DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_RS_RESOURCE_PVT

Source


1 PACKAGE BODY jtf_rs_resource_pvt AS
2   /* $Header: jtfrsvrb.pls 120.5 2010/09/09 06:44:21 rgokavar ship $ */
3 
4   /*****************************************************************************************
5    This package body defines the procedures for managing resources.
6    Its main procedures are as following:
7    Create Resource
8    Update Resource
9    These procedures do the business validations and then call the appropriate
10    table handlers to do the actual inserts and updates.
11    ******************************************************************************************/
12 
13   /* Package variables. */
14 
15   G_PKG_NAME      CONSTANT VARCHAR2(30) := 'JTF_RS_RESOURCE_PVT';
16 PROCEDURE validate_party_address(p_source_id in number,
17                                    p_address_id in number,
18                                    p_action in varchar2,
19                                    p_found   out NOCOPY boolean,
20                                    p_return_status out NOCOPY varchar);
21 
22 PROCEDURE validate_party_address(p_source_id in number,
23                                    p_address_id in number,
24                                    p_action in varchar2,
25                                    p_found   out NOCOPY boolean,
26                                    p_return_status out NOCOPY varchar)
27 IS
28 
29 cursor address_cur(l_party_id number)
30     is
31 select party_site_id
32  from  hz_party_sites
33 where party_id = l_party_id
34  and  identifying_address_flag = 'Y'
35  and  status = 'A';
36 
37 l_party_type VARCHAR2(2000);
38 l_address_id  NUMBER;
39 /* Moved the initial assignment of below variable to inside begin */
40 l_api_name    VARCHAR2(100);
41 BEGIN
42 
43   l_api_name  :=  'VALIDATE_PARTY_ADDRESS';
44 
45   p_return_status := fnd_api.g_ret_sts_success;
46   p_found := true;
47   open address_cur(p_source_id);
48   fetch address_cur into l_address_id;
49   close address_cur;
50 
51   if(nvl(p_address_id, fnd_api.g_miss_num) <> nvl(l_address_id, fnd_api.g_miss_num))
52   then
53         p_found := false;
54    end if;
55 
56  EXCEPTION
57  WHEN OTHERS
58     THEN
59       fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
60       fnd_message.set_token('P_SQLCODE',SQLCODE);
61       fnd_message.set_token('P_SQLERRM',SQLERRM);
62       fnd_message.set_token('P_API_NAME', l_api_name);
63       FND_MSG_PUB.add;
64       p_return_status := fnd_api.g_ret_sts_unexp_error;
65 
66 END;
67 
68   /* Procedure to create the resource based on input values passed by calling routines. */
69 
70   PROCEDURE  create_resource
71   (P_API_VERSION             IN   NUMBER,
72    P_INIT_MSG_LIST           IN   VARCHAR2,
73    P_COMMIT                  IN   VARCHAR2,
74    P_CATEGORY                IN   JTF_RS_RESOURCE_EXTNS.CATEGORY%TYPE,
75    P_SOURCE_ID               IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ID%TYPE,
76    P_ADDRESS_ID              IN   JTF_RS_RESOURCE_EXTNS.ADDRESS_ID%TYPE,
77    P_CONTACT_ID              IN   JTF_RS_RESOURCE_EXTNS.CONTACT_ID%TYPE,
78    P_MANAGING_EMP_ID         IN   JTF_RS_RESOURCE_EXTNS.MANAGING_EMPLOYEE_ID%TYPE,
79    P_START_DATE_ACTIVE       IN   JTF_RS_RESOURCE_EXTNS.START_DATE_ACTIVE%TYPE,
80    P_END_DATE_ACTIVE         IN   JTF_RS_RESOURCE_EXTNS.END_DATE_ACTIVE%TYPE,
81    P_TIME_ZONE               IN   JTF_RS_RESOURCE_EXTNS.TIME_ZONE%TYPE,
82    P_COST_PER_HR             IN   JTF_RS_RESOURCE_EXTNS.COST_PER_HR%TYPE,
83    P_PRIMARY_LANGUAGE        IN   JTF_RS_RESOURCE_EXTNS.PRIMARY_LANGUAGE%TYPE,
84    P_SECONDARY_LANGUAGE      IN   JTF_RS_RESOURCE_EXTNS.SECONDARY_LANGUAGE%TYPE,
85    P_SUPPORT_SITE_ID         IN   JTF_RS_RESOURCE_EXTNS.SUPPORT_SITE_ID%TYPE,
86    P_IES_AGENT_LOGIN         IN   JTF_RS_RESOURCE_EXTNS.IES_AGENT_LOGIN%TYPE,
87    P_SERVER_GROUP_ID         IN   JTF_RS_RESOURCE_EXTNS.SERVER_GROUP_ID%TYPE,
88    P_ASSIGNED_TO_GROUP_ID    IN   JTF_RS_RESOURCE_EXTNS.ASSIGNED_TO_GROUP_ID%TYPE,
89    P_COST_CENTER             IN   JTF_RS_RESOURCE_EXTNS.COST_CENTER%TYPE,
90    P_CHARGE_TO_COST_CENTER   IN   JTF_RS_RESOURCE_EXTNS.CHARGE_TO_COST_CENTER%TYPE,
91    P_COMP_CURRENCY_CODE      IN   JTF_RS_RESOURCE_EXTNS.COMPENSATION_CURRENCY_CODE%TYPE,
92    P_COMMISSIONABLE_FLAG     IN   JTF_RS_RESOURCE_EXTNS.COMMISSIONABLE_FLAG%TYPE,
93    P_HOLD_REASON_CODE        IN   JTF_RS_RESOURCE_EXTNS.HOLD_REASON_CODE%TYPE,
94    P_HOLD_PAYMENT            IN   JTF_RS_RESOURCE_EXTNS.HOLD_PAYMENT%TYPE,
95    P_COMP_SERVICE_TEAM_ID    IN   JTF_RS_RESOURCE_EXTNS.COMP_SERVICE_TEAM_ID%TYPE,
96    P_USER_ID                 IN   JTF_RS_RESOURCE_EXTNS.USER_ID%TYPE,
97    P_TRANSACTION_NUMBER      IN   JTF_RS_RESOURCE_EXTNS.TRANSACTION_NUMBER%TYPE,
98  --P_LOCATION                IN   MDSYS.SDO_GEOMETRY,
99    P_ATTRIBUTE1              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE1%TYPE,
100    P_ATTRIBUTE2              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE2%TYPE,
101    P_ATTRIBUTE3              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE3%TYPE,
102    P_ATTRIBUTE4              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE4%TYPE,
103    P_ATTRIBUTE5              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE5%TYPE,
104    P_ATTRIBUTE6              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE6%TYPE,
105    P_ATTRIBUTE7              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE7%TYPE,
106    P_ATTRIBUTE8              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE8%TYPE,
107    P_ATTRIBUTE9              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE9%TYPE,
108    P_ATTRIBUTE10             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE10%TYPE,
109    P_ATTRIBUTE11             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE11%TYPE,
110    P_ATTRIBUTE12             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE12%TYPE,
111    P_ATTRIBUTE13             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE13%TYPE,
112    P_ATTRIBUTE14             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE14%TYPE,
113    P_ATTRIBUTE15             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE15%TYPE,
114    P_ATTRIBUTE_CATEGORY      IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE_CATEGORY%TYPE,
115    X_RETURN_STATUS           OUT NOCOPY  VARCHAR2,
116    X_MSG_COUNT               OUT NOCOPY  NUMBER,
117    X_MSG_DATA                OUT NOCOPY  VARCHAR2,
118    X_RESOURCE_ID             OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
119    X_RESOURCE_NUMBER         OUT NOCOPY JTF_RS_RESOURCE_EXTNS.RESOURCE_NUMBER%TYPE
120   ) IS
121 
122     l_api_version         	CONSTANT NUMBER := 1.0;
123     l_api_name            	CONSTANT VARCHAR2(30) := 'CREATE_RESOURCE';
124   /* Moved the initial assignment of below variables to inside begin */
125     l_category                  jtf_rs_resource_extns.category%TYPE;
126     l_source_id                 jtf_rs_resource_extns.source_id%TYPE;
127     l_address_id                jtf_rs_resource_extns.address_id%TYPE;
128     l_contact_id                jtf_rs_resource_extns.contact_id%TYPE;
129     l_managing_emp_id           jtf_rs_resource_extns.managing_employee_id%TYPE;
130     -- added trunc in both dates feb 6 2002
131     l_start_date_active         jtf_rs_resource_extns.start_date_active%TYPE;
132     l_end_date_active           jtf_rs_resource_extns.end_date_active%TYPE;
133     l_time_zone                 jtf_rs_resource_extns.time_zone%TYPE;
134     l_cost_per_hr               jtf_rs_resource_extns.cost_per_hr%TYPE;
135     l_primary_language          jtf_rs_resource_extns.primary_language%TYPE;
136     l_secondary_language        jtf_rs_resource_extns.secondary_language%TYPE;
137     l_support_site_id           jtf_rs_resource_extns.support_site_id%TYPE;
138     l_ies_agent_login           jtf_rs_resource_extns.ies_agent_login%TYPE;
139     l_server_group_id           jtf_rs_resource_extns.server_group_id%TYPE;
140     l_assigned_to_group_id      jtf_rs_resource_extns.assigned_to_group_id%TYPE;
141     l_cost_center               jtf_rs_resource_extns.cost_center%TYPE;
142     l_charge_to_cost_center     jtf_rs_resource_extns.charge_to_cost_center%TYPE;
143     l_comp_currency_code        jtf_rs_resource_extns.compensation_currency_code%TYPE;
144     l_commissionable_flag       jtf_rs_resource_extns.commissionable_flag%TYPE;
145     l_hold_reason_code          jtf_rs_resource_extns.hold_reason_code%TYPE;
146     l_hold_payment              jtf_rs_resource_extns.hold_payment%TYPE;
147     l_comp_service_team_id      jtf_rs_resource_extns.comp_service_team_id%TYPE;
148     l_user_id                   jtf_rs_resource_extns.user_id%TYPE;
149     l_transaction_number        jtf_rs_resource_extns.transaction_number%TYPE;
150     --l_location                MDSYS.SDO_GEOMETRY 				:= p_location;
151 
152     l_check_char                VARCHAR2(1);
153     l_check_dup_id		VARCHAR2(1);
154     l_rowid                     ROWID;
155     l_resource_id               jtf_rs_resource_extns.resource_id%TYPE;
156     l_resource_number           jtf_rs_resource_extns.resource_number%TYPE;
157     l_bind_data_id              NUMBER;
158 
159     CURSOR c_jtf_rs_resource_extns( l_rowid   IN  ROWID ) IS
160 	 SELECT 'Y'
161 	 FROM jtf_rs_resource_extns
162 	 WHERE ROWID = l_rowid;
163 
164     CURSOR c_dup_resource_id (l_resource_id IN jtf_rs_resource_extns.resource_id%type) IS
165         SELECT 'X'
166         FROM jtf_rs_resource_extns
167         WHERE resource_id = l_resource_id;
168 
169     l_value                      VARCHAR2(100);
170     l_address_ret_status         varchar2(10);
171     l_address_found              boolean := true;
172 
173   BEGIN
174 
175     l_category                   := upper(p_category);
176     l_source_id                  := p_source_id;
177     l_address_id                 := p_address_id;
178     l_contact_id                 := p_contact_id;
179     l_managing_emp_id            := p_managing_emp_id;
180     l_start_date_active          := trunc(p_start_date_active);
181     l_end_date_active            := trunc(p_end_date_active);
182     l_time_zone                  := p_time_zone;
183     l_cost_per_hr                := p_cost_per_hr;
184     l_primary_language           := p_primary_language;
185     l_secondary_language         := p_secondary_language;
186     l_support_site_id            := p_support_site_id;
187     l_ies_agent_login            := p_ies_agent_login;
188     l_server_group_id            := p_server_group_id;
189     l_assigned_to_group_id       := p_assigned_to_group_id;
190     l_cost_center                := p_cost_center;
191     l_charge_to_cost_center      := p_charge_to_cost_center;
192     l_comp_currency_code         := p_comp_currency_code;
193     l_commissionable_flag        := p_commissionable_flag;
194     l_hold_reason_code           := p_hold_reason_code;
195     l_hold_payment               := p_hold_payment;
196     l_comp_service_team_id       := p_comp_service_team_id;
197     l_user_id                    := p_user_id;
198     l_transaction_number         := p_transaction_number;
199 
200     SAVEPOINT create_resource_pvt;
201 
202     x_return_status := fnd_api.g_ret_sts_success;
203 
204 --    DBMS_OUTPUT.put_line(' Started Create Resource Pvt ');
205 
206 
207 
208     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
209 
210       RAISE fnd_api.g_exc_unexpected_error;
211 
212     END IF;
213 
214 
215     IF fnd_api.to_boolean(p_init_msg_list) THEN
216 
217       fnd_msg_pub.initialize;
218 
219     END IF;
220 
221 
222     /* Make the pre processing call to the user hooks */
223 
224     /* Pre Call to the Customer Type User Hook */
225 
226     IF jtf_resource_utl.ok_to_execute(
227 	 'JTF_RS_RESOURCE_PVT',
228 	 'CREATE_RESOURCE',
229 	 'B',
230 	 'C')
231     THEN
232     IF jtf_usr_hks.ok_to_execute(
233 	 'JTF_RS_RESOURCE_PVT',
234 	 'CREATE_RESOURCE',
235 	 'B',
236 	 'C')
237     THEN
238 
239       jtf_rs_resource_cuhk.create_resource_pre(
240         p_category             => l_category,
241         p_source_id            => l_source_id,
242         p_address_id           => l_address_id,
243         p_contact_id           => l_contact_id,
244         p_managing_emp_id      => l_managing_emp_id,
245         p_start_date_active    => l_start_date_active,
246         p_end_date_active      => l_end_date_active,
247         p_time_zone            => l_time_zone,
248         p_cost_per_hr          => l_cost_per_hr,
249         p_primary_language     => l_primary_language,
250         p_secondary_language   => l_secondary_language,
251         p_support_site_id      => l_support_site_id,
252         p_ies_agent_login      => l_ies_agent_login,
253         p_server_group_id      => l_server_group_id,
254         p_assigned_to_group_id => l_assigned_to_group_id,
255         p_cost_center          => l_cost_center,
256         p_charge_to_cost_center=> l_charge_to_cost_center,
257         p_comp_currency_code   => l_comp_currency_code,
258         p_commissionable_flag  => l_commissionable_flag,
259         p_hold_reason_code     => l_hold_reason_code,
260         p_hold_payment         => l_hold_payment,
261         p_comp_service_team_id => l_comp_service_team_id,
262         p_user_id              => l_user_id,
263         --p_location           => l_location,
264 	x_return_status        => x_return_status);
265 
266       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
267 
268 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
269 
270 
271 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
272 	   fnd_msg_pub.add;
273 
274 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
275 		RAISE FND_API.G_EXC_ERROR;
276 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
277 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
278 	   END IF;
279 
280       END IF;
281 
282     END IF;
283     END IF;
284 
285 
286     /* Pre Call to the Vertical Type User Hook */
287 
288     IF jtf_resource_utl.ok_to_execute(
289 	 'JTF_RS_RESOURCE_PVT',
290 	 'CREATE_RESOURCE',
291 	 'B',
292 	 'V')
293     THEN
294     IF jtf_usr_hks.ok_to_execute(
295 	 'JTF_RS_RESOURCE_PVT',
296 	 'CREATE_RESOURCE',
297 	 'B',
298 	 'V')
299     THEN
300 
301       jtf_rs_resource_vuhk.create_resource_pre(
302         p_category => l_category,
303         p_source_id => l_source_id,
304         p_address_id => l_address_id,
305         p_contact_id => l_contact_id,
306         p_managing_emp_id => l_managing_emp_id,
307         p_start_date_active => l_start_date_active,
308         p_end_date_active => l_end_date_active,
309         p_time_zone => l_time_zone,
310         p_cost_per_hr => l_cost_per_hr,
311         p_primary_language => l_primary_language,
312         p_secondary_language => l_secondary_language,
313         p_support_site_id => l_support_site_id,
314         p_ies_agent_login => l_ies_agent_login,
315         p_server_group_id => l_server_group_id,
316         p_assigned_to_group_id => l_assigned_to_group_id,
317         p_cost_center => l_cost_center,
318         p_charge_to_cost_center => l_charge_to_cost_center,
319         p_comp_currency_code => l_comp_currency_code,
320         p_commissionable_flag => l_commissionable_flag,
321         p_hold_reason_code => l_hold_reason_code,
322         p_hold_payment => l_hold_payment,
323         p_comp_service_team_id => l_comp_service_team_id,
324         p_user_id => l_user_id,
325         --p_location => l_location,
326 	   x_return_status => x_return_status);
327 
328       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
329 
330 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
331 
332 
333 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
334 	   fnd_msg_pub.add;
335 
336 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
337 		RAISE FND_API.G_EXC_ERROR;
338 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
339 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
340 	   END IF;
341 
342 
343       END IF;
344 
345     END IF;
346     END IF;
347 
348 
349     /* Pre Call to the Internal Type User Hook */
350 
351     IF jtf_resource_utl.ok_to_execute(
352 	 'JTF_RS_RESOURCE_PVT',
353 	 'CREATE_RESOURCE',
354 	 'B',
355 	 'I')
356     THEN
357     IF jtf_usr_hks.ok_to_execute(
358 	 'JTF_RS_RESOURCE_PVT',
359 	 'CREATE_RESOURCE',
360 	 'B',
361 	 'I')
362     THEN
363 
364       jtf_rs_resource_iuhk.create_resource_pre(
365         p_category => l_category,
366         p_source_id => l_source_id,
367         p_address_id => l_address_id,
368         p_contact_id => l_contact_id,
369         p_managing_emp_id => l_managing_emp_id,
370         p_start_date_active => l_start_date_active,
371         p_end_date_active => l_end_date_active,
372         p_time_zone => l_time_zone,
373         p_cost_per_hr => l_cost_per_hr,
374         p_primary_language => l_primary_language,
375         p_secondary_language => l_secondary_language,
376         p_support_site_id => l_support_site_id,
377         p_ies_agent_login => l_ies_agent_login,
378         p_server_group_id => l_server_group_id,
379         p_assigned_to_group_id => l_assigned_to_group_id,
380         p_cost_center => l_cost_center,
381         p_charge_to_cost_center => l_charge_to_cost_center,
382         p_comp_currency_code => l_comp_currency_code,
383         p_commissionable_flag => l_commissionable_flag,
384         p_hold_reason_code => l_hold_reason_code,
385         p_hold_payment => l_hold_payment,
386         p_comp_service_team_id => l_comp_service_team_id,
387         p_user_id => l_user_id,
388         --p_location => l_location,
389 	   x_return_status => x_return_status);
390 
391       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
392 
393 
394 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
395 	   fnd_msg_pub.add;
396 
397 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
398 		RAISE FND_API.G_EXC_ERROR;
399 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
400 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
401 	   END IF;
402 
403       END IF;
404 
405     END IF;
406     END IF;
407 
408 
409 
410     /* Validate the Input Dates */
411 
412     jtf_resource_utl.validate_input_dates(
413       p_start_date_active => l_start_date_active,
414       p_end_date_active => l_end_date_active,
415       x_return_status => x_return_status
416     );
417 
418     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
419 
420       IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
421 	   RAISE FND_API.G_EXC_ERROR;
422       ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
423 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
424       END IF;
425 
426     END IF;
427 
428       /* Validate for address id in case of PARTNER and PARTY */
429    if(p_category IN  ('PARTNER', 'PARTY'))
430    then
431      if (p_address_id is NOT NULL) then
432         validate_party_address(p_source_id => p_source_id,
433                             p_address_id => p_address_id,
434                             p_action => 'I',
435                             p_found  => l_address_found,
436                             p_return_status => l_address_ret_status);
437 
438         if(l_address_ret_status <> fnd_api.g_ret_sts_success)
439         then
440 	  IF L_ADDRESS_RET_STATUS = FND_API.G_RET_STS_ERROR THEN
441 	       RAISE FND_API.G_EXC_ERROR;
442 	  ELSIF L_ADDRESS_RET_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
443 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
444 	  END IF;
445 
446         end if;
447 
448        if not(l_address_found)
449        then
450           fnd_message.set_name('JTF', 'JTF_RS_NOT_PRIMARY_ADDR');
451           fnd_msg_pub.add;
452           RAISE fnd_api.g_exc_error;
453 
454        end if;
455      end if;
456    end if; -- end of partner address check
457 
458    /* This portion of the code was modified to accomodate the calls to Migration API */
459    /* Check if the Global Variable Flag for Resource ID is Y or N */
460 
461 --     dbms_output.put_line ('Before checkin the Global flag in PVT API');
462 
463       IF (G_RS_ID_PVT_FLAG = 'Y') OR (G_RS_ID_PVT_FLAG = 'N' AND JTF_RS_RESOURCE_PUB.G_RESOURCE_ID IS NULL) THEN
464 
465          /* Get the next value of the Resource_id from the sequence. */
466 
467          LOOP
468             SELECT jtf_rs_resource_extns_s.nextval
469             INTO l_resource_id
470             FROM dual;
471             --dbms_output.put_line ('After Select - Resource ID ' || l_resource_id);
472             OPEN c_dup_resource_id (l_resource_id);
473             FETCH c_dup_resource_id INTO l_check_dup_id;
474             EXIT WHEN c_dup_resource_id%NOTFOUND;
475             CLOSE c_dup_resource_id;
476          END LOOP;
477          CLOSE c_dup_resource_id;
478       ELSE
479         l_resource_id 		:= JTF_RS_RESOURCE_PUB.G_RESOURCE_ID;
480       END IF;
481 
482       /* Get the next value of the Resource_number from the sequence. */
483 
484           SELECT jtf_rs_resource_number_s.nextval
485           INTO l_resource_number
486           FROM dual;
487 
488     /* Make a call to the Resource Audit API */
489 
490     jtf_rs_resource_extns_aud_pvt.insert_resource
491     (P_API_VERSION => 1,
492      P_INIT_MSG_LIST => fnd_api.g_false,
493      P_COMMIT => fnd_api.g_false,
494      P_RESOURCE_ID => l_resource_id,
495      P_RESOURCE_NUMBER => l_resource_number,
496      P_CATEGORY => l_category,
497      P_SOURCE_ID => l_source_id,
498      P_ADDRESS_ID => l_address_id,
499      P_CONTACT_ID => l_contact_id,
500      P_MANAGING_EMP_ID => l_managing_emp_id,
501      P_START_DATE_ACTIVE => l_start_date_active,
502      P_END_DATE_ACTIVE => l_end_date_active,
503      P_TIME_ZONE => l_time_zone,
504      P_COST_PER_HR => l_cost_per_hr,
505      P_PRIMARY_LANGUAGE => l_primary_language,
506      P_SECONDARY_LANGUAGE => l_secondary_language,
507      P_SUPPORT_SITE_ID => l_support_site_id,
508      P_IES_AGENT_LOGIN => l_ies_agent_login,
509      P_SERVER_GROUP_ID => l_server_group_id,
510      P_ASSIGNED_TO_GROUP_ID => l_assigned_to_group_id,
511      P_COST_CENTER => l_cost_center,
512      P_CHARGE_TO_COST_CENTER => l_charge_to_cost_center,
513      P_COMP_CURRENCY_CODE => l_comp_currency_code,
514      P_COMMISSIONABLE_FLAG => l_commissionable_flag,
515      P_HOLD_REASON_CODE => l_hold_reason_code,
516      P_HOLD_PAYMENT => l_hold_payment,
517      P_COMP_SERVICE_TEAM_ID => l_comp_service_team_id,
518      P_USER_ID => l_user_id,
519      P_TRANSACTION_NUMBER => l_transaction_number,
520      --P_LOCATION => l_location,
521      P_OBJECT_VERSION_NUMBER => 1,
522      X_RETURN_STATUS => x_return_status,
523      X_MSG_COUNT => x_msg_count,
524      X_MSG_DATA => x_msg_data
525     );
526 
527     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
528 --    dbms_output.put_line('Failed status from call to audit procedure');
529       IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
530 	   RAISE FND_API.G_EXC_ERROR;
531       ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
532 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
533       END IF;
534 
535     END IF;
536 
537     /* Insert the row into the table by calling the table handler. */
538 
539     jtf_rs_resource_extns_pkg.insert_row(
540       x_rowid                      => l_rowid,
541       x_resource_id                => l_resource_id,
542       x_category                   => l_category,
543       x_resource_number            => l_resource_number,
544       x_source_id                  => l_source_id,
545       x_address_id                 => l_address_id,
546       x_contact_id                 => l_contact_id,
547       x_managing_employee_id       => l_managing_emp_id,
548       x_start_date_active          => l_start_date_active,
549       x_end_date_active            => l_end_date_active,
550       x_time_zone                  => l_time_zone,
551       x_cost_per_hr                => l_cost_per_hr,
552       x_primary_language           => l_primary_language,
553       x_secondary_language         => l_secondary_language,
554       x_support_site_id            => l_support_site_id,
555       x_ies_agent_login            => l_ies_agent_login,
556       x_server_group_id            => l_server_group_id,
557       x_assigned_to_group_id       => l_assigned_to_group_id,
558       x_cost_center                => l_cost_center,
559       x_charge_to_cost_center      => l_charge_to_cost_center,
560       x_compensation_currency_code => l_comp_currency_code,
561       x_commissionable_flag        => l_commissionable_flag,
562       x_hold_reason_code           => l_hold_reason_code,
563       x_hold_payment               => l_hold_payment,
564       x_comp_service_team_id       => l_comp_service_team_id,
565       x_user_id                    => l_user_id,
566       --x_location                 => l_location,
567       x_transaction_number         => l_transaction_number,
568       x_attribute1                 => p_attribute1,
569       x_attribute2                 => p_attribute2,
570       x_attribute3                 => p_attribute3,
571       x_attribute4                 => p_attribute4,
572       x_attribute5                 => p_attribute5,
573       x_attribute6                 => p_attribute6,
574       x_attribute7                 => p_attribute7,
575       x_attribute8                 => p_attribute8,
576       x_attribute9                 => p_attribute9,
577       x_attribute10                => p_attribute10,
578       x_attribute11                => p_attribute11,
579       x_attribute12                => p_attribute12,
580       x_attribute13                => p_attribute13,
581       x_attribute14                => p_attribute14,
582       x_attribute15                => p_attribute15,
583       x_attribute_category         => p_attribute_category,
584       x_creation_date              => SYSDATE,
585       x_created_by                 => jtf_resource_utl.created_by,
586       x_last_update_date           => SYSDATE,
587       x_last_updated_by            => jtf_resource_utl.updated_by,
588       x_last_update_login          => jtf_resource_utl.login_id
589     );
590 
591 --    dbms_output.put_line('After Insert Procedure');
592     OPEN c_jtf_rs_resource_extns(l_rowid);
593     FETCH c_jtf_rs_resource_extns INTO l_check_char;
594 
595     IF c_jtf_rs_resource_extns%NOTFOUND THEN
596 --    dbms_output.put_line('Error in Table Handler');
597       IF c_jtf_rs_resource_extns%ISOPEN THEN
598         CLOSE c_jtf_rs_resource_extns;
599       END IF;
600 
601 	 fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
602 	 fnd_msg_pub.add;
603          RAISE fnd_api.g_exc_error;
604 
605     ELSE
606 
607 --	 dbms_output.put_line('Resource Successfully Created');
608 	 x_resource_id := l_resource_id;
609 	 x_resource_number := l_resource_number;
610 
611     END IF;
612 
613 
614     /* Close the cursors */
615 
616     IF c_jtf_rs_resource_extns%ISOPEN THEN
617       CLOSE c_jtf_rs_resource_extns;
618     END IF;
619 
620 
621     /* Make the post processing call to the user hooks */
622 
623     /* Post Call to the Customer Type User Hook */
624 
625     IF jtf_usr_hks.ok_to_execute(
626 	 'JTF_RS_RESOURCE_PVT',
627 	 'CREATE_RESOURCE',
628 	 'A',
629 	 'C')
630     THEN
631 
632       jtf_rs_resource_cuhk.create_resource_post(
633         p_resource_id => l_resource_id,
634         p_category => l_category,
635         p_source_id => l_source_id,
636         p_address_id => l_address_id,
637         p_contact_id => l_contact_id,
638         p_managing_emp_id => l_managing_emp_id,
639         p_start_date_active => l_start_date_active,
640         p_end_date_active => l_end_date_active,
641         p_time_zone => l_time_zone,
642         p_cost_per_hr => l_cost_per_hr,
643         p_primary_language => l_primary_language,
644         p_secondary_language => l_secondary_language,
645         p_support_site_id => l_support_site_id,
646         p_ies_agent_login => l_ies_agent_login,
647         p_server_group_id => l_server_group_id,
648         p_assigned_to_group_id => l_assigned_to_group_id,
649         p_cost_center => l_cost_center,
650         p_charge_to_cost_center => l_charge_to_cost_center,
651         p_comp_currency_code => l_comp_currency_code,
652         p_commissionable_flag => l_commissionable_flag,
653         p_hold_reason_code => l_hold_reason_code,
654         p_hold_payment => l_hold_payment,
655         p_comp_service_team_id => l_comp_service_team_id,
656         p_user_id => l_user_id,
657         --p_location => l_location,
658 	   x_return_status => x_return_status);
659 
660       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
661 
662 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
663 
664 
665 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
666 	   fnd_msg_pub.add;
667 
668 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
669 		RAISE FND_API.G_EXC_ERROR;
670 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
671 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
672 	   END IF;
673 
674       END IF;
675 
676     END IF;
677 
678 
679     /* Post Call to the Vertical Type User Hook */
680 
681     IF jtf_usr_hks.ok_to_execute(
682 	 'JTF_RS_RESOURCE_PVT',
683 	 'CREATE_RESOURCE',
684 	 'A',
685 	 'V')
686     THEN
687 
688       jtf_rs_resource_vuhk.create_resource_post(
689         p_resource_id => l_resource_id,
690         p_category => l_category,
691         p_source_id => l_source_id,
692         p_address_id => l_address_id,
693         p_contact_id => l_contact_id,
694         p_managing_emp_id => l_managing_emp_id,
695         p_start_date_active => l_start_date_active,
696         p_end_date_active => l_end_date_active,
697         p_time_zone => l_time_zone,
698         p_cost_per_hr => l_cost_per_hr,
699         p_primary_language => l_primary_language,
700         p_secondary_language => l_secondary_language,
701         p_support_site_id => l_support_site_id,
702         p_ies_agent_login => l_ies_agent_login,
703         p_server_group_id => l_server_group_id,
704         p_assigned_to_group_id => l_assigned_to_group_id,
705         p_cost_center => l_cost_center,
706         p_charge_to_cost_center => l_charge_to_cost_center,
707         p_comp_currency_code => l_comp_currency_code,
708         p_commissionable_flag => l_commissionable_flag,
709         p_hold_reason_code => l_hold_reason_code,
710         p_hold_payment => l_hold_payment,
711         p_comp_service_team_id => l_comp_service_team_id,
712         p_user_id => l_user_id,
713         --p_location => l_location,
714 	   x_return_status => x_return_status);
715 
716       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
717 
718 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
719 
720 
721 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
722 	   fnd_msg_pub.add;
723 
724 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
725 		RAISE FND_API.G_EXC_ERROR;
726 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
727 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
728 	   END IF;
729 
730       END IF;
731 
732     END IF;
733 
734 
735     /* Post Call to the Internal Type User Hook */
736 
737     IF jtf_resource_utl.ok_to_execute(
738 	 'JTF_RS_RESOURCE_PVT',
739 	 'CREATE_RESOURCE',
740 	 'A',
741 	 'I')
742     THEN
743     IF jtf_usr_hks.ok_to_execute(
744 	 'JTF_RS_RESOURCE_PVT',
745 	 'CREATE_RESOURCE',
746 	 'A',
747 	 'I')
748     THEN
749 
750       jtf_rs_resource_iuhk.create_resource_post(
751         p_resource_id => l_resource_id,
752         p_category => l_category,
753         p_source_id => l_source_id,
754         p_address_id => l_address_id,
755         p_contact_id => l_contact_id,
756         p_managing_emp_id => l_managing_emp_id,
757         p_start_date_active => l_start_date_active,
758         p_end_date_active => l_end_date_active,
759         p_time_zone => l_time_zone,
760         p_cost_per_hr => l_cost_per_hr,
761         p_primary_language => l_primary_language,
762         p_secondary_language => l_secondary_language,
763         p_support_site_id => l_support_site_id,
764         p_ies_agent_login => l_ies_agent_login,
765         p_server_group_id => l_server_group_id,
766         p_assigned_to_group_id => l_assigned_to_group_id,
767         p_cost_center => l_cost_center,
768         p_charge_to_cost_center => l_charge_to_cost_center,
769         p_comp_currency_code => l_comp_currency_code,
770         p_commissionable_flag => l_commissionable_flag,
771         p_hold_reason_code => l_hold_reason_code,
772         p_hold_payment => l_hold_payment,
773         p_comp_service_team_id => l_comp_service_team_id,
774         p_user_id => l_user_id,
775        -- p_location => l_location,
776 	   x_return_status => x_return_status);
777 
778       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
779 
780 
781 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
782 	   fnd_msg_pub.add;
783 
784 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
785 		RAISE FND_API.G_EXC_ERROR;
786 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
787 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
788 	   END IF;
789 
790       END IF;
791 
792     END IF;
793     END IF;
794 
795 
796     /* Standard call for Message Generation */
797 
798     IF jtf_resource_utl.ok_to_execute(
799 	 'JTF_RS_RESOURCE_PVT',
800 	 'CREATE_RESOURCE',
801 	 'M',
802 	 'M')
803     THEN
804     IF jtf_usr_hks.ok_to_execute(
805 	 'JTF_RS_RESOURCE_PVT',
806 	 'CREATE_RESOURCE',
807 	 'M',
808 	 'M')
809     THEN
810 
811       IF (jtf_rs_resource_cuhk.ok_to_generate_msg(
812 	       p_resource_id => l_resource_id,
813 	       x_return_status => x_return_status) )
814       THEN
815 
816         /* Get the bind data id for the Business Object Instance */
817 
818         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
819 
820 
821         /* Set bind values for the bind variables in the Business Object SQL */
822 
823         jtf_usr_hks.load_bind_data(l_bind_data_id, 'resource_id', l_resource_id, 'S', 'N');
824 
825 
826         /* Call the message generation API */
827 
828         jtf_usr_hks.generate_message(
829 		p_prod_code => 'JTF',
830 		p_bus_obj_code => 'RS_RES',
831 		p_action_code => 'I',
832 		p_bind_data_id => l_bind_data_id,
833 		x_return_code => x_return_status);
834 
835 
836         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
837 
838 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
839 
840 
841 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
842 	     fnd_msg_pub.add;
843 
844 	     IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
845 		  RAISE FND_API.G_EXC_ERROR;
846 	     ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
847 		  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
848 	     END IF;
849 
850         END IF;
851 
852       END IF;
853 
854     END IF;
855     END IF;
856 
857 
858     IF fnd_api.to_boolean(p_commit) THEN
859 
860 	 COMMIT WORK;
861 
862     END IF;
863 
864     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
865 
866 
867   EXCEPTION
868 
869     WHEN fnd_api.g_exc_error THEN
870       ROLLBACK TO create_resource_pvt;
871       x_return_status := fnd_api.g_ret_sts_error;
872       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
873                                  p_data => x_msg_data);
874     WHEN fnd_api.g_exc_unexpected_error THEN
875       ROLLBACK TO create_resource_pvt;
876       x_return_status := fnd_api.g_ret_sts_unexp_error;
877       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
878                                  p_data => x_msg_data);
879     WHEN OTHERS THEN
880       ROLLBACK TO create_resource_pvt;
881 -- The below lines removed as a part of fixing GSCC errors in R12 for jtfrspub.pls
882 --      IF NOT(jtf_resource_utl.check_access(l_value))
883 --      THEN
884 --            IF(l_value = 'XMLGEN')
885 --            THEN
886 --		 fnd_message.set_name ('JTF', 'JTF_RS_XMLGEN_ERR');
887 --		 FND_MSG_PUB.add;
888 --            ELSIF(l_value = 'JTF_USR_HKS')
889 --            THEN
890 --		 fnd_message.set_name ('JTF', 'JTF_RS_JUHK_ERR');
891 --		 FND_MSG_PUB.add;
892 --            END IF;
893 --      ELSE
894 	 fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
895 	 fnd_message.set_token('P_SQLCODE',SQLCODE);
896 	 fnd_message.set_token('P_SQLERRM',SQLERRM);
897 	 fnd_message.set_token('P_API_NAME', l_api_name);
898 	 FND_MSG_PUB.add;
899 --      END IF;
900       x_return_status := fnd_api.g_ret_sts_unexp_error;
901       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
902                                  p_data => x_msg_data);
903 
904   END create_resource;
905 
906   /* Create Resource Procedure Overloaded, for Resource Synchronization Purposes */
907 
908   PROCEDURE  create_resource
909   (P_API_VERSION             IN   NUMBER,
910    P_INIT_MSG_LIST           IN   VARCHAR2,
911    P_COMMIT                  IN   VARCHAR2,
912    P_CATEGORY                IN   JTF_RS_RESOURCE_EXTNS.CATEGORY%TYPE,
913    P_SOURCE_ID               IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ID%TYPE,
914    P_ADDRESS_ID              IN   JTF_RS_RESOURCE_EXTNS.ADDRESS_ID%TYPE,
915    P_CONTACT_ID              IN   JTF_RS_RESOURCE_EXTNS.CONTACT_ID%TYPE,
916    P_MANAGING_EMP_ID         IN   JTF_RS_RESOURCE_EXTNS.MANAGING_EMPLOYEE_ID%TYPE,
917    P_START_DATE_ACTIVE       IN   JTF_RS_RESOURCE_EXTNS.START_DATE_ACTIVE%TYPE,
918    P_END_DATE_ACTIVE         IN   JTF_RS_RESOURCE_EXTNS.END_DATE_ACTIVE%TYPE,
919    P_TIME_ZONE               IN   JTF_RS_RESOURCE_EXTNS.TIME_ZONE%TYPE,
920    P_COST_PER_HR             IN   JTF_RS_RESOURCE_EXTNS.COST_PER_HR%TYPE,
921    P_PRIMARY_LANGUAGE        IN   JTF_RS_RESOURCE_EXTNS.PRIMARY_LANGUAGE%TYPE,
922    P_SECONDARY_LANGUAGE      IN   JTF_RS_RESOURCE_EXTNS.SECONDARY_LANGUAGE%TYPE,
923    P_SUPPORT_SITE_ID         IN   JTF_RS_RESOURCE_EXTNS.SUPPORT_SITE_ID%TYPE,
924    P_IES_AGENT_LOGIN         IN   JTF_RS_RESOURCE_EXTNS.IES_AGENT_LOGIN%TYPE,
925    P_SERVER_GROUP_ID         IN   JTF_RS_RESOURCE_EXTNS.SERVER_GROUP_ID%TYPE,
926    P_ASSIGNED_TO_GROUP_ID    IN   JTF_RS_RESOURCE_EXTNS.ASSIGNED_TO_GROUP_ID%TYPE,
927    P_COST_CENTER             IN   JTF_RS_RESOURCE_EXTNS.COST_CENTER%TYPE,
928    P_CHARGE_TO_COST_CENTER   IN   JTF_RS_RESOURCE_EXTNS.CHARGE_TO_COST_CENTER%TYPE,
929    P_COMP_CURRENCY_CODE      IN   JTF_RS_RESOURCE_EXTNS.COMPENSATION_CURRENCY_CODE%TYPE,
930    P_COMMISSIONABLE_FLAG     IN   JTF_RS_RESOURCE_EXTNS.COMMISSIONABLE_FLAG%TYPE,
931    P_HOLD_REASON_CODE        IN   JTF_RS_RESOURCE_EXTNS.HOLD_REASON_CODE%TYPE,
932    P_HOLD_PAYMENT            IN   JTF_RS_RESOURCE_EXTNS.HOLD_PAYMENT%TYPE,
933    P_COMP_SERVICE_TEAM_ID    IN   JTF_RS_RESOURCE_EXTNS.COMP_SERVICE_TEAM_ID%TYPE,
934    P_USER_ID                 IN   JTF_RS_RESOURCE_EXTNS.USER_ID%TYPE,
935    P_TRANSACTION_NUMBER      IN   JTF_RS_RESOURCE_EXTNS.TRANSACTION_NUMBER%TYPE,
936  --P_LOCATION                IN   MDSYS.SDO_GEOMETRY,
937    P_ATTRIBUTE1              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE1%TYPE,
938    P_ATTRIBUTE2              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE2%TYPE,
939    P_ATTRIBUTE3              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE3%TYPE,
940    P_ATTRIBUTE4              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE4%TYPE,
941    P_ATTRIBUTE5              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE5%TYPE,
942    P_ATTRIBUTE6              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE6%TYPE,
943    P_ATTRIBUTE7              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE7%TYPE,
944    P_ATTRIBUTE8              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE8%TYPE,
945    P_ATTRIBUTE9              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE9%TYPE,
946    P_ATTRIBUTE10             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE10%TYPE,
947    P_ATTRIBUTE11             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE11%TYPE,
948    P_ATTRIBUTE12             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE12%TYPE,
949    P_ATTRIBUTE13             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE13%TYPE,
950    P_ATTRIBUTE14             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE14%TYPE,
951    P_ATTRIBUTE15             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE15%TYPE,
952    P_ATTRIBUTE_CATEGORY      IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE_CATEGORY%TYPE,
953    P_RESOURCE_NAME	     IN   JTF_RS_RESOURCE_EXTNS_TL.RESOURCE_NAME%TYPE,
954    P_SOURCE_NAME	     IN   JTF_RS_RESOURCE_EXTNS.SOURCE_NAME%TYPE ,
955    P_SOURCE_NUMBER	     IN   JTF_RS_RESOURCE_EXTNS.SOURCE_NUMBER%TYPE,
956    P_SOURCE_JOB_TITLE	     IN   JTF_RS_RESOURCE_EXTNS.SOURCE_JOB_TITLE%TYPE,
957    P_SOURCE_EMAIL            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_EMAIL%TYPE,
958    P_SOURCE_PHONE	     IN   JTF_RS_RESOURCE_EXTNS.SOURCE_PHONE%TYPE,
959    P_SOURCE_ORG_ID           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ORG_ID%TYPE,
960    P_SOURCE_ORG_NAME         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ORG_NAME%TYPE,
961    P_SOURCE_ADDRESS1	     IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS1%TYPE,
962    P_SOURCE_ADDRESS2         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS2%TYPE,
963    P_SOURCE_ADDRESS3         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS3%TYPE,
964    P_SOURCE_ADDRESS4         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS4%TYPE,
965    P_SOURCE_CITY             IN   JTF_RS_RESOURCE_EXTNS.SOURCE_CITY%TYPE,
966    P_SOURCE_POSTAL_CODE      IN   JTF_RS_RESOURCE_EXTNS.SOURCE_POSTAL_CODE%TYPE,
967    P_SOURCE_STATE            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_STATE%TYPE,
968    P_SOURCE_PROVINCE         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_PROVINCE%TYPE,
969    P_SOURCE_COUNTY           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_COUNTY%TYPE,
970    P_SOURCE_COUNTRY	     IN   JTF_RS_RESOURCE_EXTNS.SOURCE_COUNTRY%TYPE,
971    P_SOURCE_MGR_ID           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_MGR_ID%type,
972    P_SOURCE_MGR_NAME         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_MGR_NAME%type,
973    P_SOURCE_BUSINESS_GRP_ID  IN   JTF_RS_RESOURCE_EXTNS.SOURCE_BUSINESS_GRP_ID%type,
974    P_SOURCE_BUSINESS_GRP_NAME IN  JTF_RS_RESOURCE_EXTNS.SOURCE_BUSINESS_GRP_NAME%type,
975    P_SOURCE_FIRST_NAME       IN JTF_RS_RESOURCE_EXTNS.SOURCE_FIRST_NAME%TYPE,
976    P_SOURCE_LAST_NAME        IN JTF_RS_RESOURCE_EXTNS.SOURCE_LAST_NAME%TYPE,
977    P_SOURCE_MIDDLE_NAME      IN JTF_RS_RESOURCE_EXTNS.SOURCE_MIDDLE_NAME%TYPE,
978    P_SOURCE_CATEGORY         IN JTF_RS_RESOURCE_EXTNS.SOURCE_CATEGORY%TYPE,
979    P_SOURCE_STATUS           IN JTF_RS_RESOURCE_EXTNS.SOURCE_STATUS%TYPE,
980    P_SOURCE_OFFICE           IN JTF_RS_RESOURCE_EXTNS.SOURCE_OFFICE%TYPE,
981    P_SOURCE_LOCATION         IN JTF_RS_RESOURCE_EXTNS.SOURCE_LOCATION%TYPE,
982    P_SOURCE_MAILSTOP         IN JTF_RS_RESOURCE_EXTNS.SOURCE_MAILSTOP%TYPE,
983    P_USER_NAME               IN  VARCHAR2,
984    X_RETURN_STATUS           OUT NOCOPY  VARCHAR2,
985    X_MSG_COUNT               OUT NOCOPY  NUMBER,
986    X_MSG_DATA                OUT NOCOPY  VARCHAR2,
987    X_RESOURCE_ID             OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
988    X_RESOURCE_NUMBER         OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.RESOURCE_NUMBER%TYPE,
989    P_SOURCE_MOBILE_PHONE     IN  JTF_RS_RESOURCE_EXTNS.SOURCE_MOBILE_PHONE%TYPE,
990    P_SOURCE_PAGER            IN  JTF_RS_RESOURCE_EXTNS.SOURCE_PAGER%TYPE
991   ) IS
992 
993     l_api_version         	   CONSTANT NUMBER 					:= 1.0;
994     l_api_name            	   CONSTANT VARCHAR2(30) 				:= 'CREATE_RESOURCE';
995   /* Moved the initial assignment of below variables to inside begin */
996     l_category                     jtf_rs_resource_extns.category%TYPE;
997     l_source_id                    jtf_rs_resource_extns.source_id%TYPE;
998     l_address_id                   jtf_rs_resource_extns.address_id%TYPE;
999     l_contact_id                   jtf_rs_resource_extns.contact_id%TYPE;
1000     l_managing_emp_id              jtf_rs_resource_extns.managing_employee_id%TYPE;
1001     l_start_date_active            jtf_rs_resource_extns.start_date_active%TYPE;
1002     l_end_date_active              jtf_rs_resource_extns.end_date_active%TYPE;
1003     l_time_zone                    jtf_rs_resource_extns.time_zone%TYPE;
1004     l_cost_per_hr                  jtf_rs_resource_extns.cost_per_hr%TYPE;
1005     l_primary_language             jtf_rs_resource_extns.primary_language%TYPE;
1006     l_secondary_language           jtf_rs_resource_extns.secondary_language%TYPE;
1007     l_support_site_id              jtf_rs_resource_extns.support_site_id%TYPE;
1008     l_ies_agent_login              jtf_rs_resource_extns.ies_agent_login%TYPE;
1009     l_server_group_id              jtf_rs_resource_extns.server_group_id%TYPE;
1010     l_assigned_to_group_id         jtf_rs_resource_extns.assigned_to_group_id%TYPE;
1011     l_cost_center                  jtf_rs_resource_extns.cost_center%TYPE;
1012     l_charge_to_cost_center        jtf_rs_resource_extns.charge_to_cost_center%TYPE;
1013     l_comp_currency_code           jtf_rs_resource_extns.compensation_currency_code%TYPE;
1014     l_commissionable_flag          jtf_rs_resource_extns.commissionable_flag%TYPE;
1015     l_hold_reason_code             jtf_rs_resource_extns.hold_reason_code%TYPE;
1016     l_hold_payment                 jtf_rs_resource_extns.hold_payment%TYPE;
1017     l_comp_service_team_id         jtf_rs_resource_extns.comp_service_team_id%TYPE;
1018     l_user_id                      jtf_rs_resource_extns.user_id%TYPE;
1019     l_transaction_number           jtf_rs_resource_extns.transaction_number%TYPE;
1020     --l_location                     MDSYS.SDO_GEOMETRY 				:= p_location;
1021 
1022     l_check_char                   VARCHAR2(1);
1023     l_check_dup_id		   VARCHAR2(1);
1024     l_rowid                        ROWID;
1025     l_resource_id                  jtf_rs_resource_extns.resource_id%TYPE;
1026     l_resource_number              jtf_rs_resource_extns.resource_number%TYPE;
1027     l_bind_data_id                 NUMBER;
1028 
1029   /* Moved the initial assignment of below variables to inside begin */
1030     l_resource_name           jtf_rs_resource_extns_tl.resource_name%type;
1031     l_source_name             jtf_rs_resource_extns.source_name%type;
1032     l_source_number           jtf_rs_resource_extns.source_number%type;
1033     l_source_job_title        jtf_rs_resource_extns.source_job_title%type;
1034     l_source_email            jtf_rs_resource_extns.source_email%type;
1035     l_source_phone            jtf_rs_resource_extns.source_phone%type;
1036     l_source_org_id           jtf_rs_resource_extns.source_org_id%type;
1037     l_source_org_name         jtf_rs_resource_extns.source_org_name%type;
1038     l_source_address1         jtf_rs_resource_extns.source_address1%type;
1039     l_source_address2         jtf_rs_resource_extns.source_address2%type;
1040     l_source_address3         jtf_rs_resource_extns.source_address3%type;
1041     l_source_address4         jtf_rs_resource_extns.source_address4%type;
1042     l_source_city             jtf_rs_resource_extns.source_city%type;
1043     l_source_postal_code      jtf_rs_resource_extns.source_postal_code%type;
1044     l_source_state            jtf_rs_resource_extns.source_state%type;
1045     l_source_province         jtf_rs_resource_extns.source_province%type;
1046     l_source_county           jtf_rs_resource_extns.source_county%type;
1047     l_source_country          jtf_rs_resource_extns.source_country%type;
1048     l_source_mgr_id           jtf_rs_resource_extns.source_mgr_id%type;
1049     l_source_mgr_name         jtf_rs_resource_extns.source_mgr_name%type;
1050     l_source_business_grp_id  jtf_rs_resource_extns.source_business_grp_id%type;
1051     l_source_business_grp_name jtf_rs_resource_extns.source_business_grp_name%type;
1052     l_source_first_name        jtf_rs_resource_extns.source_first_name%type;
1053     l_source_last_name         jtf_rs_resource_extns.source_last_name%type;
1054     l_source_middle_name       jtf_rs_resource_extns.source_middle_name%type;
1055     l_source_category          jtf_rs_resource_extns.source_category%type;
1056     l_source_status            jtf_rs_resource_extns.source_status%type;
1057     l_source_office            jtf_rs_resource_extns.source_office%type;
1058     l_source_location          jtf_rs_resource_extns.source_location%type;
1059     l_source_mailstop          jtf_rs_resource_extns.source_mailstop%type;
1060     l_source_mobile_phone      jtf_rs_resource_extns.source_mobile_phone%type;
1061     l_source_pager             jtf_rs_resource_extns.source_pager%type;
1062     l_user_name                jtf_rs_resource_extns.user_name%type;
1063     l_source_job_id            jtf_rs_resource_extns.source_job_id%type;
1064     l_party_id                 jtf_rs_resource_extns.person_party_id%type;
1065 
1066     l_return_status             VARCHAR2(2000);
1067     l_msg_count                 NUMBER;
1068     l_msg_data                  VARCHAR2(2000);
1069 
1070     CURSOR c_jtf_rs_resource_extns( l_rowid   IN  ROWID ) IS
1071 	 SELECT 'Y'
1072 	 FROM jtf_rs_resource_extns
1073 	 WHERE ROWID = l_rowid;
1074 
1075     CURSOR c_dup_resource_id (l_resource_id IN jtf_rs_resource_extns.resource_id%type) IS
1076         SELECT 'X'
1077         FROM jtf_rs_resource_extns
1078         WHERE resource_id = l_resource_id;
1079 
1080     CURSOR c_asg(p_person_id IN NUMBER) IS
1081     SELECT job_id
1082     FROM   per_all_assignments_f
1083     WHERE  person_id = p_source_id
1084     AND    primary_flag = 'Y'
1085     AND    assignment_type in ('E','C')
1086     AND    trunc(sysdate) between effective_start_date and effective_end_date;
1087 
1088     CURSOR c_party_id(p_person_id IN NUMBER) IS
1089     SELECT ppf.party_id
1090     FROM   per_all_people_f ppf
1091     WHERE  ppf.person_id = p_person_id
1092     AND    trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date;
1093 
1094    l_value     VARCHAR2(100);
1095    l_address_ret_status varchar2(10);
1096    l_address_found      boolean := true;
1097 
1098   BEGIN
1099 
1100     l_category                     := upper(p_category);
1101     l_source_id                    := p_source_id;
1102     l_address_id                   := p_address_id;
1103     l_contact_id                   := p_contact_id;
1104     l_managing_emp_id              := p_managing_emp_id;
1105     l_start_date_active            := trunc(p_start_date_active);
1106     l_end_date_active              := trunc(p_end_date_active);
1107     l_time_zone                    := p_time_zone;
1108     l_cost_per_hr                  := p_cost_per_hr;
1109     l_primary_language             := p_primary_language;
1110     l_secondary_language           := p_secondary_language;
1111     l_support_site_id              := p_support_site_id;
1112     l_ies_agent_login              := p_ies_agent_login;
1113     l_server_group_id              := p_server_group_id;
1114     l_assigned_to_group_id         := p_assigned_to_group_id;
1115     l_cost_center                  := p_cost_center;
1116     l_charge_to_cost_center        := p_charge_to_cost_center;
1117     l_comp_currency_code           := p_comp_currency_code;
1118     l_commissionable_flag          := p_commissionable_flag;
1119     l_hold_reason_code             := p_hold_reason_code;
1120     l_hold_payment                 := p_hold_payment;
1121     l_comp_service_team_id         := p_comp_service_team_id;
1122     l_user_id                      := p_user_id;
1123     l_transaction_number           := p_transaction_number;
1124     l_resource_name                := p_resource_name;
1125     l_source_name                  := p_source_name;
1126     l_source_number                := p_source_number;
1127     l_source_job_title             := p_source_job_title;
1128     l_source_email                 := p_source_email;
1129     l_source_phone                 := p_source_phone;
1130     l_source_org_id                := p_source_org_id;
1131     l_source_org_name              := p_source_org_name;
1132     l_source_address1              := p_source_address1;
1133     l_source_address2              := p_source_address2;
1134     l_source_address3              := p_source_address3;
1135     l_source_address4              := p_source_address4;
1136     l_source_city                  := p_source_city;
1137     l_source_postal_code           := p_source_postal_code;
1138     l_source_state                 := p_source_state;
1139     l_source_province              := p_source_province;
1140     l_source_county                := p_source_county;
1141     l_source_country               := p_source_country;
1142     l_source_mgr_id                := p_source_mgr_id;
1143     l_source_mgr_name              := p_source_mgr_name;
1144     l_source_business_grp_id       := p_source_business_grp_id;
1145     l_source_business_grp_name     := p_source_business_grp_name;
1146     l_source_first_name            := p_source_first_name;
1147     l_source_last_name             := p_source_last_name;
1148     l_source_middle_name           := p_source_middle_name;
1149     l_source_category              := p_source_category;
1150     l_source_status                := p_source_status;
1151     l_source_office                := p_source_office;
1152     l_source_location              := p_source_location;
1153     l_source_mailstop              := p_source_mailstop;
1154     l_source_mobile_phone          := p_source_mobile_phone;
1155     l_source_pager                 := p_source_pager;
1156     l_user_name                    := p_user_name;
1157 
1158     SAVEPOINT create_resource_pvt;
1159     x_return_status := fnd_api.g_ret_sts_success;
1160 --    DBMS_OUTPUT.put_line(' Started Create Resource Pvt ');
1161 
1162     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
1163       RAISE fnd_api.g_exc_unexpected_error;
1164     END IF;
1165 
1166     IF fnd_api.to_boolean(p_init_msg_list) THEN
1167       fnd_msg_pub.initialize;
1168     END IF;
1169 
1170     IF l_category = 'EMPLOYEE' THEN
1171       OPEN c_asg(l_source_Id);
1172       FETCH c_asg INTO l_source_job_id;
1173       CLOSE c_asg;
1174       OPEN c_party_id(l_source_Id);
1175       FETCH c_party_id INTO l_party_id;
1176       CLOSE c_party_id;
1177     END IF;
1178     /* Make the pre processing call to the user hooks */
1179 
1180     /* Pre Call to the Customer Type User Hook */
1181 
1182     IF jtf_resource_utl.ok_to_execute(
1183 	 'JTF_RS_RESOURCE_PVT',
1184 	 'CREATE_RESOURCE',
1185 	 'B',
1186 	 'C')
1187     THEN
1188     IF jtf_usr_hks.ok_to_execute(
1189 	 'JTF_RS_RESOURCE_PVT',
1190 	 'CREATE_RESOURCE',
1191 	 'B',
1192 	 'C')
1193     THEN
1194 
1195       jtf_rs_resource_cuhk.create_resource_pre(
1196         p_category => l_category,
1197         p_source_id => l_source_id,
1198         p_address_id => l_address_id,
1199         p_contact_id => l_contact_id,
1200         p_managing_emp_id => l_managing_emp_id,
1201         p_start_date_active => l_start_date_active,
1202         p_end_date_active => l_end_date_active,
1203         p_time_zone => l_time_zone,
1204         p_cost_per_hr => l_cost_per_hr,
1205         p_primary_language => l_primary_language,
1206         p_secondary_language => l_secondary_language,
1207         p_support_site_id => l_support_site_id,
1208         p_ies_agent_login => l_ies_agent_login,
1209         p_server_group_id => l_server_group_id,
1210         p_assigned_to_group_id => l_assigned_to_group_id,
1211         p_cost_center => l_cost_center,
1212         p_charge_to_cost_center => l_charge_to_cost_center,
1213         p_comp_currency_code => l_comp_currency_code,
1214         p_commissionable_flag => l_commissionable_flag,
1215         p_hold_reason_code => l_hold_reason_code,
1216         p_hold_payment => l_hold_payment,
1217         p_comp_service_team_id => l_comp_service_team_id,
1218         p_user_id => l_user_id,
1219         --p_location => l_location,
1220 	   x_return_status => x_return_status);
1221 
1222       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1223 
1224 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
1225 
1226 
1227 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
1228 	   fnd_msg_pub.add;
1229 
1230 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1231 		RAISE FND_API.G_EXC_ERROR;
1232 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1233 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1234 	   END IF;
1235 
1236 
1237       END IF;
1238 
1239     END IF;
1240     END IF;
1241 
1242 
1243     /* Pre Call to the Vertical Type User Hook */
1244 
1245     IF jtf_resource_utl.ok_to_execute(
1246 	 'JTF_RS_RESOURCE_PVT',
1247 	 'CREATE_RESOURCE',
1248 	 'B',
1249 	 'V')
1250     THEN
1251     IF jtf_usr_hks.ok_to_execute(
1252 	 'JTF_RS_RESOURCE_PVT',
1253 	 'CREATE_RESOURCE',
1254 	 'B',
1255 	 'V')
1256     THEN
1257 
1258       jtf_rs_resource_vuhk.create_resource_pre(
1259         p_category => l_category,
1260         p_source_id => l_source_id,
1261         p_address_id => l_address_id,
1262         p_contact_id => l_contact_id,
1263         p_managing_emp_id => l_managing_emp_id,
1264         p_start_date_active => l_start_date_active,
1265         p_end_date_active => l_end_date_active,
1266         p_time_zone => l_time_zone,
1267         p_cost_per_hr => l_cost_per_hr,
1268         p_primary_language => l_primary_language,
1269         p_secondary_language => l_secondary_language,
1270         p_support_site_id => l_support_site_id,
1271         p_ies_agent_login => l_ies_agent_login,
1272         p_server_group_id => l_server_group_id,
1273         p_assigned_to_group_id => l_assigned_to_group_id,
1274         p_cost_center => l_cost_center,
1275         p_charge_to_cost_center => l_charge_to_cost_center,
1276         p_comp_currency_code => l_comp_currency_code,
1277         p_commissionable_flag => l_commissionable_flag,
1278         p_hold_reason_code => l_hold_reason_code,
1279         p_hold_payment => l_hold_payment,
1280         p_comp_service_team_id => l_comp_service_team_id,
1281         p_user_id => l_user_id,
1282         --p_location => l_location,
1283 	   x_return_status => x_return_status);
1284 
1285       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1286 
1287 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
1288 
1289 
1290 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
1291 	   fnd_msg_pub.add;
1292 
1293 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1294 		RAISE FND_API.G_EXC_ERROR;
1295 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1296 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1297 	   END IF;
1298 
1299 
1300       END IF;
1301 
1302     END IF;
1303     END IF;
1304 
1305 
1306     /* Pre Call to the Internal Type User Hook */
1307 
1308     IF jtf_resource_utl.ok_to_execute(
1309 	 'JTF_RS_RESOURCE_PVT',
1310 	 'CREATE_RESOURCE',
1311 	 'B',
1312 	 'I')
1313     THEN
1314     IF jtf_usr_hks.ok_to_execute(
1315 	 'JTF_RS_RESOURCE_PVT',
1316 	 'CREATE_RESOURCE',
1317 	 'B',
1318 	 'I')
1319     THEN
1320 
1321       jtf_rs_resource_iuhk.create_resource_pre(
1322         p_category => l_category,
1323         p_source_id => l_source_id,
1324         p_address_id => l_address_id,
1325         p_contact_id => l_contact_id,
1326         p_managing_emp_id => l_managing_emp_id,
1327         p_start_date_active => l_start_date_active,
1328         p_end_date_active => l_end_date_active,
1329         p_time_zone => l_time_zone,
1330         p_cost_per_hr => l_cost_per_hr,
1331         p_primary_language => l_primary_language,
1332         p_secondary_language => l_secondary_language,
1333         p_support_site_id => l_support_site_id,
1334         p_ies_agent_login => l_ies_agent_login,
1335         p_server_group_id => l_server_group_id,
1336         p_assigned_to_group_id => l_assigned_to_group_id,
1337         p_cost_center => l_cost_center,
1338         p_charge_to_cost_center => l_charge_to_cost_center,
1339         p_comp_currency_code => l_comp_currency_code,
1340         p_commissionable_flag => l_commissionable_flag,
1341         p_hold_reason_code => l_hold_reason_code,
1342         p_hold_payment => l_hold_payment,
1343         p_comp_service_team_id => l_comp_service_team_id,
1344         p_user_id => l_user_id,
1345         --p_location => l_location,
1346 	   x_return_status => x_return_status);
1347 
1348       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1349 
1350 
1351 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
1352 	   fnd_msg_pub.add;
1353 
1354 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1355 		RAISE FND_API.G_EXC_ERROR;
1356 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1357 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1358 	   END IF;
1359 
1360 
1361       END IF;
1362 
1363     END IF;
1364     END IF;
1365 
1366 
1367 
1368     /* Validate the Input Dates */
1369 
1370     jtf_resource_utl.validate_input_dates(
1371       p_start_date_active => l_start_date_active,
1372       p_end_date_active => l_end_date_active,
1373       x_return_status => x_return_status
1374     );
1375 
1376     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1377 
1378       IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1379 	   RAISE FND_API.G_EXC_ERROR;
1380       ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1381 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1382       END IF;
1383 
1384     END IF;
1385 
1386    /* Validate for address id in case in PARTNER */
1387    if(p_category IN  ('PARTNER', 'PARTY'))
1388    then
1389      if (p_address_id is NOT NULL) then
1390          validate_party_address(p_source_id => p_source_id,
1391                             p_address_id => p_address_id,
1392                             p_action => 'I',
1393                             p_found  => l_address_found,
1394                             p_return_status => l_address_ret_status);
1395 
1396         if(l_address_ret_status <> fnd_api.g_ret_sts_success)
1397         then
1398 	   IF L_ADDRESS_RET_STATUS = FND_API.G_RET_STS_ERROR THEN
1399 		RAISE FND_API.G_EXC_ERROR;
1400 	   ELSIF L_ADDRESS_RET_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1401 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1402 	   END IF;
1403 
1404         end if;
1405 
1406        if not(l_address_found)
1407        then
1408           fnd_message.set_name('JTF', 'JTF_RS_NOT_PRIMARY_ADDR');
1409           fnd_msg_pub.add;
1410           RAISE fnd_api.g_exc_error;
1411 
1412        end if;
1413      end if;
1414    end if; -- end of partner address check
1415 
1416    /* This portion of the code was modified to accomodate the calls to Migration API */
1417    /* Check if the Global Variable Flag for Resource ID is Y or N */
1418 
1419 --     dbms_output.put_line ('Before checkin the Global flag in PVT API');
1420 
1421       IF (G_RS_ID_PVT_FLAG = 'Y') OR (G_RS_ID_PVT_FLAG = 'N' AND JTF_RS_RESOURCE_PUB.G_RESOURCE_ID IS NULL) THEN
1422 
1423          /* Get the next value of the Resource_id from the sequence. */
1424 
1425          LOOP
1426             SELECT jtf_rs_resource_extns_s.nextval
1427             INTO l_resource_id
1428             FROM dual;
1429             --dbms_output.put_line ('After Select - Resource ID ' || l_resource_id);
1430             OPEN c_dup_resource_id (l_resource_id);
1431             FETCH c_dup_resource_id INTO l_check_dup_id;
1432             EXIT WHEN c_dup_resource_id%NOTFOUND;
1433             CLOSE c_dup_resource_id;
1434          END LOOP;
1435          CLOSE c_dup_resource_id;
1436       ELSE
1437         l_resource_id 		:= JTF_RS_RESOURCE_PUB.G_RESOURCE_ID;
1438       END IF;
1439 
1440       /* Get the next value of the Resource_number from the sequence. */
1441 
1442           SELECT jtf_rs_resource_number_s.nextval
1443           INTO l_resource_number
1444           FROM dual;
1445 
1446     /* Make a call to the Resource Audit API */
1447 
1448     jtf_rs_resource_extns_aud_pvt.insert_resource
1449     (P_API_VERSION => 1,
1450      P_INIT_MSG_LIST => fnd_api.g_false,
1451      P_COMMIT => fnd_api.g_false,
1452      P_RESOURCE_ID => l_resource_id,
1453      P_RESOURCE_NUMBER => l_resource_number,
1454      P_CATEGORY => l_category,
1455      P_SOURCE_ID => l_source_id,
1456      P_ADDRESS_ID => l_address_id,
1457      P_CONTACT_ID => l_contact_id,
1458      P_MANAGING_EMP_ID => l_managing_emp_id,
1459      P_START_DATE_ACTIVE => l_start_date_active,
1460      P_END_DATE_ACTIVE => l_end_date_active,
1461      P_TIME_ZONE => l_time_zone,
1462      P_COST_PER_HR => l_cost_per_hr,
1463      P_PRIMARY_LANGUAGE => l_primary_language,
1464      P_SECONDARY_LANGUAGE => l_secondary_language,
1465      P_SUPPORT_SITE_ID => l_support_site_id,
1466      P_IES_AGENT_LOGIN => l_ies_agent_login,
1467      P_SERVER_GROUP_ID => l_server_group_id,
1468      P_ASSIGNED_TO_GROUP_ID => l_assigned_to_group_id,
1469      P_COST_CENTER => l_cost_center,
1470      P_CHARGE_TO_COST_CENTER => l_charge_to_cost_center,
1471      P_COMP_CURRENCY_CODE => l_comp_currency_code,
1472      P_COMMISSIONABLE_FLAG => l_commissionable_flag,
1473      P_HOLD_REASON_CODE => l_hold_reason_code,
1474      P_HOLD_PAYMENT => l_hold_payment,
1475      P_COMP_SERVICE_TEAM_ID => l_comp_service_team_id,
1476      P_USER_ID => l_user_id,
1477      P_TRANSACTION_NUMBER => l_transaction_number,
1478      --P_LOCATION => l_location,
1479      P_OBJECT_VERSION_NUMBER => 1,
1480      P_RESOURCE_NAME => l_RESOURCE_NAME,
1481      P_SOURCE_NAME => l_SOURCE_NAME,
1482      P_SOURCE_NUMBER => l_SOURCE_NUMBER,
1483      P_SOURCE_JOB_TITLE => l_SOURCE_JOB_TITLE ,
1484      P_SOURCE_EMAIL => l_SOURCE_EMAIL ,
1485      P_SOURCE_PHONE => l_SOURCE_PHONE ,
1486      P_SOURCE_ORG_ID => l_SOURCE_ORG_ID ,
1487      P_SOURCE_ORG_NAME => l_SOURCE_ORG_NAME ,
1488      P_SOURCE_ADDRESS1 => l_SOURCE_ADDRESS1 ,
1489      P_SOURCE_ADDRESS2 => l_SOURCE_ADDRESS2 ,
1490      P_SOURCE_ADDRESS3 => l_SOURCE_ADDRESS3 ,
1491      P_SOURCE_ADDRESS4 => l_SOURCE_ADDRESS4 ,
1492      P_SOURCE_CITY => l_SOURCE_CITY ,
1493      P_SOURCE_POSTAL_CODE => l_SOURCE_POSTAL_CODE ,
1494      P_SOURCE_STATE => l_SOURCE_STATE ,
1495      P_SOURCE_PROVINCE => l_SOURCE_PROVINCE ,
1496      P_SOURCE_COUNTY => l_SOURCE_COUNTY ,
1497      P_SOURCE_COUNTRY => l_SOURCE_COUNTRY ,
1498      P_SOURCE_MGR_ID => l_SOURCE_MGR_ID ,
1499      P_SOURCE_MGR_NAME => l_SOURCE_MGR_NAME ,
1500      P_SOURCE_BUSINESS_GRP_ID => l_SOURCE_BUSINESS_GRP_ID ,
1501      P_SOURCE_BUSINESS_GRP_NAME => l_SOURCE_BUSINESS_GRP_NAME ,
1502      P_SOURCE_FIRST_NAME => l_source_first_name ,
1503      P_SOURCE_LAST_NAME => l_source_last_name ,
1504      P_SOURCE_MIDDLE_NAME => l_source_middle_name ,
1505      P_SOURCE_CATEGORY => l_source_category ,
1506      P_SOURCE_STATUS => l_source_status ,
1507      P_SOURCE_OFFICE => l_source_office ,
1508      P_SOURCE_LOCATION => l_source_location ,
1509      P_SOURCE_MAILSTOP => l_source_mailstop ,
1510      P_SOURCE_JOB_ID => l_source_job_id ,
1511      P_PARTY_ID => l_party_id ,
1512      X_RETURN_STATUS => x_return_status,
1513      X_MSG_COUNT => x_msg_count,
1514      X_MSG_DATA => x_msg_data,
1515      P_SOURCE_MOBILE_PHONE => l_source_mobile_phone ,
1516      P_SOURCE_PAGER => l_source_pager
1517     );
1518 
1519     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1520 --    dbms_output.put_line('Failed status from call to audit procedure');
1521       IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1522 	   RAISE FND_API.G_EXC_ERROR;
1523       ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1524 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1525       END IF;
1526 
1527     END IF;
1528 
1529     /* Insert the row into the table by calling the table handler. */
1530 
1531     jtf_rs_resource_extns_pkg.insert_row(
1532       x_rowid 			=> l_rowid,
1533       x_resource_id 		=> l_resource_id,
1534       x_category 		=> l_category,
1535       x_resource_number 	=> l_resource_number,
1536       x_source_id 		=> l_source_id,
1537       x_address_id 		=> l_address_id,
1538       x_contact_id 		=> l_contact_id,
1539       x_managing_employee_id 	=> l_managing_emp_id,
1540       x_start_date_active 	=> l_start_date_active,
1541       x_end_date_active 	=> l_end_date_active,
1542       x_time_zone 		=> l_time_zone,
1543       x_cost_per_hr 		=> l_cost_per_hr,
1544       x_primary_language 	=> l_primary_language,
1545       x_secondary_language 	=> l_secondary_language,
1546       x_support_site_id 	=> l_support_site_id,
1547       x_ies_agent_login 	=> l_ies_agent_login,
1548       x_server_group_id 	=> l_server_group_id,
1549       x_assigned_to_group_id 	=> l_assigned_to_group_id,
1550       x_cost_center 		=> l_cost_center,
1551       x_charge_to_cost_center 	=> l_charge_to_cost_center,
1552       x_compensation_currency_code => l_comp_currency_code,
1553       x_commissionable_flag 	=> l_commissionable_flag,
1554       x_hold_reason_code 	=> l_hold_reason_code,
1555       x_hold_payment 		=> l_hold_payment,
1556       x_comp_service_team_id 	=> l_comp_service_team_id,
1557       x_user_id 		=> l_user_id,
1558       --x_location 		=> l_location,
1559       x_transaction_number 	=> l_transaction_number,
1560       x_attribute1 		=> p_attribute1,
1561       x_attribute2 		=> p_attribute2,
1562       x_attribute3 		=> p_attribute3,
1563       x_attribute4 		=> p_attribute4,
1564       x_attribute5 		=> p_attribute5,
1565       x_attribute6 		=> p_attribute6,
1566       x_attribute7 		=> p_attribute7,
1567       x_attribute8 		=> p_attribute8,
1568       x_attribute9 		=> p_attribute9,
1569       x_attribute10 		=> p_attribute10,
1570       x_attribute11 		=> p_attribute11,
1571       x_attribute12 		=> p_attribute12,
1572       x_attribute13 		=> p_attribute13,
1573       x_attribute14 		=> p_attribute14,
1574       x_attribute15 		=> p_attribute15,
1575       x_attribute_category 	=> p_attribute_category,
1576       x_creation_date 		=> SYSDATE,
1577       x_created_by 		=> jtf_resource_utl.created_by,
1578       x_last_update_date 	=> SYSDATE,
1579       x_last_updated_by 	=> jtf_resource_utl.updated_by,
1580       x_last_update_login 	=> jtf_resource_utl.login_id,
1581       x_resource_name		=> l_resource_name,
1582       x_source_name		=> l_source_name,
1583       x_source_number		=> l_source_number,
1584       x_source_job_title	=> l_source_job_title,
1585       x_source_email		=> l_source_email,
1586       x_source_phone		=> l_source_phone,
1587       x_source_org_id		=> l_source_org_id,
1588       x_source_org_name		=> l_source_org_name,
1589       x_source_address1		=> l_source_address1,
1590       x_source_address2         => l_source_address2,
1591       x_source_address3         => l_source_address3,
1592       x_source_address4         => l_source_address4,
1593       x_source_city         	=> l_source_city,
1594       x_source_postal_code      => l_source_postal_code,
1595       x_source_state         	=> l_source_state,
1596       x_source_province         => l_source_province,
1597       x_source_county         	=> l_source_county,
1598       x_source_country          => l_source_country,
1599       x_source_mgr_id           => l_source_mgr_id,
1600       x_source_mgr_name         => l_source_mgr_name,
1601       x_source_business_grp_id  => l_source_business_grp_id,
1602       x_source_business_grp_name=> l_source_business_grp_name,
1603       x_source_first_name       => l_source_first_name,
1604       x_source_last_name        => l_source_last_name,
1605       x_source_middle_name      => l_source_middle_name,
1606       x_source_category         => l_source_category,
1607       x_source_status           => l_source_status,
1608       x_source_office           => l_source_office,
1609       x_source_location         => l_source_location,
1610       x_source_mailstop         => l_source_mailstop,
1611       x_source_mobile_phone     => l_source_mobile_phone,
1612       x_source_pager            => l_source_pager,
1613       x_source_job_id           => l_source_job_id,
1614       x_party_id                => l_party_id,
1615       x_user_name               => l_user_name
1616     );
1617 
1618 --    dbms_output.put_line('After Insert Procedure');
1619     OPEN c_jtf_rs_resource_extns(l_rowid);
1620     FETCH c_jtf_rs_resource_extns INTO l_check_char;
1621     IF c_jtf_rs_resource_extns%NOTFOUND THEN
1622 --	 dbms_output.put_line('Error in Table Handler');
1623       IF c_jtf_rs_resource_extns%ISOPEN THEN
1624         CLOSE c_jtf_rs_resource_extns;
1625       END IF;
1626 	 x_return_status := fnd_api.g_ret_sts_unexp_error;
1627 	 fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
1628 	 fnd_msg_pub.add;
1629 	 RAISE fnd_api.g_exc_unexpected_error;
1630     ELSE
1631 --	 dbms_output.put_line('Resource Successfully Created');
1632 	 x_resource_id := l_resource_id;
1633 	 x_resource_number := l_resource_number;
1634     END IF;
1635 
1636     /* Close the cursors */
1637 
1638     IF c_jtf_rs_resource_extns%ISOPEN THEN
1639       CLOSE c_jtf_rs_resource_extns;
1640     END IF;
1641 
1642     /* Make the post processing call to the user hooks */
1643 
1644     /* Post Call to the Customer Type User Hook */
1645 
1646     IF jtf_usr_hks.ok_to_execute(
1647 	 'JTF_RS_RESOURCE_PVT',
1648 	 'CREATE_RESOURCE',
1649 	 'A',
1650 	 'C')
1651     THEN
1652 
1653       jtf_rs_resource_cuhk.create_resource_post(
1654         p_resource_id 		=> l_resource_id,
1655         p_category 		=> l_category,
1656         p_source_id 		=> l_source_id,
1657         p_address_id 		=> l_address_id,
1658         p_contact_id 		=> l_contact_id,
1659         p_managing_emp_id 	=> l_managing_emp_id,
1660         p_start_date_active 	=> l_start_date_active,
1661         p_end_date_active 	=> l_end_date_active,
1662         p_time_zone 		=> l_time_zone,
1663         p_cost_per_hr 		=> l_cost_per_hr,
1664         p_primary_language 	=> l_primary_language,
1665         p_secondary_language 	=> l_secondary_language,
1666         p_support_site_id 	=> l_support_site_id,
1667         p_ies_agent_login 	=> l_ies_agent_login,
1668         p_server_group_id 	=> l_server_group_id,
1669         p_assigned_to_group_id 	=> l_assigned_to_group_id,
1670         p_cost_center 		=> l_cost_center,
1671         p_charge_to_cost_center => l_charge_to_cost_center,
1672         p_comp_currency_code 	=> l_comp_currency_code,
1673         p_commissionable_flag 	=> l_commissionable_flag,
1674         p_hold_reason_code 	=> l_hold_reason_code,
1675         p_hold_payment 		=> l_hold_payment,
1676         p_comp_service_team_id 	=> l_comp_service_team_id,
1677         p_user_id 		=> l_user_id,
1678         --p_location 		=> l_location,
1679 	   x_return_status 	=> x_return_status);
1680 
1681       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1682 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
1683 
1684 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
1685 	   fnd_msg_pub.add;
1686 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1687 		RAISE FND_API.G_EXC_ERROR;
1688 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1689 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1690 	   END IF;
1691 
1692       END IF;
1693     END IF;
1694 
1695     /* Post Call to the Vertical Type User Hook */
1696 
1697     IF jtf_resource_utl.ok_to_execute(
1698 	 'JTF_RS_RESOURCE_PVT',
1699 	 'CREATE_RESOURCE',
1700 	 'A',
1701 	 'V')
1702     THEN
1703     IF jtf_usr_hks.ok_to_execute(
1704 	 'JTF_RS_RESOURCE_PVT',
1705 	 'CREATE_RESOURCE',
1706 	 'A',
1707 	 'V')
1708     THEN
1709 
1710       jtf_rs_resource_vuhk.create_resource_post(
1711         p_resource_id => l_resource_id,
1712         p_category => l_category,
1713         p_source_id => l_source_id,
1714         p_address_id => l_address_id,
1715         p_contact_id => l_contact_id,
1716         p_managing_emp_id => l_managing_emp_id,
1717         p_start_date_active => l_start_date_active,
1718         p_end_date_active => l_end_date_active,
1719         p_time_zone => l_time_zone,
1720         p_cost_per_hr => l_cost_per_hr,
1721         p_primary_language => l_primary_language,
1722         p_secondary_language => l_secondary_language,
1723         p_support_site_id => l_support_site_id,
1724         p_ies_agent_login => l_ies_agent_login,
1725         p_server_group_id => l_server_group_id,
1726         p_assigned_to_group_id => l_assigned_to_group_id,
1727         p_cost_center => l_cost_center,
1728         p_charge_to_cost_center => l_charge_to_cost_center,
1729         p_comp_currency_code => l_comp_currency_code,
1730         p_commissionable_flag => l_commissionable_flag,
1731         p_hold_reason_code => l_hold_reason_code,
1732         p_hold_payment => l_hold_payment,
1733         p_comp_service_team_id => l_comp_service_team_id,
1734         p_user_id => l_user_id,
1735         --p_location => l_location,
1736 	   x_return_status => x_return_status);
1737 
1738       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1739 
1740 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
1741 
1742 
1743 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
1744 	   fnd_msg_pub.add;
1745 
1746 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1747 		RAISE FND_API.G_EXC_ERROR;
1748 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1749 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1750 	   END IF;
1751 
1752 
1753       END IF;
1754 
1755     END IF;
1756     END IF;
1757 
1758 
1759     /* Post Call to the Internal Type User Hook */
1760 
1761     IF jtf_resource_utl.ok_to_execute(
1762 	 'JTF_RS_RESOURCE_PVT',
1763 	 'CREATE_RESOURCE',
1764 	 'A',
1765 	 'I')
1766     THEN
1767     IF jtf_usr_hks.ok_to_execute(
1768 	 'JTF_RS_RESOURCE_PVT',
1769 	 'CREATE_RESOURCE',
1770 	 'A',
1771 	 'I')
1772     THEN
1773 
1774       jtf_rs_resource_iuhk.create_resource_post(
1775         p_resource_id => l_resource_id,
1776         p_category => l_category,
1777         p_source_id => l_source_id,
1778         p_address_id => l_address_id,
1779         p_contact_id => l_contact_id,
1780         p_managing_emp_id => l_managing_emp_id,
1781         p_start_date_active => l_start_date_active,
1782         p_end_date_active => l_end_date_active,
1783         p_time_zone => l_time_zone,
1784         p_cost_per_hr => l_cost_per_hr,
1785         p_primary_language => l_primary_language,
1786         p_secondary_language => l_secondary_language,
1787         p_support_site_id => l_support_site_id,
1788         p_ies_agent_login => l_ies_agent_login,
1789         p_server_group_id => l_server_group_id,
1790         p_assigned_to_group_id => l_assigned_to_group_id,
1791         p_cost_center => l_cost_center,
1792         p_charge_to_cost_center => l_charge_to_cost_center,
1793         p_comp_currency_code => l_comp_currency_code,
1794         p_commissionable_flag => l_commissionable_flag,
1795         p_hold_reason_code => l_hold_reason_code,
1796         p_hold_payment => l_hold_payment,
1797         p_comp_service_team_id => l_comp_service_team_id,
1798         p_user_id => l_user_id,
1799        -- p_location => l_location,
1800 	   x_return_status => x_return_status);
1801 
1802       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1803 
1804 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
1805 	   fnd_msg_pub.add;
1806 
1807 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1808 		RAISE FND_API.G_EXC_ERROR;
1809 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1810 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1811 	   END IF;
1812 
1813 
1814       END IF;
1815 
1816     END IF;
1817     END IF;
1818 
1819 
1820     /* Standard call for Message Generation */
1821 
1822     IF jtf_resource_utl.ok_to_execute(
1823 	 'JTF_RS_RESOURCE_PVT',
1824 	 'CREATE_RESOURCE',
1825 	 'M',
1826 	 'M')
1827     THEN
1828     IF jtf_usr_hks.ok_to_execute(
1829 	 'JTF_RS_RESOURCE_PVT',
1830 	 'CREATE_RESOURCE',
1831 	 'M',
1832 	 'M')
1833     THEN
1834 
1835       IF (jtf_rs_resource_cuhk.ok_to_generate_msg(
1836 	       p_resource_id => l_resource_id,
1837 	       x_return_status => x_return_status) )
1838       THEN
1839 
1840         /* Get the bind data id for the Business Object Instance */
1841 
1842         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
1843 
1844 
1845         /* Set bind values for the bind variables in the Business Object SQL */
1846 
1847         jtf_usr_hks.load_bind_data(l_bind_data_id, 'resource_id', l_resource_id, 'S', 'N');
1848 
1849 
1850         /* Call the message generation API */
1851 
1852         jtf_usr_hks.generate_message(
1853 		p_prod_code => 'JTF',
1854 		p_bus_obj_code => 'RS_RES',
1855 		p_action_code => 'I',
1856 		p_bind_data_id => l_bind_data_id,
1857 		x_return_code => x_return_status);
1858 
1859 
1860         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1861 
1862 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
1863 
1864 
1865 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
1866 	     fnd_msg_pub.add;
1867 
1868 	     IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1869 		  RAISE FND_API.G_EXC_ERROR;
1870 	     ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1871 		  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1872 	     END IF;
1873 
1874 
1875         END IF;
1876 
1877       END IF;
1878 
1879     END IF;
1880     END IF;
1881 
1882 
1883     IF fnd_api.to_boolean(p_commit) THEN
1884 
1885 	 COMMIT WORK;
1886 
1887     END IF;
1888 
1889     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
1890 
1891 /* Calling publish API to raise create resource event. */
1892 /* added by baianand on 11/04/2002 */
1893 
1894     begin
1895        jtf_rs_wf_events_pub.create_resource
1896               (p_api_version               => 1.0
1897               ,p_init_msg_list             => fnd_api.g_false
1898               ,p_commit                    => fnd_api.g_false
1899               ,p_resource_id               => l_resource_id
1900               ,p_resource_name             => l_resource_name
1901               ,p_category                  => l_category
1902               ,p_user_id                   => l_user_id
1903               ,p_start_date_active         => l_start_date_active
1904               ,p_end_date_active           => l_end_date_active
1905               ,x_return_status             => l_return_status
1906               ,x_msg_count                 => l_msg_count
1907               ,x_msg_data                  => l_msg_data);
1908 
1909     EXCEPTION when others then
1910        null;
1911     end;
1912 
1913 /* End of publish API call */
1914 
1915 
1916 /* Calling work API for insert record into wf_local tables. */
1917 /* added by baianand on 08/12/2002 */
1918 
1919     begin
1920        jtf_rs_wf_integration_pub.create_resource
1921               (p_api_version               => 1.0
1922               ,p_init_msg_list             => fnd_api.g_false
1923               ,p_commit                    => fnd_api.g_false
1924               ,p_resource_id               => l_resource_id
1925               ,p_resource_name             => l_resource_name
1926               ,p_category                  => l_category
1927               ,p_user_id                   => l_user_id
1928               ,p_email_address             => l_source_email
1929               ,p_start_date_active         => l_start_date_active
1930               ,p_end_date_active           => l_end_date_active
1931               ,x_return_status             => l_return_status
1932               ,x_msg_count                 => l_msg_count
1933               ,x_msg_data                  => l_msg_data);
1934 
1935     EXCEPTION when others then
1936        null;
1937     end;
1938 
1939 /* End of work API call */
1940 
1941 
1942   EXCEPTION
1943 
1944 
1945     WHEN fnd_api.g_exc_error THEN
1946       ROLLBACK TO create_resource_pvt;
1947       x_return_status := fnd_api.g_ret_sts_error;
1948       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
1949                                  p_data => x_msg_data);
1950     WHEN fnd_api.g_exc_unexpected_error THEN
1951       ROLLBACK TO create_resource_pvt;
1952       x_return_status := fnd_api.g_ret_sts_unexp_error;
1953       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
1954                                  p_data => x_msg_data);
1955     WHEN OTHERS THEN
1956       ROLLBACK TO create_resource_pvt;
1957 -- The below lines removed as a part of fixing GSCC errors in R12 for jtfrspub.pls
1958 --      IF NOT(jtf_resource_utl.check_access(l_value))
1959 --      THEN
1960 --            IF(l_value = 'XMLGEN')
1961 --            THEN
1962 --		 fnd_message.set_name ('JTF', 'JTF_RS_XMLGEN_ERR');
1963 --		 FND_MSG_PUB.add;
1964 --            ELSIF(l_value = 'JTF_USR_HKS')
1965 --            THEN
1966 --		 fnd_message.set_name ('JTF', 'JTF_RS_JUHK_ERR');
1967 --		 FND_MSG_PUB.add;
1968 --            END IF;
1969 --      ELSE
1970 	fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
1971 	fnd_message.set_token('P_SQLCODE',SQLCODE);
1972 	fnd_message.set_token('P_SQLERRM',SQLERRM);
1973 	fnd_message.set_token('P_API_NAME', l_api_name);
1974 	FND_MSG_PUB.add;
1975 --      END IF;
1976       x_return_status := fnd_api.g_ret_sts_unexp_error;
1977       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
1978                                  p_data => x_msg_data);
1979 
1980   END create_resource;
1981 
1982 
1983   PROCEDURE  create_resource_migrate (
1984    P_API_VERSION             IN   NUMBER,
1985    P_INIT_MSG_LIST           IN   VARCHAR2,
1986    P_COMMIT                  IN   VARCHAR2,
1987    P_CATEGORY                IN   JTF_RS_RESOURCE_EXTNS.CATEGORY%TYPE,
1988    P_SOURCE_ID               IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ID%TYPE,
1989    P_ADDRESS_ID              IN   JTF_RS_RESOURCE_EXTNS.ADDRESS_ID%TYPE,
1990    P_CONTACT_ID              IN   JTF_RS_RESOURCE_EXTNS.CONTACT_ID%TYPE,
1991    P_MANAGING_EMP_ID         IN   JTF_RS_RESOURCE_EXTNS.MANAGING_EMPLOYEE_ID%TYPE,
1992    P_START_DATE_ACTIVE       IN   JTF_RS_RESOURCE_EXTNS.START_DATE_ACTIVE%TYPE,
1993    P_END_DATE_ACTIVE         IN   JTF_RS_RESOURCE_EXTNS.END_DATE_ACTIVE%TYPE,
1994    P_TIME_ZONE               IN   JTF_RS_RESOURCE_EXTNS.TIME_ZONE%TYPE,
1995    P_COST_PER_HR             IN   JTF_RS_RESOURCE_EXTNS.COST_PER_HR%TYPE,
1996    P_PRIMARY_LANGUAGE        IN   JTF_RS_RESOURCE_EXTNS.PRIMARY_LANGUAGE%TYPE,
1997    P_SECONDARY_LANGUAGE      IN   JTF_RS_RESOURCE_EXTNS.SECONDARY_LANGUAGE%TYPE,
1998    P_SUPPORT_SITE_ID         IN   JTF_RS_RESOURCE_EXTNS.SUPPORT_SITE_ID%TYPE,
1999    P_IES_AGENT_LOGIN         IN   JTF_RS_RESOURCE_EXTNS.IES_AGENT_LOGIN%TYPE,
2000    P_SERVER_GROUP_ID         IN   JTF_RS_RESOURCE_EXTNS.SERVER_GROUP_ID%TYPE,
2001    P_ASSIGNED_TO_GROUP_ID    IN   JTF_RS_RESOURCE_EXTNS.ASSIGNED_TO_GROUP_ID%TYPE,
2002    P_COST_CENTER             IN   JTF_RS_RESOURCE_EXTNS.COST_CENTER%TYPE,
2003    P_CHARGE_TO_COST_CENTER   IN   JTF_RS_RESOURCE_EXTNS.CHARGE_TO_COST_CENTER%TYPE,
2004    P_COMP_CURRENCY_CODE      IN   JTF_RS_RESOURCE_EXTNS.COMPENSATION_CURRENCY_CODE%TYPE,
2005    P_COMMISSIONABLE_FLAG     IN   JTF_RS_RESOURCE_EXTNS.COMMISSIONABLE_FLAG%TYPE,
2006    P_HOLD_REASON_CODE        IN   JTF_RS_RESOURCE_EXTNS.HOLD_REASON_CODE%TYPE,
2007    P_HOLD_PAYMENT            IN   JTF_RS_RESOURCE_EXTNS.HOLD_PAYMENT%TYPE,
2008    P_COMP_SERVICE_TEAM_ID    IN   JTF_RS_RESOURCE_EXTNS.COMP_SERVICE_TEAM_ID%TYPE,
2009    P_USER_ID                 IN   JTF_RS_RESOURCE_EXTNS.USER_ID%TYPE,
2010    P_TRANSACTION_NUMBER      IN   JTF_RS_RESOURCE_EXTNS.TRANSACTION_NUMBER%TYPE,
2011  --P_LOCATION                IN   MDSYS.SDO_GEOMETRY,
2012    P_ATTRIBUTE1              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE1%TYPE,
2013    P_ATTRIBUTE2              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE2%TYPE,
2014    P_ATTRIBUTE3              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE3%TYPE,
2015    P_ATTRIBUTE4              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE4%TYPE,
2016    P_ATTRIBUTE5              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE5%TYPE,
2017    P_ATTRIBUTE6              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE6%TYPE,
2018    P_ATTRIBUTE7              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE7%TYPE,
2019    P_ATTRIBUTE8              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE8%TYPE,
2020    P_ATTRIBUTE9              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE9%TYPE,
2021    P_ATTRIBUTE10             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE10%TYPE,
2022    P_ATTRIBUTE11             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE11%TYPE,
2023    P_ATTRIBUTE12             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE12%TYPE,
2024    P_ATTRIBUTE13             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE13%TYPE,
2025    P_ATTRIBUTE14             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE14%TYPE,
2026    P_ATTRIBUTE15             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE15%TYPE,
2027    P_ATTRIBUTE_CATEGORY      IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE_CATEGORY%TYPE,
2028    P_RESOURCE_ID             IN   JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
2029    X_RETURN_STATUS           OUT NOCOPY  VARCHAR2,
2030    X_MSG_COUNT               OUT NOCOPY  NUMBER,
2031    X_MSG_DATA                OUT NOCOPY  VARCHAR2,
2032    X_RESOURCE_ID             OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
2033    X_RESOURCE_NUMBER         OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.RESOURCE_NUMBER%TYPE
2034    )
2035    IS
2036 
2037    BEGIN
2038 
2039      G_RS_ID_PVT_FLAG	:= 'N';
2040 
2041      JTF_RS_RESOURCE_PVT.CREATE_RESOURCE (
2042        	P_API_VERSION             => P_API_VERSION,
2043    	P_INIT_MSG_LIST           => P_INIT_MSG_LIST,
2044    	P_COMMIT                  => P_COMMIT,
2045    	P_CATEGORY                => P_CATEGORY,
2046    	P_SOURCE_ID               => P_SOURCE_ID,
2047    	P_ADDRESS_ID              => P_ADDRESS_ID,
2048    	P_CONTACT_ID              => P_CONTACT_ID,
2049    	P_MANAGING_EMP_ID         => P_MANAGING_EMP_ID,
2050    	P_START_DATE_ACTIVE       => P_START_DATE_ACTIVE,
2051    	P_END_DATE_ACTIVE         => P_END_DATE_ACTIVE,
2052    	P_TIME_ZONE               => P_TIME_ZONE,
2053    	P_COST_PER_HR             => P_COST_PER_HR,
2054    	P_PRIMARY_LANGUAGE        => P_PRIMARY_LANGUAGE,
2055    	P_SECONDARY_LANGUAGE      => P_SECONDARY_LANGUAGE,
2056    	P_SUPPORT_SITE_ID         => P_SUPPORT_SITE_ID,
2057    	P_IES_AGENT_LOGIN         => P_IES_AGENT_LOGIN,
2058    	P_SERVER_GROUP_ID         => P_SERVER_GROUP_ID,
2059    	P_ASSIGNED_TO_GROUP_ID    => P_ASSIGNED_TO_GROUP_ID,
2060    	P_COST_CENTER             => P_COST_CENTER,
2061    	P_CHARGE_TO_COST_CENTER   => P_CHARGE_TO_COST_CENTER,
2062    	P_COMP_CURRENCY_CODE      => P_COMP_CURRENCY_CODE,
2063    	P_COMMISSIONABLE_FLAG     => P_COMMISSIONABLE_FLAG,
2064    	P_HOLD_REASON_CODE        => P_HOLD_REASON_CODE,
2065    	P_HOLD_PAYMENT            => P_HOLD_PAYMENT,
2066    	P_COMP_SERVICE_TEAM_ID    => P_COMP_SERVICE_TEAM_ID,
2067    	P_USER_ID                 => P_USER_ID,
2068    	P_TRANSACTION_NUMBER      => P_TRANSACTION_NUMBER,
2069       --P_LOCATION                => P_LOCATION,
2070    	P_ATTRIBUTE1              => P_ATTRIBUTE1,
2071    	P_ATTRIBUTE2              => P_ATTRIBUTE2,
2072    	P_ATTRIBUTE3              => P_ATTRIBUTE3,
2073    	P_ATTRIBUTE4              => P_ATTRIBUTE4,
2074    	P_ATTRIBUTE5              => P_ATTRIBUTE5,
2075    	P_ATTRIBUTE6              => P_ATTRIBUTE6,
2076    	P_ATTRIBUTE7              => P_ATTRIBUTE7,
2077    	P_ATTRIBUTE8              => P_ATTRIBUTE8,
2078    	P_ATTRIBUTE9              => P_ATTRIBUTE9,
2079    	P_ATTRIBUTE10             => P_ATTRIBUTE10,
2080    	P_ATTRIBUTE11             => P_ATTRIBUTE11,
2081    	P_ATTRIBUTE12             => P_ATTRIBUTE12,
2082    	P_ATTRIBUTE13             => P_ATTRIBUTE13,
2083    	P_ATTRIBUTE14             => P_ATTRIBUTE14,
2084    	P_ATTRIBUTE15             => P_ATTRIBUTE15,
2085    	P_ATTRIBUTE_CATEGORY      => P_ATTRIBUTE_CATEGORY,
2086 	P_SOURCE_NAME             => JTF_RESOURCE_UTL.G_SOURCE_NAME,
2087 	P_RESOURCE_NAME    => JTF_RESOURCE_UTL.G_SOURCE_NAME,
2088    	X_RETURN_STATUS           => X_RETURN_STATUS,
2089    	X_MSG_COUNT               => X_MSG_COUNT,
2090    	X_MSG_DATA                => X_MSG_DATA,
2091    	X_RESOURCE_ID             => X_RESOURCE_ID,
2092    	X_RESOURCE_NUMBER         => X_RESOURCE_NUMBER
2093      );
2094 
2095   END create_resource_migrate;
2096 
2097   /* Procedure to update the resource based on input values passed by calling routines. */
2098 
2099   PROCEDURE  update_resource
2100   (P_API_VERSION             IN   NUMBER,
2101    P_INIT_MSG_LIST           IN   VARCHAR2,
2102    P_COMMIT                  IN   VARCHAR2,
2103    P_RESOURCE_ID             IN   JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
2104    P_MANAGING_EMP_ID         IN   JTF_RS_RESOURCE_EXTNS.MANAGING_EMPLOYEE_ID%TYPE,
2105    P_START_DATE_ACTIVE       IN   JTF_RS_RESOURCE_EXTNS.START_DATE_ACTIVE%TYPE,
2106    P_END_DATE_ACTIVE         IN   JTF_RS_RESOURCE_EXTNS.END_DATE_ACTIVE%TYPE,
2107    P_TIME_ZONE               IN   JTF_RS_RESOURCE_EXTNS.TIME_ZONE%TYPE,
2108    P_COST_PER_HR             IN   JTF_RS_RESOURCE_EXTNS.COST_PER_HR%TYPE,
2109    P_PRIMARY_LANGUAGE        IN   JTF_RS_RESOURCE_EXTNS.PRIMARY_LANGUAGE%TYPE,
2110    P_SECONDARY_LANGUAGE      IN   JTF_RS_RESOURCE_EXTNS.SECONDARY_LANGUAGE%TYPE,
2111    P_SUPPORT_SITE_ID         IN   JTF_RS_RESOURCE_EXTNS.SUPPORT_SITE_ID%TYPE,
2112    P_IES_AGENT_LOGIN         IN   JTF_RS_RESOURCE_EXTNS.IES_AGENT_LOGIN%TYPE,
2113    P_SERVER_GROUP_ID         IN   JTF_RS_RESOURCE_EXTNS.SERVER_GROUP_ID%TYPE,
2114    P_ASSIGNED_TO_GROUP_ID    IN   JTF_RS_RESOURCE_EXTNS.ASSIGNED_TO_GROUP_ID%TYPE,
2115    P_COST_CENTER             IN   JTF_RS_RESOURCE_EXTNS.COST_CENTER%TYPE,
2116    P_CHARGE_TO_COST_CENTER   IN   JTF_RS_RESOURCE_EXTNS.CHARGE_TO_COST_CENTER%TYPE,
2117    P_COMP_CURRENCY_CODE      IN   JTF_RS_RESOURCE_EXTNS.COMPENSATION_CURRENCY_CODE%TYPE,
2118    P_COMMISSIONABLE_FLAG     IN   JTF_RS_RESOURCE_EXTNS.COMMISSIONABLE_FLAG%TYPE,
2119    P_HOLD_REASON_CODE        IN   JTF_RS_RESOURCE_EXTNS.HOLD_REASON_CODE%TYPE,
2120    P_HOLD_PAYMENT            IN   JTF_RS_RESOURCE_EXTNS.HOLD_PAYMENT%TYPE,
2121    P_COMP_SERVICE_TEAM_ID    IN   JTF_RS_RESOURCE_EXTNS.COMP_SERVICE_TEAM_ID%TYPE,
2122    P_USER_ID                 IN   JTF_RS_RESOURCE_EXTNS.USER_ID%TYPE,
2123    --P_LOCATION                IN   MDSYS.SDO_GEOMETRY,
2124    P_ATTRIBUTE1              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE1%TYPE,
2125    P_ATTRIBUTE2              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE2%TYPE,
2126    P_ATTRIBUTE3              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE3%TYPE,
2127    P_ATTRIBUTE4              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE4%TYPE,
2128    P_ATTRIBUTE5              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE5%TYPE,
2129    P_ATTRIBUTE6              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE6%TYPE,
2130    P_ATTRIBUTE7              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE7%TYPE,
2131    P_ATTRIBUTE8              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE8%TYPE,
2132    P_ATTRIBUTE9              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE9%TYPE,
2133    P_ATTRIBUTE10             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE10%TYPE,
2134    P_ATTRIBUTE11             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE11%TYPE,
2135    P_ATTRIBUTE12             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE12%TYPE,
2136    P_ATTRIBUTE13             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE13%TYPE,
2137    P_ATTRIBUTE14             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE14%TYPE,
2138    P_ATTRIBUTE15             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE15%TYPE,
2139    P_ATTRIBUTE_CATEGORY      IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE_CATEGORY%TYPE,
2140    P_OBJECT_VERSION_NUM   IN OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.OBJECT_VERSION_NUMBER%TYPE,
2141    X_RETURN_STATUS           OUT NOCOPY  VARCHAR2,
2142    X_MSG_COUNT               OUT NOCOPY  NUMBER,
2143    X_MSG_DATA                OUT NOCOPY  VARCHAR2
2144   ) IS
2145 
2146     l_api_version         CONSTANT NUMBER := 1.0;
2147     l_api_name            CONSTANT VARCHAR2(30) := 'UPDATE_RESOURCE';
2148   /* Moved the initial assignment of below variables to inside begin */
2149     l_resource_id                  jtf_rs_resource_extns.resource_id%TYPE;
2150     l_managing_emp_id              jtf_rs_resource_extns.managing_employee_id%TYPE;
2151     -- added trunc for the dates 6feb2002
2152     l_start_date_active            jtf_rs_resource_extns.start_date_active%TYPE;
2153     l_end_date_active              jtf_rs_resource_extns.end_date_active%TYPE;
2154     l_time_zone                    jtf_rs_resource_extns.time_zone%TYPE;
2155     l_cost_per_hr                  jtf_rs_resource_extns.cost_per_hr%TYPE;
2156     l_primary_language             jtf_rs_resource_extns.primary_language%TYPE;
2157     l_secondary_language           jtf_rs_resource_extns.secondary_language%TYPE;
2158     l_support_site_id              jtf_rs_resource_extns.support_site_id%TYPE;
2159     l_ies_agent_login              jtf_rs_resource_extns.ies_agent_login%TYPE;
2160     l_server_group_id              jtf_rs_resource_extns.server_group_id%TYPE;
2161     l_assigned_to_group_id         jtf_rs_resource_extns.assigned_to_group_id%TYPE;
2162     l_cost_center                  jtf_rs_resource_extns.cost_center%TYPE;
2163     l_charge_to_cost_center        jtf_rs_resource_extns.charge_to_cost_center%TYPE;
2164     l_comp_currency_code           jtf_rs_resource_extns.compensation_currency_code%TYPE;
2165     l_commissionable_flag          jtf_rs_resource_extns.commissionable_flag%TYPE;
2166     l_hold_reason_code             jtf_rs_resource_extns.hold_reason_code%TYPE;
2167     l_hold_payment                 jtf_rs_resource_extns.hold_payment%TYPE;
2168     l_comp_service_team_id         jtf_rs_resource_extns.comp_service_team_id%TYPE;
2169     l_user_id                      jtf_rs_resource_extns.user_id%TYPE;
2170     --l_location                     mdsys.sdo_geometry := p_location;
2171     l_object_version_num           jtf_rs_resource_extns.object_version_number%TYPE;
2172 
2173 -- added for NOCOPY to handle in JTF_RESOURCE_UTL
2174     l_managing_emp_id_out          jtf_rs_resource_extns.managing_employee_id%TYPE ;
2175     l_server_group_id_out              jtf_rs_resource_extns.server_group_id%TYPE ;
2176     l_comp_service_team_id_out         jtf_rs_resource_extns.comp_service_team_id%TYPE;
2177 
2178     l_max_end_date                 DATE;
2179     l_min_start_date               DATE;
2180     l_bind_data_id                 NUMBER;
2181     l_check_flag                   VARCHAR2(1);
2182 
2183 
2184     CURSOR c_resource_update(
2185 	 l_resource_id    IN  NUMBER )
2186     IS
2187 	 SELECT
2188 	   DECODE(p_managing_emp_id, fnd_api.g_miss_num, managing_employee_id, p_managing_emp_id) managing_emp_id,
2189            -- added trunc on the dates 6feb 2002
2190 	   DECODE(p_start_date_active, fnd_api.g_miss_date, start_date_active, trunc(p_start_date_active)) start_date_active,
2191 	   DECODE(p_end_date_active, fnd_api.g_miss_date, end_date_active, trunc(p_end_date_active)) end_date_active,
2192 	   DECODE(p_time_zone, fnd_api.g_miss_num, time_zone, p_time_zone) time_zone,
2193 	   DECODE(p_cost_per_hr, fnd_api.g_miss_num, cost_per_hr, p_cost_per_hr) cost_per_hr,
2194 	   DECODE(p_primary_language, fnd_api.g_miss_char, primary_language, p_primary_language) primary_language,
2195 	   DECODE(p_secondary_language, fnd_api.g_miss_char, secondary_language, p_secondary_language) secondary_language,
2196 	   DECODE(p_support_site_id, fnd_api.g_miss_num, support_site_id, p_support_site_id) support_site_id,
2197         DECODE(p_ies_agent_login, fnd_api.g_miss_char, ies_agent_login, p_ies_agent_login) ies_agent_login,
2198         DECODE(p_server_group_id, fnd_api.g_miss_num, server_group_id, p_server_group_id) server_group_id,
2199         DECODE(p_assigned_to_group_id, fnd_api.g_miss_num, assigned_to_group_id, p_assigned_to_group_id) assigned_to_group_id,
2200         DECODE(p_cost_center, fnd_api.g_miss_char, cost_center, p_cost_center) cost_center,
2201         DECODE(p_charge_to_cost_center, fnd_api.g_miss_char, charge_to_cost_center, p_charge_to_cost_center) charge_to_cost_center,
2202         DECODE(p_comp_currency_code, fnd_api.g_miss_char, compensation_currency_code, p_comp_currency_code) comp_currency_code,
2203         DECODE(p_commissionable_flag, fnd_api.g_miss_char, commissionable_flag, p_commissionable_flag) commissionable_flag,
2204         DECODE(p_hold_reason_code, fnd_api.g_miss_char, hold_reason_code, p_hold_reason_code) hold_reason_code,
2205         DECODE(p_hold_payment, fnd_api.g_miss_char, hold_payment, p_hold_payment) hold_payment,
2206         DECODE(p_comp_service_team_id, fnd_api.g_miss_num, comp_service_team_id, p_comp_service_team_id) comp_service_team_id,
2207         DECODE(p_user_id, fnd_api.g_miss_num, user_id, p_user_id) user_id,
2208         --DECODE(p_location, jtf_rs_resource_pub.g_miss_location, location, p_location) location,
2209 	   DECODE(p_attribute1, fnd_api.g_miss_char, attribute1, p_attribute1) attribute1,
2210 	   DECODE(p_attribute2, fnd_api.g_miss_char, attribute2, p_attribute2) attribute2,
2211 	   DECODE(p_attribute3, fnd_api.g_miss_char, attribute3, p_attribute3) attribute3,
2212 	   DECODE(p_attribute4, fnd_api.g_miss_char, attribute4, p_attribute4) attribute4,
2213 	   DECODE(p_attribute5, fnd_api.g_miss_char, attribute5, p_attribute5) attribute5,
2214 	   DECODE(p_attribute6, fnd_api.g_miss_char, attribute6, p_attribute6) attribute6,
2215 	   DECODE(p_attribute7, fnd_api.g_miss_char, attribute7, p_attribute7) attribute7,
2216 	   DECODE(p_attribute8, fnd_api.g_miss_char, attribute8, p_attribute8) attribute8,
2217 	   DECODE(p_attribute9, fnd_api.g_miss_char, attribute9, p_attribute9) attribute9,
2218 	   DECODE(p_attribute10, fnd_api.g_miss_char, attribute10, p_attribute10) attribute10,
2219 	   DECODE(p_attribute11, fnd_api.g_miss_char, attribute11, p_attribute11) attribute11,
2220 	   DECODE(p_attribute12, fnd_api.g_miss_char, attribute12, p_attribute12) attribute12,
2221 	   DECODE(p_attribute13, fnd_api.g_miss_char, attribute13, p_attribute13) attribute13,
2222 	   DECODE(p_attribute14, fnd_api.g_miss_char, attribute14, p_attribute14) attribute14,
2223 	   DECODE(p_attribute15, fnd_api.g_miss_char, attribute15, p_attribute15) attribute15,
2224 	   DECODE(p_attribute_category, fnd_api.g_miss_char, attribute_category, p_attribute_category) attribute_category,
2225 	   category,
2226 	   resource_number,
2227         source_id,
2228         address_id,
2229         contact_id,
2230 	   transaction_number
2231       FROM jtf_rs_resource_extns_vl
2232 	 WHERE resource_id = l_resource_id;
2233 
2234     resource_rec   c_resource_update%ROWTYPE;
2235 
2236 
2237     -- Modtfying the below query for bug # 4956644
2238     -- New query logic is given in bug # 4052112
2239     -- OIC expanded the definition of compensation analyst to include any active user in the
2240     -- system regardless of their assignment to a CN responsibility.
2241     CURSOR c_assigned_to_group_id(
2242 	 l_assigned_to_group_id    IN  NUMBER)
2243     IS
2244 	 SELECT u.user_id
2245       FROM fnd_user u,
2246 	   jtf_rs_resource_extns r
2247 	 WHERE u.user_id = r.user_id
2248 	   AND u.user_id = l_assigned_to_group_id;
2249 
2250 
2251     CURSOR c_get_resource_info(
2252 	 l_resource_id    IN  NUMBER )
2253     IS
2254 	 SELECT start_date_active
2255       FROM jtf_rs_resource_extns
2256 	 WHERE resource_id = l_resource_id;
2257 
2258 
2259     CURSOR c_related_role_dates_first(
2260 	 l_resource_id    IN  NUMBER )
2261     IS
2262 	 SELECT min(start_date_active),
2263 	   max(end_date_active)
2264       FROM jtf_rs_role_relations
2265 	 WHERE role_resource_type = 'RS_INDIVIDUAL'
2266 	   AND role_resource_id = l_resource_id
2267 	   AND nvl(delete_flag, 'N') <> 'Y'
2268 	   AND end_date_active is not null;
2269 
2270 
2271     CURSOR c_related_role_dates_sec(
2272 	 l_resource_id    IN  NUMBER )
2273     IS
2274 	 SELECT min(start_date_active)
2275       FROM jtf_rs_role_relations
2276 	 WHERE role_resource_type = 'RS_INDIVIDUAL'
2277 	   AND role_resource_id = l_resource_id
2278 	   AND nvl(delete_flag, 'N') <> 'Y'
2279 	   AND end_date_active is null;
2280 
2281 
2282     CURSOR c_grp_mbr_role_dates_first(
2283 	 l_resource_id    IN  NUMBER )
2284     IS
2285 	 SELECT min(jrrr.start_date_active),
2286 	   max(jrrr.end_date_active)
2287       FROM jtf_rs_group_members jrgm,
2288 	   jtf_rs_role_relations jrrr
2289       WHERE jrgm.group_member_id = jrrr.role_resource_id
2290 	   AND jrrr.role_resource_type = 'RS_GROUP_MEMBER'
2291 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
2292 	   AND nvl(jrgm.delete_flag, 'N') <> 'Y'
2293 	   AND jrgm.resource_id = l_resource_id
2294 	   AND jrrr.end_date_active is not null;
2295 
2296 
2297     CURSOR c_grp_mbr_role_dates_sec(
2298 	 l_resource_id    IN  NUMBER )
2299     IS
2300 	 SELECT min(jrrr.start_date_active)
2301       FROM jtf_rs_group_members jrgm,
2302 	   jtf_rs_role_relations jrrr
2303       WHERE jrgm.group_member_id = jrrr.role_resource_id
2304 	   AND jrrr.role_resource_type = 'RS_GROUP_MEMBER'
2305 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
2306 	   AND nvl(jrgm.delete_flag, 'N') <> 'Y'
2307 	   AND jrgm.resource_id = l_resource_id
2308 	   AND jrrr.end_date_active is null;
2309 
2310 
2311     CURSOR c_team_mbr_role_dates_first(
2312 	 l_resource_id    IN  NUMBER )
2313     IS
2314 	 SELECT min(jrrr.start_date_active),
2315 	   max(jrrr.end_date_active)
2316       FROM jtf_rs_team_members jrtm,
2317 	   jtf_rs_role_relations jrrr
2318       WHERE jrtm.team_member_id = jrrr.role_resource_id
2319 	   AND jrrr.role_resource_type = 'RS_TEAM_MEMBER'
2320 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
2321 	   AND nvl(jrtm.delete_flag, 'N') <> 'Y'
2322 	   AND jrtm.team_resource_id = l_resource_id
2323 	   AND jrtm.resource_type = 'INDIVIDUAL'
2324 	   AND jrrr.end_date_active is not null;
2325 
2326 
2327     CURSOR c_team_mbr_role_dates_sec(
2328 	 l_resource_id    IN  NUMBER )
2329     IS
2330 	 SELECT min(jrrr.start_date_active)
2331       FROM jtf_rs_team_members jrtm,
2332 	   jtf_rs_role_relations jrrr
2333       WHERE jrtm.team_member_id = jrrr.role_resource_id
2334 	   AND jrrr.role_resource_type = 'RS_TEAM_MEMBER'
2335 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
2336 	   AND nvl(jrtm.delete_flag, 'N') <> 'Y'
2337 	   AND jrtm.team_resource_id = l_resource_id
2338 	   AND jrtm.resource_type = 'INDIVIDUAL'
2339 	   AND jrrr.end_date_active is null;
2340 
2341 
2342     CURSOR c_salesrep_dates_first(
2343 	 l_resource_id    IN  NUMBER )
2344     IS
2345 	 SELECT min(start_date_active),
2346 	   max(end_date_active)
2347       FROM jtf_rs_salesreps
2348 	 WHERE resource_id = l_resource_id
2349 	   AND end_date_active is not null;
2350 
2351 
2352     CURSOR c_salesrep_dates_sec(
2353 	 l_resource_id    IN  NUMBER )
2354     IS
2355 	 SELECT min(start_date_active)
2356       FROM jtf_rs_salesreps
2357 	 WHERE resource_id = l_resource_id
2358 	   AND end_date_active is null;
2359 
2360     CURSOR c_validate_user_id(
2361          l_resource_id    IN  NUMBER,
2362          l_user_id        IN  NUMBER)
2363     IS
2364          SELECT 'Y'
2365       FROM jtf_rs_resource_extns
2366          WHERE user_id = l_user_id
2367          AND   resource_id <> l_resource_id;
2368 
2369    l_value     VARCHAR2(100);
2370 
2371   l_address_ret_status varchar2(10);
2372   l_address_found      boolean := true;
2373   BEGIN
2374 
2375     l_resource_id                  := p_resource_id;
2376     l_managing_emp_id              := p_managing_emp_id;
2377     l_start_date_active            := trunc(p_start_date_active);
2378     l_end_date_active              := trunc(p_end_date_active);
2379     l_time_zone                    := p_time_zone;
2380     l_cost_per_hr                  := p_cost_per_hr;
2381     l_primary_language             := p_primary_language;
2382     l_secondary_language           := p_secondary_language;
2383     l_support_site_id              := p_support_site_id;
2384     l_ies_agent_login              := p_ies_agent_login;
2385     l_server_group_id              := p_server_group_id;
2386     l_assigned_to_group_id         := p_assigned_to_group_id;
2387     l_cost_center                  := p_cost_center;
2388     l_charge_to_cost_center        := p_charge_to_cost_center;
2389     l_comp_currency_code           := p_comp_currency_code;
2390     l_commissionable_flag          := p_commissionable_flag;
2391     l_hold_reason_code             := p_hold_reason_code;
2392     l_hold_payment                 := p_hold_payment;
2393     l_comp_service_team_id         := p_comp_service_team_id;
2394     l_user_id                      := p_user_id;
2395     l_object_version_num           := p_object_version_num;
2396 
2397     SAVEPOINT update_resource_pvt;
2398 
2399     x_return_status := fnd_api.g_ret_sts_success;
2400 
2401 --    DBMS_OUTPUT.put_line('Started Update Resource Pvt ');
2402 
2403 
2404     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
2405 
2406       RAISE fnd_api.g_exc_unexpected_error;
2407 
2408     END IF;
2409 
2410 
2411     IF fnd_api.to_boolean(p_init_msg_list) THEN
2412 
2413       fnd_msg_pub.initialize;
2414 
2415     END IF;
2416 
2417     /* Make the pre processing call to the user hooks */
2418 
2419     /* Pre Call to the Customer Type User Hook */
2420 
2421     IF jtf_resource_utl.ok_to_execute(
2422 	 'JTF_RS_RESOURCE_PVT',
2423 	 'UPDATE_RESOURCE',
2424 	 'B',
2425 	 'C')
2426     THEN
2427     IF jtf_usr_hks.ok_to_execute(
2428 	 'JTF_RS_RESOURCE_PVT',
2429 	 'UPDATE_RESOURCE',
2430 	 'B',
2431 	 'C')
2432     THEN
2433 
2434       jtf_rs_resource_cuhk.update_resource_pre(
2435 	   p_resource_id => l_resource_id,
2436         p_managing_emp_id => l_managing_emp_id,
2437         p_start_date_active => l_start_date_active,
2438         p_end_date_active => l_end_date_active,
2439         p_time_zone => l_time_zone,
2440         p_cost_per_hr => l_cost_per_hr,
2441         p_primary_language => l_primary_language,
2442         p_secondary_language => l_secondary_language,
2443         p_support_site_id => l_support_site_id,
2444         p_ies_agent_login => l_ies_agent_login,
2445         p_server_group_id => l_server_group_id,
2446         p_assigned_to_group_id => l_assigned_to_group_id,
2447         p_cost_center => l_cost_center,
2448         p_charge_to_cost_center => l_charge_to_cost_center,
2449         p_comp_currency_code => l_comp_currency_code,
2450         p_commissionable_flag => l_commissionable_flag,
2451         p_hold_reason_code => l_hold_reason_code,
2452         p_hold_payment => l_hold_payment,
2453         p_comp_service_team_id => l_comp_service_team_id,
2454         p_user_id => l_user_id,
2455        -- p_location => l_location,
2456 	   x_return_status => x_return_status);
2457 
2458       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
2459 
2460 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
2461 
2462 
2463 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
2464 	   fnd_msg_pub.add;
2465 
2466 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
2467 		RAISE FND_API.G_EXC_ERROR;
2468 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
2469 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2470 	   END IF;
2471 
2472 
2473       END IF;
2474 
2475     END IF;
2476     END IF;
2477 
2478 
2479     /* Pre Call to the Vertical Type User Hook */
2480 
2481     IF jtf_resource_utl.ok_to_execute(
2482 	 'JTF_RS_RESOURCE_PVT',
2483 	 'UPDATE_RESOURCE',
2484 	 'B',
2485 	 'V')
2486     THEN
2487     IF jtf_usr_hks.ok_to_execute(
2488 	 'JTF_RS_RESOURCE_PVT',
2489 	 'UPDATE_RESOURCE',
2490 	 'B',
2491 	 'V')
2492     THEN
2493 
2494       jtf_rs_resource_vuhk.update_resource_pre(
2495 	   p_resource_id => l_resource_id,
2496         p_managing_emp_id => l_managing_emp_id,
2497         p_start_date_active => l_start_date_active,
2498         p_end_date_active => l_end_date_active,
2499         p_time_zone => l_time_zone,
2500         p_cost_per_hr => l_cost_per_hr,
2501         p_primary_language => l_primary_language,
2502         p_secondary_language => l_secondary_language,
2503         p_support_site_id => l_support_site_id,
2504         p_ies_agent_login => l_ies_agent_login,
2505         p_server_group_id => l_server_group_id,
2506         p_assigned_to_group_id => l_assigned_to_group_id,
2507         p_cost_center => l_cost_center,
2508         p_charge_to_cost_center => l_charge_to_cost_center,
2509         p_comp_currency_code => l_comp_currency_code,
2510         p_commissionable_flag => l_commissionable_flag,
2511         p_hold_reason_code => l_hold_reason_code,
2512         p_hold_payment => l_hold_payment,
2513         p_comp_service_team_id => l_comp_service_team_id,
2514         p_user_id => l_user_id,
2515        -- p_location => l_location,
2516 	   x_return_status => x_return_status);
2517 
2518       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
2519 
2520 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
2521 
2522 
2523 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
2524 	   fnd_msg_pub.add;
2525 
2526 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
2527 		RAISE FND_API.G_EXC_ERROR;
2528 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
2529 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2530 	   END IF;
2531 
2532 
2533       END IF;
2534 
2535     END IF;
2536     END IF;
2537 
2538 
2539     /* Pre Call to the Internal Type User Hook */
2540 
2541     IF jtf_resource_utl.ok_to_execute(
2542 	 'JTF_RS_RESOURCE_PVT',
2543 	 'UPDATE_RESOURCE',
2544 	 'B',
2545 	 'I')
2546     THEN
2547     IF jtf_usr_hks.ok_to_execute(
2548 	 'JTF_RS_RESOURCE_PVT',
2549 	 'UPDATE_RESOURCE',
2550 	 'B',
2551 	 'I')
2552     THEN
2553 
2554       jtf_rs_resource_iuhk.update_resource_pre(
2555 	   p_resource_id => l_resource_id,
2556         p_managing_emp_id => l_managing_emp_id,
2557         p_start_date_active => l_start_date_active,
2558         p_end_date_active => l_end_date_active,
2559         p_time_zone => l_time_zone,
2560         p_cost_per_hr => l_cost_per_hr,
2561         p_primary_language => l_primary_language,
2562         p_secondary_language => l_secondary_language,
2563         p_support_site_id => l_support_site_id,
2564         p_ies_agent_login => l_ies_agent_login,
2565         p_server_group_id => l_server_group_id,
2566         p_assigned_to_group_id => l_assigned_to_group_id,
2567         p_cost_center => l_cost_center,
2568         p_charge_to_cost_center => l_charge_to_cost_center,
2569         p_comp_currency_code => l_comp_currency_code,
2570         p_commissionable_flag => l_commissionable_flag,
2571         p_hold_reason_code => l_hold_reason_code,
2572         p_hold_payment => l_hold_payment,
2573         p_comp_service_team_id => l_comp_service_team_id,
2574         p_user_id => l_user_id,
2575         --p_location => l_location,
2576 	   x_return_status => x_return_status);
2577 
2578       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
2579 
2580 
2581 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
2582 	   fnd_msg_pub.add;
2583 
2584 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
2585 		RAISE FND_API.G_EXC_ERROR;
2586 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
2587 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2588 	   END IF;
2589 
2590       END IF;
2591 
2592     END IF;
2593     END IF;
2594 
2595 
2596     OPEN c_resource_update(l_resource_id);
2597 
2598     FETCH c_resource_update INTO resource_rec;
2599 
2600 
2601     IF c_resource_update%NOTFOUND THEN
2602 
2603       IF c_resource_update%ISOPEN THEN
2604 
2605         CLOSE c_resource_update;
2606 
2607       END IF;
2608 
2609       fnd_message.set_name('JTF', 'JTF_RS_INVALID_RESOURCE');
2610 	 fnd_message.set_token('P_RESOURCE_ID', l_resource_id);
2611       fnd_msg_pub.add;
2612 
2613       RAISE fnd_api.g_exc_error;
2614 
2615 
2616     END IF;
2617 
2618     /* Validate the Managing Employee Id if specified */
2619 
2620     IF l_managing_emp_id <> fnd_api.g_miss_num THEN
2621 
2622       jtf_resource_utl.validate_employee_resource(
2623         p_emp_resource_id => l_managing_emp_id,
2624         p_emp_resource_number => null,
2625         x_return_status => x_return_status,
2626         x_emp_resource_id => l_managing_emp_id_out
2627       );
2628 -- added for NOCOPY
2629       l_managing_emp_id  := l_managing_emp_id_out;
2630 
2631       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
2632 
2633 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
2634 		RAISE FND_API.G_EXC_ERROR;
2635 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
2636 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2637 	   END IF;
2638 
2639       END IF;
2640 
2641     END IF;
2642 
2643 
2644     /* Validate the Input Dates */
2645 
2646     IF l_start_date_active <> fnd_api.g_miss_date OR
2647 	  l_end_date_active <> fnd_api.g_miss_date THEN
2648 
2649     -- Code changes to fix bug 4171623. (G_MISS_DATE DOESN'T WORK PROPERLY ON JTF_RS_RESOURCE_PUB).
2650 
2651     -- Changing the values being passed to "validate_input_dates" procedure,
2652     -- from l_end_date_active to resource_rec.end_date_active (same for start date)
2653     -- so that it validates the correct dates which its supposed to validate.
2654 
2655       jtf_resource_utl.validate_input_dates(
2656         p_start_date_active => resource_rec.start_date_active,
2657         p_end_date_active => resource_rec.end_date_active,
2658         x_return_status => x_return_status
2659       );
2660 
2661       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
2662 
2663 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
2664 	     RAISE FND_API.G_EXC_ERROR;
2665 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
2666 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2667 	END IF;
2668 
2669 
2670       END IF;
2671 
2672     END IF;
2673 
2674     /* Validate that the resource dates cover the role related dates for the
2675 	  resource */
2676 
2677     /* First part of the validation where the role relate end date active
2678 	  is not null */
2679 
2680     OPEN c_related_role_dates_first(l_resource_id);
2681 
2682     FETCH c_related_role_dates_first INTO l_min_start_date, l_max_end_date;
2683 
2684 
2685     IF l_min_start_date IS NOT NULL THEN
2686 
2687       IF l_start_date_active <> FND_API.G_MISS_DATE AND
2688          l_min_start_date < l_start_date_active THEN
2689 
2690         /* Resource Start Date out of range for the role related start dates of the resource */
2691 
2692         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_START_DATE');
2693         fnd_msg_pub.add;
2694 
2695         RAISE fnd_api.g_exc_error;
2696 
2697 
2698       END IF;
2699 
2700       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
2701            l_max_end_date > l_end_date_active AND
2702            l_end_date_active IS NOT NULL ) THEN
2703 
2704         /* Resource End Date out of range for the role related End dates of the Resource */
2705 
2706         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_END_DATE');
2707         fnd_msg_pub.add;
2708 
2709         RAISE fnd_api.g_exc_error;
2710 
2711 
2712       END IF;
2713 
2714     END IF;
2715 
2716 
2717     /* Close the cursor */
2718 
2719     IF c_related_role_dates_first%ISOPEN THEN
2720 
2721       CLOSE c_related_role_dates_first;
2722 
2723     END IF;
2724 
2725 
2726 
2727     /* Second part of the validation where the role relate end date active
2728 	  is null */
2729 
2730     OPEN c_related_role_dates_sec(l_resource_id);
2731 
2732     FETCH c_related_role_dates_sec INTO l_min_start_date;
2733 
2734 
2735     IF l_min_start_date IS NOT NULL THEN
2736 
2737       IF  l_start_date_active <> FND_API.G_MISS_DATE AND
2738           l_min_start_date < l_start_date_active THEN
2739 
2740         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_START_DATE');
2741         fnd_msg_pub.add;
2742 
2743         RAISE fnd_api.g_exc_error;
2744 
2745 
2746       END IF;
2747 
2748       IF l_end_date_active <> FND_API.G_MISS_DATE AND
2749          l_end_date_active IS NOT NULL THEN
2750 
2751         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_END_DATE');
2752         fnd_msg_pub.add;
2753 
2754         RAISE fnd_api.g_exc_error;
2755 
2756 
2757       END IF;
2758 
2759     END IF;
2760 
2761 
2762     /* Close the cursor */
2763 
2764     IF c_related_role_dates_sec%ISOPEN THEN
2765 
2766       CLOSE c_related_role_dates_sec;
2767 
2768     END IF;
2769 
2770 
2771 
2772     /* Validate that the resource dates cover the group member role related dates for the
2773 	  resource */
2774 
2775     /* First part of the validation where the group member role relate end date active
2776 	  is not null */
2777 
2778     OPEN c_grp_mbr_role_dates_first(l_resource_id);
2779 
2780     FETCH c_grp_mbr_role_dates_first INTO l_min_start_date, l_max_end_date;
2781 
2782 
2783     IF l_min_start_date IS NOT NULL THEN
2784 
2785       IF l_start_date_active <> FND_API.G_MISS_DATE AND
2786          l_min_start_date < l_start_date_active THEN
2787 
2788         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_START_DATE');
2789         fnd_msg_pub.add;
2790 
2791         RAISE fnd_api.g_exc_error;
2792 
2793 
2794       END IF;
2795 
2796       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
2797            l_max_end_date > l_end_date_active AND
2798            l_end_date_active IS NOT NULL ) THEN
2799 
2800         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_END_DATE');
2801         fnd_msg_pub.add;
2802 
2803         RAISE fnd_api.g_exc_error;
2804 
2805       END IF;
2806 
2807     END IF;
2808 
2809 
2810     /* Close the cursor */
2811 
2812     IF c_grp_mbr_role_dates_first%ISOPEN THEN
2813 
2814       CLOSE c_grp_mbr_role_dates_first;
2815 
2816     END IF;
2817 
2818 
2819 
2820     /* Second part of the validation where the member role relate end date active
2821 	  is null */
2822 
2823     OPEN c_grp_mbr_role_dates_sec(l_resource_id);
2824 
2825     FETCH c_grp_mbr_role_dates_sec INTO l_min_start_date;
2826 
2827 
2828     IF l_min_start_date IS NOT NULL THEN
2829 
2830       IF l_start_date_active <> FND_API.G_MISS_DATE AND
2831          l_min_start_date < l_start_date_active THEN
2832 
2833         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_START_DATE');
2834         fnd_msg_pub.add;
2835 
2836         RAISE fnd_api.g_exc_error;
2837 
2838 
2839       END IF;
2840 
2841       IF l_end_date_active <> FND_API.G_MISS_DATE AND
2842          l_end_date_active IS NOT NULL THEN
2843 
2844         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_END_DATE');
2845         fnd_msg_pub.add;
2846 
2847         RAISE fnd_api.g_exc_error;
2848 
2849 
2850       END IF;
2851 
2852     END IF;
2853 
2854 
2855     /* Close the cursor */
2856 
2857     IF c_grp_mbr_role_dates_sec%ISOPEN THEN
2858 
2859       CLOSE c_grp_mbr_role_dates_sec;
2860 
2861     END IF;
2862 
2863 
2864 
2865     /* Validate that the resource dates cover the team member role related dates for the
2866 	  resource, where the team member is a resource */
2867 
2868     /* First part of the validation where the team member role relate end date active
2869 	  is not null */
2870 
2871     OPEN c_team_mbr_role_dates_first(l_resource_id);
2872 
2873     FETCH c_team_mbr_role_dates_first INTO l_min_start_date, l_max_end_date;
2874 
2875 
2876     IF l_min_start_date IS NOT NULL THEN
2877 
2878       IF l_start_date_active <> FND_API.G_MISS_DATE AND
2879          l_min_start_date < l_start_date_active THEN
2880 
2881         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_START_DATE');
2882         fnd_msg_pub.add;
2883 
2884         RAISE fnd_api.g_exc_error;
2885 
2886 
2887       END IF;
2888 
2889       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
2890            l_max_end_date > l_end_date_active AND
2891            l_end_date_active IS NOT NULL ) THEN
2892 
2893         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_END_DATE');
2894         fnd_msg_pub.add;
2895 
2896         RAISE fnd_api.g_exc_error;
2897 
2898 
2899       END IF;
2900 
2901     END IF;
2902 
2903 
2904 
2905     /* Close the cursor */
2906 
2907     IF c_team_mbr_role_dates_first%ISOPEN THEN
2908 
2909       CLOSE c_team_mbr_role_dates_first;
2910 
2911     END IF;
2912 
2913 
2914 
2915     /* Second part of the validation where the member role relate end date active
2916 	  is null */
2917 
2918     OPEN c_team_mbr_role_dates_sec(l_resource_id);
2919 
2920     FETCH c_team_mbr_role_dates_sec INTO l_min_start_date;
2921 
2922 
2923     IF l_min_start_date IS NOT NULL THEN
2924 
2925       IF l_start_date_active <> FND_API.G_MISS_DATE AND
2926          l_min_start_date < l_start_date_active THEN
2927 
2928         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_START_DATE');
2929         fnd_msg_pub.add;
2930 
2931         RAISE fnd_api.g_exc_error;
2932 
2933 
2934       END IF;
2935 
2936       IF l_end_date_active <> FND_API.G_MISS_DATE AND
2937          l_end_date_active IS NOT NULL THEN
2938 
2939         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_END_DATE');
2940         fnd_msg_pub.add;
2941 
2942         RAISE fnd_api.g_exc_error;
2943 
2944 
2945       END IF;
2946 
2947     END IF;
2948 
2949 
2950     /* Close the cursor */
2951 
2952     IF c_team_mbr_role_dates_sec%ISOPEN THEN
2953 
2954       CLOSE c_team_mbr_role_dates_sec;
2955 
2956     END IF;
2957 
2958 
2959 
2960     /* Validate that the resource dates cover the salesrep related dates for the
2961 	  resource */
2962 
2963     /* First part of the validation where the salesrep end date active
2964 	  is not null */
2965 
2966     OPEN c_salesrep_dates_first(l_resource_id);
2967 
2968     FETCH c_salesrep_dates_first INTO l_min_start_date, l_max_end_date;
2969 
2970 
2971     IF l_min_start_date IS NOT NULL THEN
2972 
2973       IF l_start_date_active <> FND_API.G_MISS_DATE AND
2974          l_min_start_date < l_start_date_active THEN
2975 
2976         /* Resource Start Date out of range for the salesrep related start dates of the resource */
2977 
2978         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_START_DATE');
2979         fnd_msg_pub.add;
2980 
2981         RAISE fnd_api.g_exc_error;
2982 
2983 
2984       END IF;
2985 
2986       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
2987            l_max_end_date > l_end_date_active AND
2988            l_end_date_active IS NOT NULL ) THEN
2989 
2990         /* Resource End Date out of range for the salesrep related End dates of the Resource */
2991 
2992         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_END_DATE');
2993         fnd_msg_pub.add;
2994 
2995         RAISE fnd_api.g_exc_error;
2996 
2997 
2998       END IF;
2999 
3000     END IF;
3001 
3002 
3003     /* Close the cursor */
3004 
3005     IF c_salesrep_dates_first%ISOPEN THEN
3006 
3007       CLOSE c_salesrep_dates_first;
3008 
3009     END IF;
3010 
3011 
3012 
3013     /* Second part of the validation where the role relate end date active
3014 	  is null */
3015 
3016     OPEN c_salesrep_dates_sec(l_resource_id);
3017 
3018     FETCH c_salesrep_dates_sec INTO l_min_start_date;
3019 
3020 
3021     IF l_min_start_date IS NOT NULL THEN
3022 
3023       IF l_start_date_active <> FND_API.G_MISS_DATE AND
3024          l_min_start_date < l_start_date_active THEN
3025 
3026         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_START_DATE');
3027         fnd_msg_pub.add;
3028 
3029         RAISE fnd_api.g_exc_error;
3030 
3031 
3032       END IF;
3033 
3034       IF l_end_date_active <> FND_API.G_MISS_DATE AND
3035          l_end_date_active IS NOT NULL THEN
3036 
3037         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_END_DATE');
3038         fnd_msg_pub.add;
3039 
3040         RAISE fnd_api.g_exc_error;
3041 
3042 
3043       END IF;
3044 
3045     END IF;
3046 
3047 
3048     /* Close the cursor */
3049 
3050     IF c_salesrep_dates_sec%ISOPEN THEN
3051 
3052       CLOSE c_salesrep_dates_sec;
3053 
3054     END IF;
3055 
3056 
3057 
3058     /* Validate the Time Zone */
3059 
3060     IF l_time_zone <> fnd_api.g_miss_num THEN
3061 
3062       IF l_time_zone IS NOT NULL THEN
3063 
3064         jtf_resource_utl.validate_time_zone(
3065           p_time_zone_id => l_time_zone,
3066           x_return_status => x_return_status
3067         );
3068 
3069         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3070 
3071 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3072 		RAISE FND_API.G_EXC_ERROR;
3073 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3074 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3075 	   END IF;
3076 
3077 
3078         END IF;
3079 
3080       END IF;
3081 
3082     END IF;
3083 
3084 
3085 
3086     /* Validate the Primary Language */
3087 
3088     IF l_primary_language <> fnd_api.g_miss_char THEN
3089 
3090       IF l_primary_language IS NOT NULL THEN
3091 
3092         jtf_resource_utl.validate_nls_language(
3093           p_nls_language => l_primary_language,
3094           x_return_status => x_return_status
3095         );
3096 
3097         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3098 
3099 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3100 		RAISE FND_API.G_EXC_ERROR;
3101 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3102 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3103 	   END IF;
3104 
3105 
3106         END IF;
3107 
3108       END IF;
3109 
3110     END IF;
3111 
3112 
3113 
3114     /* Validate the Secondary Language */
3115 
3116     IF l_secondary_language <> fnd_api.g_miss_char THEN
3117 
3118       IF l_secondary_language IS NOT NULL THEN
3119 
3120         jtf_resource_utl.validate_nls_language(
3121           p_nls_language => l_secondary_language,
3122           x_return_status => x_return_status
3123         );
3124 
3125         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3126 
3127 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3128 		RAISE FND_API.G_EXC_ERROR;
3129 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3130 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3131 	   END IF;
3132 
3133 
3134         END IF;
3135 
3136       END IF;
3137 
3138     END IF;
3139 
3140 
3141 
3142     /* Validate the Support Site */
3143 
3144     IF l_support_site_id <> fnd_api.g_miss_num THEN
3145 
3146       IF l_support_site_id IS NOT NULL THEN
3147 
3148         jtf_resource_utl.validate_support_site_id(
3149           p_support_site_id => l_support_site_id,
3150           x_return_status => x_return_status
3151         );
3152 
3153         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3154 
3155 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3156 	       RAISE FND_API.G_EXC_ERROR;
3157 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3158 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3159 	  END IF;
3160 
3161 
3162         END IF;
3163 
3164       END IF;
3165 
3166     END IF;
3167 
3168 
3169 
3170     /* Validate the Server Group. */
3171 
3172     IF l_server_group_id <> fnd_api.g_miss_num THEN
3173 
3174       jtf_resource_utl.validate_server_group(
3175         p_server_group_id => l_server_group_id,
3176         p_server_group_name => null,
3177         x_return_status => x_return_status,
3178         x_server_group_id => l_server_group_id_out
3179       );
3180 -- added for NOCOPY
3181       l_server_group_id := l_server_group_id_out;
3182 
3183       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3184 
3185 	 IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3186 	      RAISE FND_API.G_EXC_ERROR;
3187 	 ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3188 	      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3189 	 END IF;
3190 
3191 
3192       END IF;
3193 
3194     END IF;
3195 
3196 
3197 
3198     /* Validate the assigned_to_group_id if specified */
3199 
3200     IF l_assigned_to_group_id <> fnd_api.g_miss_num THEN
3201 
3202       IF l_assigned_to_group_id IS NOT NULL THEN
3203 
3204         OPEN c_assigned_to_group_id(l_assigned_to_group_id);
3205 
3206         FETCH c_assigned_to_group_id INTO l_assigned_to_group_id;
3207 
3208 
3209         IF c_assigned_to_group_id%NOTFOUND THEN
3210 
3211 --          dbms_output.put_line('Invalid Assigned To Group Id');
3212 
3213           fnd_message.set_name('JTF', 'JTF_RS_ERR_ASSIGN_TO_GRP_ID');
3214           fnd_message.set_token('P_ASSIGNED_TO_GROUP_ID', l_assigned_to_group_id);
3215           fnd_msg_pub.add;
3216 
3217           RAISE fnd_api.g_exc_error;
3218 
3219 
3220         END IF;
3221 
3222 
3223         /* Close the cursor */
3224 
3225         IF c_assigned_to_group_id%ISOPEN THEN
3226 
3227           CLOSE c_assigned_to_group_id;
3228 
3229         END IF;
3230 
3231       END IF;
3232 
3233     END IF;
3234 
3235 
3236 
3237     /* Validate the Comp Currency Code */
3238 
3239     IF l_comp_currency_code <> fnd_api.g_miss_char THEN
3240 
3241       IF l_comp_currency_code IS NOT NULL THEN
3242 
3243         jtf_resource_utl.validate_currency_code(
3244           p_currency_code => l_comp_currency_code,
3245           x_return_status => x_return_status
3246         );
3247 
3248         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3249 
3250 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3251 		RAISE FND_API.G_EXC_ERROR;
3252 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3253 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3254 	   END IF;
3255 
3256 
3257         END IF;
3258 
3259       END IF;
3260 
3261     END IF;
3262 
3263 
3264 
3265     /* Validate the value of the commisionable flag */
3266 
3267     IF l_commissionable_flag <> fnd_api.g_miss_char THEN
3268 
3269       IF l_commissionable_flag <> 'Y' AND l_commissionable_flag <> 'N' THEN
3270 
3271 --	   dbms_output.put_line('Commissionable Flag should either be ''Y'' or ''N'' ');
3272 
3273         fnd_message.set_name('JTF', 'JTF_RS_INVALID_FLAG_VALUE');
3274         fnd_msg_pub.add;
3275 
3276         RAISE fnd_api.g_exc_error;
3277 
3278 
3279       END IF;
3280 
3281     END IF;
3282 
3283 
3284 
3285     /* Validate the value of the Hold Payment flag */
3286 
3287     IF l_hold_payment <> fnd_api.g_miss_char THEN
3288 
3289       IF l_hold_payment <> 'Y' AND l_hold_payment <> 'N' THEN
3290 
3291 --	   dbms_output.put_line('Hold Payment should either be ''Y'' or ''N'' ');
3292 
3293         fnd_message.set_name('JTF', 'JTF_RS_INVALID_FLAG_VALUE');
3294         fnd_msg_pub.add;
3295 
3296         RAISE fnd_api.g_exc_error;
3297 
3298 
3299       END IF;
3300 
3301     END IF;
3302 
3303 
3304 
3305     /* Validate the Hold Reason Code */
3306 
3307     IF l_hold_reason_code <> fnd_api.g_miss_char THEN
3308 
3309       IF l_hold_reason_code IS NOT NULL THEN
3310 
3311         jtf_resource_utl.validate_hold_reason_code(
3312           p_hold_reason_code => l_hold_reason_code,
3313           x_return_status => x_return_status
3314         );
3315 
3316         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3317 
3318 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3319 	       RAISE FND_API.G_EXC_ERROR;
3320 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3321 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3322 	  END IF;
3323 
3324 
3325         END IF;
3326 
3327       END IF;
3328 
3329     END IF;
3330 
3331 
3332     /* Validate that the user_id should only be specified in case of
3333 	  'EMPLOYEE', 'PARTY', 'SUPPLIER_CONTACT' categories */
3334 
3335     IF l_user_id <> fnd_api.g_miss_num THEN
3336 
3337 /* Removed 'WORKER' from the below code to fix bug # 3455951 */
3338       IF resource_rec.category NOT IN ('EMPLOYEE', 'PARTY', 'SUPPLIER_CONTACT') AND l_user_id IS NOT NULL THEN
3339 
3340         fnd_message.set_name('JTF', 'JTF_RS_USERID_ERROR');
3341         fnd_msg_pub.add;
3342 
3343         RAISE fnd_api.g_exc_error;
3344 
3345 
3346 	 END IF;
3347 
3348     END IF;
3349 
3350 
3351     IF l_user_id <> fnd_api.g_miss_num THEN
3352 
3353       /* Validate the User Id if specified */
3354 
3355       IF l_user_id IS NOT NULL THEN
3356 
3357         jtf_resource_utl.validate_user_id(
3358           p_user_id => l_user_id,
3359           p_category => resource_rec.category,
3360           p_source_id => resource_rec.source_id,
3361           x_return_status => x_return_status
3362         );
3363 
3364         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3365 
3366 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3367 		RAISE FND_API.G_EXC_ERROR;
3368 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3369 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3370 	   END IF;
3371 
3372         else
3373 
3374         OPEN c_validate_user_id(l_resource_id,l_user_id);
3375 
3376         FETCH c_validate_user_id INTO l_check_flag
3377 ;
3378 
3379 
3380         IF c_validate_user_id%FOUND THEN
3381 
3382 --          dbms_output.put_line('duplicate user Id');
3383 
3384           fnd_message.set_name('JTF', 'JTF_RS_ERR_DUPLICATE_USER_ID');
3385           fnd_message.set_token('P_USER_ID', l_user_id);
3386           fnd_msg_pub.add;
3387 
3388           RAISE fnd_api.g_exc_error;
3389 
3390         END IF;
3391 
3392 
3393         /* Close the cursor */
3394 
3395         CLOSE c_validate_user_id;
3396 
3397 
3398 
3399         END IF;
3400 
3401       END IF;
3402 
3403     END IF;
3404 
3405 
3406     /* Validate the Comp Service Team Id if specified */
3407 
3408     IF l_comp_service_team_id <> fnd_api.g_miss_num THEN
3409 
3410       IF l_comp_service_team_id IS NOT NULL THEN
3411 
3412         jtf_resource_utl.validate_resource_team(
3413           p_team_id => l_comp_service_team_id,
3414           p_team_number => null,
3415           x_return_status => x_return_status,
3416           x_team_id => l_comp_service_team_id_out
3417         );
3418 -- added for NOCOPY
3419         l_comp_service_team_id  := l_comp_service_team_id_out;
3420 
3421 
3422         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3423 
3424 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3425 		RAISE FND_API.G_EXC_ERROR;
3426 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3427 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3428 	   END IF;
3429 
3430 
3431         END IF;
3432 
3433       END IF;
3434 
3435     END IF;
3436 
3437 
3438     /* Call the lock row procedure to ensure that the object version number
3439 	  is still valid. */
3440 
3441     BEGIN
3442 
3443       jtf_rs_resource_extns_pkg.lock_row(
3444         x_resource_id => l_resource_id,
3445 	   x_object_version_number => p_object_version_num
3446       );
3447 
3448      --dbms_output.put_line ('After Call to Lock Row Procedure');
3449 
3450 
3451     EXCEPTION
3452 
3453 	 WHEN OTHERS THEN
3454 
3455 --	   dbms_output.put_line('Error in Locking the Row');
3456 
3457 	   x_return_status := fnd_api.g_ret_sts_unexp_error;
3458 
3459 	   fnd_message.set_name('JTF', 'JTF_RS_ROW_LOCK_ERROR');
3460 	   fnd_msg_pub.add;
3461 
3462            RAISE fnd_api.g_exc_error;
3463 
3464 
3465     END;
3466 
3467     --dbms_output.put_line ('Before Call to Audit API');
3468 
3469 
3470     /* Make a call to the Resource Audit API */
3471 
3472     jtf_rs_resource_extns_aud_pvt.update_resource
3473     (P_API_VERSION => 1,
3474      P_INIT_MSG_LIST => fnd_api.g_false,
3475      P_COMMIT => fnd_api.g_false,
3476      P_RESOURCE_ID => l_resource_id,
3477      P_RESOURCE_NUMBER => resource_rec.resource_number,
3478      P_CATEGORY => resource_rec.category,
3479      P_SOURCE_ID => resource_rec.source_id,
3480 	P_ADDRESS_ID => resource_rec.address_id,
3481 	P_CONTACT_ID => resource_rec.contact_id,
3482 	P_MANAGING_EMP_ID => resource_rec.managing_emp_id,
3483 	P_START_DATE_ACTIVE => resource_rec.start_date_active,
3484 	P_END_DATE_ACTIVE => resource_rec.end_date_active,
3485      P_TIME_ZONE => resource_rec.time_zone,
3486      P_COST_PER_HR => resource_rec.cost_per_hr,
3487      P_PRIMARY_LANGUAGE => resource_rec.primary_language,
3488      P_SECONDARY_LANGUAGE => resource_rec.secondary_language,
3489      P_SUPPORT_SITE_ID => resource_rec.support_site_id,
3490      P_IES_AGENT_LOGIN => resource_rec.ies_agent_login,
3491      P_SERVER_GROUP_ID => resource_rec.server_group_id,
3492      P_ASSIGNED_TO_GROUP_ID => resource_rec.assigned_to_group_id,
3493      P_COST_CENTER => resource_rec.cost_center,
3494      P_CHARGE_TO_COST_CENTER => resource_rec.charge_to_cost_center,
3495      P_COMP_CURRENCY_CODE => resource_rec.comp_currency_code,
3496      P_COMMISSIONABLE_FLAG => resource_rec.commissionable_flag,
3497      P_HOLD_REASON_CODE => resource_rec.hold_reason_code,
3498      P_HOLD_PAYMENT => resource_rec.hold_payment,
3499      P_COMP_SERVICE_TEAM_ID => resource_rec.comp_service_team_id,
3500      P_USER_ID => resource_rec.user_id,
3501      P_TRANSACTION_NUMBER => resource_rec.transaction_number,
3502     -- P_LOCATION => resource_rec.location,
3503 	P_OBJECT_VERSION_NUMBER => p_object_version_num + 1,
3504      X_RETURN_STATUS => x_return_status,
3505      X_MSG_COUNT => x_msg_count,
3506      X_MSG_DATA => x_msg_data
3507     );
3508 
3509     --dbms_output.put_line ('After Call to Audit API');
3510 
3511     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3512 
3513 --	 dbms_output.put_line('Failed status from call to audit procedure');
3514 
3515       IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3516 	   RAISE FND_API.G_EXC_ERROR;
3517       ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3518 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3519       END IF;
3520 
3521 
3522     END IF;
3523 
3524 
3525     BEGIN
3526 
3527       /* Increment the object version number */
3528 
3529 	 l_object_version_num := p_object_version_num + 1;
3530 
3531     --dbms_output.put_line ('Before Call to Update Row Table Handler ');
3532 
3533 
3534       /* Update the row into the table by calling the table handler. */
3535 
3536       jtf_rs_resource_extns_pkg.update_row(
3537         x_resource_id => l_resource_id,
3538         x_category => resource_rec.category,
3539         x_resource_number => resource_rec.resource_number,
3540         x_source_id => resource_rec.source_id,
3541         x_address_id => resource_rec.address_id,
3542         x_contact_id => resource_rec.contact_id,
3543         x_managing_employee_id => resource_rec.managing_emp_id,
3544         x_start_date_active => resource_rec.start_date_active,
3545         x_end_date_active => resource_rec.end_date_active,
3546         x_time_zone => resource_rec.time_zone,
3547         x_cost_per_hr => resource_rec.cost_per_hr,
3548         x_primary_language => resource_rec.primary_language,
3549         x_secondary_language => resource_rec.secondary_language,
3550         x_support_site_id => resource_rec.support_site_id,
3551         x_ies_agent_login => resource_rec.ies_agent_login,
3552         x_server_group_id => resource_rec.server_group_id,
3553         x_assigned_to_group_id => resource_rec.assigned_to_group_id,
3554         x_cost_center => resource_rec.cost_center,
3555         x_charge_to_cost_center => resource_rec.charge_to_cost_center,
3556         x_compensation_currency_code => resource_rec.comp_currency_code,
3557         x_commissionable_flag => resource_rec.commissionable_flag,
3558         x_hold_reason_code => resource_rec.hold_reason_code,
3559         x_hold_payment => resource_rec.hold_payment,
3560         x_comp_service_team_id => resource_rec.comp_service_team_id,
3561         x_user_id => resource_rec.user_id,
3562         --x_location => resource_rec.location,
3563         x_transaction_number => resource_rec.transaction_number,
3564 	   x_object_version_number => l_object_version_num,
3565         x_attribute1 => resource_rec.attribute1,
3566         x_attribute2 => resource_rec.attribute2,
3567         x_attribute3 => resource_rec.attribute3,
3568         x_attribute4 => resource_rec.attribute4,
3569         x_attribute5 => resource_rec.attribute5,
3570         x_attribute6 => resource_rec.attribute6,
3571         x_attribute7 => resource_rec.attribute7,
3572         x_attribute8 => resource_rec.attribute8,
3573         x_attribute9 => resource_rec.attribute9,
3574         x_attribute10 => resource_rec.attribute10,
3575         x_attribute11 => resource_rec.attribute11,
3576         x_attribute12 => resource_rec.attribute12,
3577         x_attribute13 => resource_rec.attribute13,
3578         x_attribute14 => resource_rec.attribute14,
3579         x_attribute15 => resource_rec.attribute15,
3580         x_attribute_category => resource_rec.attribute_category,
3581         x_last_update_date => SYSDATE,
3582         x_last_updated_by => jtf_resource_utl.updated_by,
3583         x_last_update_login => jtf_resource_utl.login_id
3584       );
3585 
3586       --dbms_output.put_line ('After Call to Update Row Table Handler ');
3587 
3588       /* Return the new value of the object version number */
3589 
3590       p_object_version_num := l_object_version_num;
3591 
3592     EXCEPTION
3593 
3594 	 WHEN NO_DATA_FOUND THEN
3595 
3596 --	   dbms_output.put_line('Error in Table Handler');
3597 
3598         IF c_resource_update%ISOPEN THEN
3599 
3600           CLOSE c_resource_update;
3601 
3602         END IF;
3603 
3604 	   x_return_status := fnd_api.g_ret_sts_unexp_error;
3605 
3606 	   fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
3607 	   fnd_msg_pub.add;
3608 
3609            RAISE fnd_api.g_exc_error;
3610 
3611 
3612     END;
3613 
3614 --    dbms_output.put_line('Resource Successfully Updated');
3615 
3616 
3617     /* Close the cursors */
3618 
3619     IF c_resource_update%ISOPEN THEN
3620 
3621       CLOSE c_resource_update;
3622 
3623     END IF;
3624 
3625 
3626     /* Make the post processing call to the user hooks */
3627 
3628     /* Post Call to the Customer Type User Hook */
3629 
3630     IF jtf_resource_utl.ok_to_execute(
3631 	 'JTF_RS_RESOURCE_PVT',
3632 	 'UPDATE_RESOURCE',
3633 	 'A',
3634 	 'C')
3635     THEN
3636     IF jtf_usr_hks.ok_to_execute(
3637 	 'JTF_RS_RESOURCE_PVT',
3638 	 'UPDATE_RESOURCE',
3639 	 'A',
3640 	 'C')
3641     THEN
3642 
3643       jtf_rs_resource_cuhk.update_resource_post(
3644 	   p_resource_id => l_resource_id,
3645         p_managing_emp_id => l_managing_emp_id,
3646         p_start_date_active => l_start_date_active,
3647         p_end_date_active => l_end_date_active,
3648         p_time_zone => l_time_zone,
3649         p_cost_per_hr => l_cost_per_hr,
3650         p_primary_language => l_primary_language,
3651         p_secondary_language => l_secondary_language,
3652         p_support_site_id => l_support_site_id,
3653         p_ies_agent_login => l_ies_agent_login,
3654         p_server_group_id => l_server_group_id,
3655         p_assigned_to_group_id => l_assigned_to_group_id,
3656         p_cost_center => l_cost_center,
3657         p_charge_to_cost_center => l_charge_to_cost_center,
3658         p_comp_currency_code => l_comp_currency_code,
3659         p_commissionable_flag => l_commissionable_flag,
3660         p_hold_reason_code => l_hold_reason_code,
3661         p_hold_payment => l_hold_payment,
3662         p_comp_service_team_id => l_comp_service_team_id,
3663         p_user_id => l_user_id,
3664         --p_location => l_location,
3665 	   x_return_status => x_return_status);
3666 
3667       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3668 
3669 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
3670 
3671 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
3672 	   fnd_msg_pub.add;
3673 
3674 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3675 		RAISE FND_API.G_EXC_ERROR;
3676 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3677 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3678 	   END IF;
3679 
3680 
3681       END IF;
3682 
3683     END IF;
3684     END IF;
3685 
3686 
3687     /* Post Call to the Vertical Type User Hook */
3688 
3689     IF jtf_resource_utl.ok_to_execute(
3690 	 'JTF_RS_RESOURCE_PVT',
3691 	 'UPDATE_RESOURCE',
3692 	 'A',
3693 	 'V')
3694     THEN
3695     IF jtf_usr_hks.ok_to_execute(
3696 	 'JTF_RS_RESOURCE_PVT',
3697 	 'UPDATE_RESOURCE',
3698 	 'A',
3699 	 'V')
3700     THEN
3701 
3702       jtf_rs_resource_vuhk.update_resource_post(
3703 	   p_resource_id => l_resource_id,
3704         p_managing_emp_id => l_managing_emp_id,
3705         p_start_date_active => l_start_date_active,
3706         p_end_date_active => l_end_date_active,
3707         p_time_zone => l_time_zone,
3708         p_cost_per_hr => l_cost_per_hr,
3709         p_primary_language => l_primary_language,
3710         p_secondary_language => l_secondary_language,
3711         p_support_site_id => l_support_site_id,
3712         p_ies_agent_login => l_ies_agent_login,
3713         p_server_group_id => l_server_group_id,
3714         p_assigned_to_group_id => l_assigned_to_group_id,
3715         p_cost_center => l_cost_center,
3716         p_charge_to_cost_center => l_charge_to_cost_center,
3717         p_comp_currency_code => l_comp_currency_code,
3718         p_commissionable_flag => l_commissionable_flag,
3719         p_hold_reason_code => l_hold_reason_code,
3720         p_hold_payment => l_hold_payment,
3721         p_comp_service_team_id => l_comp_service_team_id,
3722         p_user_id => l_user_id,
3723         --p_location => l_location,
3724 	   x_return_status => x_return_status);
3725 
3726       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3727 
3728 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
3729 
3730 
3731 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
3732 	   fnd_msg_pub.add;
3733 
3734 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3735 		RAISE FND_API.G_EXC_ERROR;
3736 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3737 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3738 	   END IF;
3739 
3740 
3741       END IF;
3742 
3743     END IF;
3744     END IF;
3745 
3746 
3747     /* Post Call to the Internal Type User Hook */
3748 
3749     IF jtf_resource_utl.ok_to_execute(
3750 	 'JTF_RS_RESOURCE_PVT',
3751 	 'UPDATE_RESOURCE',
3752 	 'A',
3753 	 'I')
3754     THEN
3755     IF jtf_usr_hks.ok_to_execute(
3756 	 'JTF_RS_RESOURCE_PVT',
3757 	 'UPDATE_RESOURCE',
3758 	 'A',
3759 	 'I')
3760     THEN
3761 
3762       jtf_rs_resource_iuhk.update_resource_post(
3763 	   p_resource_id => l_resource_id,
3764         p_managing_emp_id => l_managing_emp_id,
3765         p_start_date_active => l_start_date_active,
3766         p_end_date_active => l_end_date_active,
3767         p_time_zone => l_time_zone,
3768         p_cost_per_hr => l_cost_per_hr,
3769         p_primary_language => l_primary_language,
3770         p_secondary_language => l_secondary_language,
3771         p_support_site_id => l_support_site_id,
3772         p_ies_agent_login => l_ies_agent_login,
3773         p_server_group_id => l_server_group_id,
3774         p_assigned_to_group_id => l_assigned_to_group_id,
3775         p_cost_center => l_cost_center,
3776         p_charge_to_cost_center => l_charge_to_cost_center,
3777         p_comp_currency_code => l_comp_currency_code,
3778         p_commissionable_flag => l_commissionable_flag,
3779         p_hold_reason_code => l_hold_reason_code,
3780         p_hold_payment => l_hold_payment,
3781         p_comp_service_team_id => l_comp_service_team_id,
3782         p_user_id => l_user_id,
3783         --p_location => l_location,
3784 	   x_return_status => x_return_status);
3785 
3786       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3787 
3788 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
3789 
3790 
3791 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
3792 	   fnd_msg_pub.add;
3793 
3794 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3795 		RAISE FND_API.G_EXC_ERROR;
3796 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3797 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3798 	   END IF;
3799 
3800       END IF;
3801 
3802     END IF;
3803     END IF;
3804 
3805 
3806     /* Standard call for Message Generation */
3807 
3808     IF jtf_resource_utl.ok_to_execute(
3809 	 'JTF_RS_RESOURCE_PVT',
3810 	 'UPDATE_RESOURCE',
3811 	 'M',
3812 	 'M')
3813     THEN
3814     IF jtf_usr_hks.ok_to_execute(
3815 	 'JTF_RS_RESOURCE_PVT',
3816 	 'UPDATE_RESOURCE',
3817 	 'M',
3818 	 'M')
3819     THEN
3820 
3821       IF (jtf_rs_resource_cuhk.ok_to_generate_msg(
3822 	       p_resource_id => l_resource_id,
3823 	       x_return_status => x_return_status) )
3824       THEN
3825 
3826         /* Get the bind data id for the Business Object Instance */
3827 
3828         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
3829 
3830 
3831         /* Set bind values for the bind variables in the Business Object SQL */
3832 
3833         jtf_usr_hks.load_bind_data(l_bind_data_id, 'resource_id', l_resource_id, 'S', 'N');
3834 
3835 
3836         /* Call the message generation API */
3837 
3838         jtf_usr_hks.generate_message(
3839 		p_prod_code => 'RS',
3840 		p_bus_obj_code => 'RES',
3841 		p_action_code => 'U',
3842 		p_bind_data_id => l_bind_data_id,
3843 		x_return_code => x_return_status);
3844 
3845 
3846         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
3847 
3848 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
3849 
3850 
3851 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
3852 	     fnd_msg_pub.add;
3853 
3854 	     IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
3855 		  RAISE FND_API.G_EXC_ERROR;
3856 	     ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
3857 		  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3858 	     END IF;
3859 
3860 
3861         END IF;
3862 
3863       END IF;
3864 
3865     END IF;
3866     END IF;
3867 
3868 
3869     IF fnd_api.to_boolean(p_commit) THEN
3870 
3871 	 COMMIT WORK;
3872 
3873     END IF;
3874 
3875     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
3876 
3877 
3878   EXCEPTION
3879 
3880     WHEN fnd_api.g_exc_error THEN
3881       ROLLBACK TO update_resource_pvt;
3882       x_return_status := fnd_api.g_ret_sts_error;
3883       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
3884                                  p_data => x_msg_data);
3885     WHEN fnd_api.g_exc_unexpected_error THEN
3886       ROLLBACK TO update_resource_pvt;
3887       x_return_status := fnd_api.g_ret_sts_unexp_error;
3888       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
3889                                  p_data => x_msg_data);
3890     WHEN OTHERS THEN
3891       ROLLBACK TO update_resource_pvt;
3892 -- The below lines removed as a part of fixing GSCC errors in R12 for jtfrspub.pls
3893 --      IF NOT(jtf_resource_utl.check_access(l_value))
3894 --      THEN
3895 --            IF(l_value = 'XMLGEN')
3896 --            THEN
3897 --		 fnd_message.set_name ('JTF', 'JTF_RS_XMLGEN_ERR');
3898 --		 FND_MSG_PUB.add;
3899 --            ELSIF(l_value = 'JTF_USR_HKS')
3900 --            THEN
3901 --		 fnd_message.set_name ('JTF', 'JTF_RS_JUHK_ERR');
3902 --		 FND_MSG_PUB.add;
3903 --            END IF;
3904 --      ELSE
3905 	 fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
3906 	 fnd_message.set_token('P_SQLCODE',SQLCODE);
3907 	 fnd_message.set_token('P_SQLERRM',SQLERRM);
3908 	 fnd_message.set_token('P_API_NAME', l_api_name);
3909 	 FND_MSG_PUB.add;
3910 --      END IF;
3911       x_return_status := fnd_api.g_ret_sts_unexp_error;
3912       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
3913                                  p_data => x_msg_data);
3914 
3915 
3916   END update_resource;
3917 
3918     /*
3919  	  | Modification History :
3920  	  |
3921  	  | Sudhir Gokavarapu      ER9864816 - New procedure Created,  FS_SETUP_COMPLETE parameter is added to
3922       |                        existing UPDATE_RESOURSE parameter list.
3923       |                        Complete business logic moved from old procedure to this new procedure
3924     */
3925 
3926    /* Overloaded Procedure to update the resource for Resource Synchronization along with FS Setup Complet Flag*/
3927 
3928   PROCEDURE  update_resource
3929   (P_API_VERSION             IN   NUMBER,
3930    P_INIT_MSG_LIST           IN   VARCHAR2,
3931    P_COMMIT                  IN   VARCHAR2,
3932    P_RESOURCE_ID             IN   JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
3933    P_MANAGING_EMP_ID         IN   JTF_RS_RESOURCE_EXTNS.MANAGING_EMPLOYEE_ID%TYPE,
3934    P_START_DATE_ACTIVE       IN   JTF_RS_RESOURCE_EXTNS.START_DATE_ACTIVE%TYPE,
3935    P_END_DATE_ACTIVE         IN   JTF_RS_RESOURCE_EXTNS.END_DATE_ACTIVE%TYPE,
3936    P_TIME_ZONE               IN   JTF_RS_RESOURCE_EXTNS.TIME_ZONE%TYPE,
3937    P_COST_PER_HR             IN   JTF_RS_RESOURCE_EXTNS.COST_PER_HR%TYPE,
3938    P_PRIMARY_LANGUAGE        IN   JTF_RS_RESOURCE_EXTNS.PRIMARY_LANGUAGE%TYPE,
3939    P_SECONDARY_LANGUAGE      IN   JTF_RS_RESOURCE_EXTNS.SECONDARY_LANGUAGE%TYPE,
3940    P_SUPPORT_SITE_ID         IN   JTF_RS_RESOURCE_EXTNS.SUPPORT_SITE_ID%TYPE,
3941    P_IES_AGENT_LOGIN         IN   JTF_RS_RESOURCE_EXTNS.IES_AGENT_LOGIN%TYPE,
3942    P_SERVER_GROUP_ID         IN   JTF_RS_RESOURCE_EXTNS.SERVER_GROUP_ID%TYPE,
3943    P_ASSIGNED_TO_GROUP_ID    IN   JTF_RS_RESOURCE_EXTNS.ASSIGNED_TO_GROUP_ID%TYPE,
3944    P_COST_CENTER             IN   JTF_RS_RESOURCE_EXTNS.COST_CENTER%TYPE,
3945    P_CHARGE_TO_COST_CENTER   IN   JTF_RS_RESOURCE_EXTNS.CHARGE_TO_COST_CENTER%TYPE,
3946    P_COMP_CURRENCY_CODE      IN   JTF_RS_RESOURCE_EXTNS.COMPENSATION_CURRENCY_CODE%TYPE,
3947    P_COMMISSIONABLE_FLAG     IN   JTF_RS_RESOURCE_EXTNS.COMMISSIONABLE_FLAG%TYPE,
3948    P_HOLD_REASON_CODE        IN   JTF_RS_RESOURCE_EXTNS.HOLD_REASON_CODE%TYPE,
3949    P_HOLD_PAYMENT            IN   JTF_RS_RESOURCE_EXTNS.HOLD_PAYMENT%TYPE,
3950    P_COMP_SERVICE_TEAM_ID    IN   JTF_RS_RESOURCE_EXTNS.COMP_SERVICE_TEAM_ID%TYPE,
3951    P_USER_ID                 IN   JTF_RS_RESOURCE_EXTNS.USER_ID%TYPE,
3952    --P_LOCATION              IN   MDSYS.SDO_GEOMETRY,
3953    P_ATTRIBUTE1              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE1%TYPE,
3954    P_ATTRIBUTE2              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE2%TYPE,
3955    P_ATTRIBUTE3              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE3%TYPE,
3956    P_ATTRIBUTE4              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE4%TYPE,
3957    P_ATTRIBUTE5              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE5%TYPE,
3958    P_ATTRIBUTE6              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE6%TYPE,
3959    P_ATTRIBUTE7              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE7%TYPE,
3960    P_ATTRIBUTE8              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE8%TYPE,
3961    P_ATTRIBUTE9              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE9%TYPE,
3962    P_ATTRIBUTE10             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE10%TYPE,
3963    P_ATTRIBUTE11             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE11%TYPE,
3964    P_ATTRIBUTE12             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE12%TYPE,
3965    P_ATTRIBUTE13             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE13%TYPE,
3966    P_ATTRIBUTE14             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE14%TYPE,
3967    P_ATTRIBUTE15             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE15%TYPE,
3968    P_ATTRIBUTE_CATEGORY      IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE_CATEGORY%TYPE,
3969    P_RESOURCE_NAME           IN   JTF_RS_RESOURCE_EXTNS_TL.RESOURCE_NAME%TYPE,
3970    P_SOURCE_NAME             IN   JTF_RS_RESOURCE_EXTNS.SOURCE_NAME%TYPE,
3971    P_SOURCE_NUMBER           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_NUMBER%TYPE,
3972    P_SOURCE_JOB_TITLE        IN   JTF_RS_RESOURCE_EXTNS.SOURCE_JOB_TITLE%TYPE,
3973    P_SOURCE_EMAIL            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_EMAIL%TYPE,
3974    P_SOURCE_PHONE            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_PHONE%TYPE,
3975    P_SOURCE_ORG_ID           IN   NUMBER,
3976    P_SOURCE_ORG_NAME         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ORG_NAME%TYPE,
3977    P_SOURCE_ADDRESS1         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS1%TYPE,
3978    P_SOURCE_ADDRESS2         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS2%TYPE,
3979    P_SOURCE_ADDRESS3         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS3%TYPE,
3980    P_SOURCE_ADDRESS4         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS4%TYPE,
3981    P_SOURCE_CITY             IN   JTF_RS_RESOURCE_EXTNS.SOURCE_CITY%TYPE,
3982    P_SOURCE_POSTAL_CODE      IN   JTF_RS_RESOURCE_EXTNS.SOURCE_POSTAL_CODE%TYPE,
3983    P_SOURCE_STATE            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_STATE%TYPE,
3984    P_SOURCE_PROVINCE         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_PROVINCE%TYPE,
3985    P_SOURCE_COUNTY           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_COUNTY%TYPE,
3986    P_SOURCE_COUNTRY          IN   JTF_RS_RESOURCE_EXTNS.SOURCE_COUNTRY%TYPE,
3987    P_SOURCE_MGR_ID           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_MGR_ID%type,
3988    P_SOURCE_MGR_NAME         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_MGR_NAME%type,
3989    P_SOURCE_BUSINESS_GRP_ID  IN   JTF_RS_RESOURCE_EXTNS.SOURCE_BUSINESS_GRP_ID%type,
3990    P_SOURCE_BUSINESS_GRP_NAME IN  JTF_RS_RESOURCE_EXTNS.SOURCE_BUSINESS_GRP_NAME%type,
3991    P_SOURCE_FIRST_NAME        IN JTF_RS_RESOURCE_EXTNS.SOURCE_FIRST_NAME%TYPE,
3992    P_SOURCE_LAST_NAME         IN JTF_RS_RESOURCE_EXTNS.SOURCE_LAST_NAME%TYPE,
3993    P_SOURCE_MIDDLE_NAME       IN JTF_RS_RESOURCE_EXTNS.SOURCE_MIDDLE_NAME%TYPE,
3994    P_SOURCE_CATEGORY          IN JTF_RS_RESOURCE_EXTNS.SOURCE_CATEGORY%TYPE,
3995    P_SOURCE_STATUS            IN JTF_RS_RESOURCE_EXTNS.SOURCE_STATUS%TYPE,
3996    P_SOURCE_OFFICE            IN JTF_RS_RESOURCE_EXTNS.SOURCE_OFFICE%TYPE,
3997    P_SOURCE_LOCATION          IN JTF_RS_RESOURCE_EXTNS.SOURCE_LOCATION%TYPE,
3998    P_SOURCE_MAILSTOP          IN JTF_RS_RESOURCE_EXTNS.SOURCE_MAILSTOP%TYPE,
3999    P_ADDRESS_ID               IN JTF_RS_RESOURCE_EXTNS.ADDRESS_ID%TYPE,
4000    P_OBJECT_VERSION_NUM       IN OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.OBJECT_VERSION_NUMBER%TYPE,
4001    P_USER_NAME                IN  VARCHAR2,
4002    X_RETURN_STATUS            OUT NOCOPY  VARCHAR2,
4003    X_MSG_COUNT                OUT NOCOPY  NUMBER,
4004    X_MSG_DATA                 OUT NOCOPY  VARCHAR2,
4005    P_SOURCE_MOBILE_PHONE      IN JTF_RS_RESOURCE_EXTNS.SOURCE_MOBILE_PHONE%TYPE,
4006    P_SOURCE_PAGER             IN JTF_RS_RESOURCE_EXTNS.SOURCE_PAGER%TYPE,
4007    P_FS_SETUP_COMPLETE       IN   JTF_RS_RESOURCE_EXTNS.FS_SETUP_COMPLETE%TYPE
4008   ) IS
4009 
4010     l_api_version         CONSTANT NUMBER := 1.0;
4011     l_api_name            CONSTANT VARCHAR2(30) := 'UPDATE_RESOURCE';
4012   /* Moved the initial assignment of below variables to inside begin */
4013     l_resource_id                  jtf_rs_resource_extns.resource_id%TYPE;
4014     l_managing_emp_id              jtf_rs_resource_extns.managing_employee_id%TYPE;
4015     l_start_date_active            jtf_rs_resource_extns.start_date_active%TYPE;
4016     l_end_date_active              jtf_rs_resource_extns.end_date_active%TYPE;
4017     l_time_zone                    jtf_rs_resource_extns.time_zone%TYPE;
4018     l_cost_per_hr                  jtf_rs_resource_extns.cost_per_hr%TYPE;
4019     l_primary_language             jtf_rs_resource_extns.primary_language%TYPE;
4020     l_secondary_language           jtf_rs_resource_extns.secondary_language%TYPE;
4021     l_support_site_id              jtf_rs_resource_extns.support_site_id%TYPE;
4022     l_ies_agent_login              jtf_rs_resource_extns.ies_agent_login%TYPE;
4023     l_server_group_id              jtf_rs_resource_extns.server_group_id%TYPE;
4024     l_assigned_to_group_id         jtf_rs_resource_extns.assigned_to_group_id%TYPE;
4025     l_cost_center                  jtf_rs_resource_extns.cost_center%TYPE;
4026     l_charge_to_cost_center        jtf_rs_resource_extns.charge_to_cost_center%TYPE;
4027     l_comp_currency_code           jtf_rs_resource_extns.compensation_currency_code%TYPE;
4028     l_commissionable_flag          jtf_rs_resource_extns.commissionable_flag%TYPE;
4029     l_hold_reason_code             jtf_rs_resource_extns.hold_reason_code%TYPE;
4030     l_hold_payment                 jtf_rs_resource_extns.hold_payment%TYPE;
4031     l_comp_service_team_id         jtf_rs_resource_extns.comp_service_team_id%TYPE;
4032     l_user_id                      jtf_rs_resource_extns.user_id%TYPE;
4033     --l_location                     mdsys.sdo_geometry := p_location;
4034     l_object_version_num           jtf_rs_resource_extns.object_version_number%TYPE;
4035 
4036     l_max_end_date                 DATE;
4037     l_min_start_date               DATE;
4038     l_bind_data_id                 NUMBER;
4039     l_check_flag                   VARCHAR2(1);
4040 
4041   /* Moved the initial assignment of below variables to inside begin */
4042     l_resource_name           jtf_rs_resource_extns_tl.resource_name%type;
4043     l_source_name             jtf_rs_resource_extns.source_name%type;
4044     l_source_number           jtf_rs_resource_extns.source_number%type;
4045     l_source_job_title        jtf_rs_resource_extns.source_job_title%type;
4046     l_source_email            jtf_rs_resource_extns.source_email%type;
4047     l_source_phone            jtf_rs_resource_extns.source_phone%type;
4048     l_source_org_id           number;
4049     l_source_org_name         jtf_rs_resource_extns.source_org_name%type;
4050     l_source_address1         jtf_rs_resource_extns.source_address1%type;
4051     l_source_address2         jtf_rs_resource_extns.source_address2%type;
4052     l_source_address3         jtf_rs_resource_extns.source_address3%type;
4053     l_source_address4         jtf_rs_resource_extns.source_address4%type;
4054     l_source_city             jtf_rs_resource_extns.source_city%type;
4055     l_source_postal_code      jtf_rs_resource_extns.source_postal_code%type;
4056     l_source_state            jtf_rs_resource_extns.source_state%type;
4057     l_source_province         jtf_rs_resource_extns.source_province%type;
4058     l_source_county           jtf_rs_resource_extns.source_county%type;
4059     l_source_country          jtf_rs_resource_extns.source_country%type;
4060     l_source_mgr_id           jtf_rs_resource_extns.source_mgr_id%type;
4061     l_source_mgr_name         jtf_rs_resource_extns.source_mgr_name%type;
4062     l_source_business_grp_id  jtf_rs_resource_extns.source_business_grp_id%type;
4063     l_source_business_grp_name jtf_rs_resource_extns.source_business_grp_name%type;
4064     l_source_first_name       jtf_rs_resource_extns.source_first_name%type;
4065     l_source_last_name        jtf_rs_resource_extns.source_last_name%type;
4066     l_source_middle_name      jtf_rs_resource_extns.source_middle_name%type;
4067     l_source_status           jtf_rs_resource_extns.source_status%type;
4068     l_source_office           jtf_rs_resource_extns.source_office%type;
4069     l_source_location         jtf_rs_resource_extns.source_location%type;
4070     l_source_mailstop         jtf_rs_resource_extns.source_mailstop%type;
4071     l_source_mobile_phone     jtf_rs_resource_extns.source_mobile_phone%type;
4072     l_source_pager            jtf_rs_resource_extns.source_pager%type;
4073     l_address_id              jtf_rs_resource_extns.address_id%type;
4074     l_source_category         jtf_rs_resource_extns.source_category%type;
4075     l_user_name               jtf_rs_resource_extns.user_name%type;
4076 
4077 
4078 --added for NOCOPY to handle in JTF_RESOURCE_UTL
4079     l_managing_emp_id_out          jtf_rs_resource_extns.managing_employee_id%TYPE ;
4080     l_server_group_id_out              jtf_rs_resource_extns.server_group_id%TYPE ;
4081     l_comp_service_team_id_out         jtf_rs_resource_extns.comp_service_team_id%TYPE;
4082     l_fs_setup_complete            jtf_rs_resource_extns.fs_setup_complete%type;
4083 
4084     CURSOR c_resource_update(
4085 	 l_resource_id    IN  NUMBER )
4086     IS
4087 	 SELECT
4088 	   DECODE(p_managing_emp_id, fnd_api.g_miss_num, managing_employee_id, p_managing_emp_id) managing_emp_id,
4089 	   DECODE(p_start_date_active, fnd_api.g_miss_date, start_date_active, trunc(p_start_date_active)) start_date_active,
4090 	   DECODE(p_end_date_active, fnd_api.g_miss_date, end_date_active,trunc(p_end_date_active)) end_date_active,
4091 	   DECODE(p_time_zone, fnd_api.g_miss_num, time_zone, p_time_zone) time_zone,
4092 	   DECODE(p_cost_per_hr, fnd_api.g_miss_num, cost_per_hr, p_cost_per_hr) cost_per_hr,
4093 	   DECODE(p_primary_language, fnd_api.g_miss_char, primary_language, p_primary_language) primary_language,
4094 	   DECODE(p_secondary_language, fnd_api.g_miss_char, secondary_language, p_secondary_language) secondary_language,
4095 	   DECODE(p_support_site_id, fnd_api.g_miss_num, support_site_id, p_support_site_id) support_site_id,
4096         DECODE(p_ies_agent_login, fnd_api.g_miss_char, ies_agent_login, p_ies_agent_login) ies_agent_login,
4097         DECODE(p_server_group_id, fnd_api.g_miss_num, server_group_id, p_server_group_id) server_group_id,
4098         DECODE(p_assigned_to_group_id, fnd_api.g_miss_num, assigned_to_group_id, p_assigned_to_group_id) assigned_to_group_id,
4099         DECODE(p_cost_center, fnd_api.g_miss_char, cost_center, p_cost_center) cost_center,
4100         DECODE(p_charge_to_cost_center, fnd_api.g_miss_char, charge_to_cost_center, p_charge_to_cost_center) charge_to_cost_center,
4101         DECODE(p_comp_currency_code, fnd_api.g_miss_char, compensation_currency_code, p_comp_currency_code) comp_currency_code,
4102         DECODE(p_commissionable_flag, fnd_api.g_miss_char, commissionable_flag, p_commissionable_flag) commissionable_flag,
4103         DECODE(p_hold_reason_code, fnd_api.g_miss_char, hold_reason_code, p_hold_reason_code) hold_reason_code,
4104         DECODE(p_hold_payment, fnd_api.g_miss_char, hold_payment, p_hold_payment) hold_payment,
4105         DECODE(p_comp_service_team_id, fnd_api.g_miss_num, comp_service_team_id, p_comp_service_team_id) comp_service_team_id,
4106         DECODE(p_user_id, fnd_api.g_miss_num, user_id, p_user_id) user_id,
4107         --DECODE(p_location, jtf_rs_resource_pub.g_miss_location, location, p_location) location,
4108 	   DECODE(p_attribute1, fnd_api.g_miss_char, attribute1, p_attribute1) attribute1,
4109 	   DECODE(p_attribute2, fnd_api.g_miss_char, attribute2, p_attribute2) attribute2,
4110 	   DECODE(p_attribute3, fnd_api.g_miss_char, attribute3, p_attribute3) attribute3,
4111 	   DECODE(p_attribute4, fnd_api.g_miss_char, attribute4, p_attribute4) attribute4,
4112 	   DECODE(p_attribute5, fnd_api.g_miss_char, attribute5, p_attribute5) attribute5,
4113 	   DECODE(p_attribute6, fnd_api.g_miss_char, attribute6, p_attribute6) attribute6,
4114 	   DECODE(p_attribute7, fnd_api.g_miss_char, attribute7, p_attribute7) attribute7,
4115 	   DECODE(p_attribute8, fnd_api.g_miss_char, attribute8, p_attribute8) attribute8,
4116 	   DECODE(p_attribute9, fnd_api.g_miss_char, attribute9, p_attribute9) attribute9,
4117 	   DECODE(p_attribute10, fnd_api.g_miss_char, attribute10, p_attribute10) attribute10,
4118 	   DECODE(p_attribute11, fnd_api.g_miss_char, attribute11, p_attribute11) attribute11,
4119 	   DECODE(p_attribute12, fnd_api.g_miss_char, attribute12, p_attribute12) attribute12,
4120 	   DECODE(p_attribute13, fnd_api.g_miss_char, attribute13, p_attribute13) attribute13,
4121 	   DECODE(p_attribute14, fnd_api.g_miss_char, attribute14, p_attribute14) attribute14,
4122 	   DECODE(p_attribute15, fnd_api.g_miss_char, attribute15, p_attribute15) attribute15,
4123 	   DECODE(p_attribute_category, fnd_api.g_miss_char, attribute_category, p_attribute_category) attribute_category,
4124            DECODE(p_resource_name, fnd_api.g_miss_char, resource_name, p_resource_name) resource_name,
4125            DECODE(p_source_name, fnd_api.g_miss_char, source_name, p_source_name) source_name,
4126            DECODE(p_source_number, fnd_api.g_miss_char, source_number, p_source_number) source_number,
4127            DECODE(p_source_job_title, fnd_api.g_miss_char, source_job_title, p_source_job_title) source_job_title,
4128            DECODE(p_source_email, fnd_api.g_miss_char, source_email, p_source_email) source_email,
4129            DECODE(p_source_phone, fnd_api.g_miss_char, source_phone, p_source_phone) source_phone,
4130            DECODE(p_source_org_id, fnd_api.g_miss_num, source_org_id, p_source_org_id) source_org_id,
4131            DECODE(p_source_org_name, fnd_api.g_miss_char, source_org_name, p_source_org_name) source_org_name,
4132            DECODE(p_source_address1, fnd_api.g_miss_char, source_address1, p_source_address1) source_address1,
4133            DECODE(p_source_address2, fnd_api.g_miss_char, source_address2, p_source_address2) source_address2,
4134            DECODE(p_source_address3, fnd_api.g_miss_char, source_address3, p_source_address3) source_address3,
4135            DECODE(p_source_address4, fnd_api.g_miss_char, source_address4, p_source_address4) source_address4,
4136            DECODE(p_source_city, fnd_api.g_miss_char, source_city, p_source_city) source_city,
4137            DECODE(p_source_postal_code, fnd_api.g_miss_char, source_postal_code, p_source_postal_code) source_postal_code,
4138            DECODE(p_source_state, fnd_api.g_miss_char, source_state, p_source_state) source_state,
4139            DECODE(p_source_province, fnd_api.g_miss_char, source_province, p_source_province) source_province,
4140            DECODE(p_source_county, fnd_api.g_miss_char, source_county, p_source_county) source_county,
4141            DECODE(p_source_country, fnd_api.g_miss_char, source_country, p_source_country) source_country,
4142            DECODE(p_source_mgr_id, fnd_api.g_miss_num, source_mgr_id, p_source_mgr_id) source_mgr_id,
4143            DECODE(p_source_mgr_name, fnd_api.g_miss_char, source_mgr_name, p_source_mgr_name) source_mgr_name,
4144            DECODE(p_source_business_grp_id, fnd_api.g_miss_num, source_business_grp_id, p_source_business_grp_id) source_business_grp_id,
4145            DECODE(p_source_business_grp_name, fnd_api.g_miss_char, source_business_grp_name, p_source_business_grp_name) source_business_grp_name,
4146            DECODE(p_source_first_name, fnd_api.g_miss_char, source_first_name, p_source_first_name) source_first_name,
4147            DECODE(p_source_middle_name, fnd_api.g_miss_char, source_middle_name, p_source_middle_name) source_middle_name,
4148            DECODE(p_source_last_name, fnd_api.g_miss_char, source_last_name, p_source_last_name) source_last_name,
4149            DECODE(p_source_category, fnd_api.g_miss_char, source_category, p_source_category) source_category,
4150            DECODE(p_source_status, fnd_api.g_miss_char, source_status, p_source_status) source_status,
4151            DECODE(p_source_office, fnd_api.g_miss_char, source_office, p_source_office) source_office,
4152            DECODE(p_source_location, fnd_api.g_miss_char, source_location, p_source_location) source_location,
4153            DECODE(p_source_mailstop, fnd_api.g_miss_char, source_mailstop, p_source_mailstop) source_mailstop,
4154            DECODE(p_source_mobile_phone, fnd_api.g_miss_char, source_mobile_phone, p_source_mobile_phone) source_mobile_phone,
4155            DECODE(p_source_pager, fnd_api.g_miss_char, source_pager, p_source_pager) source_pager,
4156            DECODE(p_address_id, fnd_api.g_miss_num, address_id, p_address_id) address_id,
4157            DECODE(p_user_name, fnd_api.g_miss_char, user_name, p_user_name) user_name,
4158            PERSON_PARTY_ID,
4159            SOURCE_JOB_ID,
4160 	       category,
4161 	       resource_number,
4162            source_id,
4163            contact_id,
4164 	       transaction_number,
4165            address_id old_address_id,
4166            DECODE(p_fs_setup_complete,fnd_api.g_miss_char,fs_setup_complete,p_fs_setup_complete) fs_setup_complete
4167       FROM jtf_rs_resource_extns_vl
4168       WHERE resource_id = l_resource_id;
4169 
4170     resource_rec   c_resource_update%ROWTYPE;
4171 
4172     -- Modtfying the below query for bug # 4956644
4173     -- New query logic is given in bug # 4052112
4174     -- OIC expanded the definition of compensation analyst to include any active user in the
4175     -- system regardless of their assignment to a CN responsibility.
4176     CURSOR c_assigned_to_group_id(
4177 	 l_assigned_to_group_id    IN  NUMBER)
4178     IS
4179       SELECT u.user_id
4180       FROM fnd_user u,
4181 	   jtf_rs_resource_extns r
4182       WHERE u.user_id = r.user_id
4183       AND u.user_id = l_assigned_to_group_id;
4184 
4185 
4186     CURSOR c_get_resource_info(
4187 	 l_resource_id    IN  NUMBER )
4188     IS
4189 	 SELECT start_date_active
4190       FROM jtf_rs_resource_extns
4191 	 WHERE resource_id = l_resource_id;
4192 
4193 
4194     CURSOR c_related_role_dates_first(
4195 	 l_resource_id    IN  NUMBER )
4196     IS
4197 	 SELECT min(start_date_active),
4198 	   max(end_date_active)
4199       FROM jtf_rs_role_relations
4200 	 WHERE role_resource_type = 'RS_INDIVIDUAL'
4201 	   AND role_resource_id = l_resource_id
4202 	   AND nvl(delete_flag, 'N') <> 'Y'
4203 	   AND end_date_active is not null;
4204 
4205 
4206     CURSOR c_related_role_dates_sec(
4207 	 l_resource_id    IN  NUMBER )
4208     IS
4209 	 SELECT min(start_date_active)
4210       FROM jtf_rs_role_relations
4211 	 WHERE role_resource_type = 'RS_INDIVIDUAL'
4212 	   AND role_resource_id = l_resource_id
4213 	   AND nvl(delete_flag, 'N') <> 'Y'
4214 	   AND end_date_active is null;
4215 
4216 
4217     CURSOR c_grp_mbr_role_dates_first(
4218 	 l_resource_id    IN  NUMBER )
4219     IS
4220 	 SELECT min(jrrr.start_date_active),
4221 	   max(jrrr.end_date_active)
4222       FROM jtf_rs_group_members jrgm,
4223 	   jtf_rs_role_relations jrrr
4224       WHERE jrgm.group_member_id = jrrr.role_resource_id
4225 	   AND jrrr.role_resource_type = 'RS_GROUP_MEMBER'
4226 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
4227 	   AND nvl(jrgm.delete_flag, 'N') <> 'Y'
4228 	   AND jrgm.resource_id = l_resource_id
4229 	   AND jrrr.end_date_active is not null;
4230 
4231 
4232     CURSOR c_grp_mbr_role_dates_sec(
4233 	 l_resource_id    IN  NUMBER )
4234     IS
4235 	 SELECT min(jrrr.start_date_active)
4236       FROM jtf_rs_group_members jrgm,
4237 	   jtf_rs_role_relations jrrr
4238       WHERE jrgm.group_member_id = jrrr.role_resource_id
4239 	   AND jrrr.role_resource_type = 'RS_GROUP_MEMBER'
4240 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
4241 	   AND nvl(jrgm.delete_flag, 'N') <> 'Y'
4242 	   AND jrgm.resource_id = l_resource_id
4243 	   AND jrrr.end_date_active is null;
4244 
4245 
4246     CURSOR c_team_mbr_role_dates_first(
4247 	 l_resource_id    IN  NUMBER )
4248     IS
4249 	 SELECT min(jrrr.start_date_active),
4250 	   max(jrrr.end_date_active)
4251       FROM jtf_rs_team_members jrtm,
4252 	   jtf_rs_role_relations jrrr
4253       WHERE jrtm.team_member_id = jrrr.role_resource_id
4254 	   AND jrrr.role_resource_type = 'RS_TEAM_MEMBER'
4255 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
4256 	   AND nvl(jrtm.delete_flag, 'N') <> 'Y'
4257 	   AND jrtm.team_resource_id = l_resource_id
4258 	   AND jrtm.resource_type = 'INDIVIDUAL'
4259 	   AND jrrr.end_date_active is not null;
4260 
4261 
4262     CURSOR c_team_mbr_role_dates_sec(
4263 	 l_resource_id    IN  NUMBER )
4264     IS
4265 	 SELECT min(jrrr.start_date_active)
4266       FROM jtf_rs_team_members jrtm,
4267 	   jtf_rs_role_relations jrrr
4268       WHERE jrtm.team_member_id = jrrr.role_resource_id
4269 	   AND jrrr.role_resource_type = 'RS_TEAM_MEMBER'
4270 	   AND nvl(jrrr.delete_flag, 'N') <> 'Y'
4271 	   AND nvl(jrtm.delete_flag, 'N') <> 'Y'
4272 	   AND jrtm.team_resource_id = l_resource_id
4273 	   AND jrtm.resource_type = 'INDIVIDUAL'
4274 	   AND jrrr.end_date_active is null;
4275 
4276 
4277     CURSOR c_salesrep_dates_first(
4278 	 l_resource_id    IN  NUMBER )
4279     IS
4280 	 SELECT min(start_date_active),
4281 	   max(end_date_active)
4282       FROM jtf_rs_salesreps
4283 	 WHERE resource_id = l_resource_id
4284 	   AND end_date_active is not null;
4285 
4286 
4287     CURSOR c_salesrep_dates_sec(
4288 	 l_resource_id    IN  NUMBER )
4289     IS
4290 	 SELECT min(start_date_active)
4291       FROM jtf_rs_salesreps
4292 	 WHERE resource_id = l_resource_id
4293 	   AND end_date_active is null;
4294 
4295     CURSOR c_validate_user_id(
4296          l_resource_id    IN  NUMBER,
4297          l_user_id        IN  NUMBER)
4298     IS
4299          SELECT 'Y'
4300       FROM jtf_rs_resource_extns
4301          WHERE user_id = l_user_id
4302          AND   resource_id <> l_resource_id;
4303 
4304    l_value       VARCHAR2(100);
4305    l_address_ret_status varchar2(10);
4306    l_address_found      boolean := true;
4307 
4308    l_return_status             VARCHAR2(2000);
4309    l_msg_count                 NUMBER;
4310    l_msg_data                  VARCHAR2(2000);
4311 
4312    l_resource_rec       jtf_rs_resource_pvt.resource_rec_type;
4313    l_jtf_rs_flag_name   varchar2(100);
4314   BEGIN
4315 
4316     l_resource_id                  := p_resource_id;
4317     l_managing_emp_id              := p_managing_emp_id;
4318     l_start_date_active            := trunc(p_start_date_active);
4319     l_end_date_active              := trunc(p_end_date_active);
4320     l_time_zone                    := p_time_zone;
4321     l_cost_per_hr                  := p_cost_per_hr;
4322     l_primary_language             := p_primary_language;
4323     l_secondary_language           := p_secondary_language;
4324     l_support_site_id              := p_support_site_id;
4325     l_ies_agent_login              := p_ies_agent_login;
4326     l_server_group_id              := p_server_group_id;
4327     l_assigned_to_group_id         := p_assigned_to_group_id;
4328     l_cost_center                  := p_cost_center;
4329     l_charge_to_cost_center        := p_charge_to_cost_center;
4330     l_comp_currency_code           := p_comp_currency_code;
4331     l_commissionable_flag          := p_commissionable_flag;
4332     l_hold_reason_code             := p_hold_reason_code;
4333     l_hold_payment                 := p_hold_payment;
4334     l_comp_service_team_id         := p_comp_service_team_id;
4335     l_user_id                      := p_user_id;
4336     l_object_version_num           := p_object_version_num;
4337     l_resource_name                := p_resource_name;
4338     l_source_name                  := p_source_name;
4339     l_source_number                := p_source_number;
4340     l_source_job_title             := p_source_job_title;
4341     l_source_email                 := p_source_email;
4342     l_source_phone                 := p_source_phone;
4343     l_source_org_id                := p_source_org_id;
4344     l_source_org_name              := p_source_org_name;
4345     l_source_address1              := p_source_address1;
4346     l_source_address2              := p_source_address2;
4347     l_source_address3              := p_source_address3;
4348     l_source_address4              := p_source_address4;
4349     l_source_city                  := p_source_city;
4350     l_source_postal_code           := p_source_postal_code;
4351     l_source_state                 := p_source_state;
4352     l_source_province              := p_source_province;
4353     l_source_county                := p_source_county;
4354     l_source_country               := p_source_country;
4355     l_source_mgr_id                := p_source_mgr_id;
4356     l_source_mgr_name              := p_source_mgr_name;
4357     l_source_business_grp_id       := p_source_business_grp_id;
4358     l_source_business_grp_name     := p_source_business_grp_name;
4359     l_source_first_name            := p_source_first_name;
4360     l_source_last_name             := p_source_last_name;
4361     l_source_middle_name           := p_source_middle_name;
4362     l_source_status                := p_source_status;
4363     l_source_office                := p_source_office;
4364     l_source_location              := p_source_location;
4365     l_source_mailstop              := p_source_mailstop;
4366     l_source_mobile_phone          := p_source_mobile_phone;
4367     l_source_pager                 := p_source_pager;
4368     l_address_id                   := p_address_id;
4369     l_source_category              := p_source_category;
4370     l_user_name                    := p_user_name;
4371     l_fs_setup_complete            := p_fs_setup_complete;
4372     SAVEPOINT update_resource_pvt;
4373 
4374     x_return_status := fnd_api.g_ret_sts_success;
4375 
4376 --    DBMS_OUTPUT.put_line('Started Update Resource Pvt ');
4377 
4378 
4379     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
4380 
4381       RAISE fnd_api.g_exc_unexpected_error;
4382 
4383     END IF;
4384 
4385 
4386     IF fnd_api.to_boolean(p_init_msg_list) THEN
4387 
4388       fnd_msg_pub.initialize;
4389 
4390     END IF;
4391 
4392 
4393     /* Make the pre processing call to the user hooks */
4394 
4395     /* Pre Call to the Customer Type User Hook */
4396 
4397     IF jtf_resource_utl.ok_to_execute(
4398 	 'JTF_RS_RESOURCE_PVT',
4399 	 'UPDATE_RESOURCE',
4400 	 'B',
4401 	 'C')
4402     THEN
4403     IF jtf_usr_hks.ok_to_execute(
4404 	 'JTF_RS_RESOURCE_PVT',
4405 	 'UPDATE_RESOURCE',
4406 	 'B',
4407 	 'C')
4408     THEN
4409 
4410       jtf_rs_resource_cuhk.update_resource_pre(
4411 	   p_resource_id => l_resource_id,
4412         p_managing_emp_id => l_managing_emp_id,
4413         p_start_date_active => l_start_date_active,
4414         p_end_date_active => l_end_date_active,
4415         p_time_zone => l_time_zone,
4416         p_cost_per_hr => l_cost_per_hr,
4417         p_primary_language => l_primary_language,
4418         p_secondary_language => l_secondary_language,
4419         p_support_site_id => l_support_site_id,
4420         p_ies_agent_login => l_ies_agent_login,
4421         p_server_group_id => l_server_group_id,
4422         p_assigned_to_group_id => l_assigned_to_group_id,
4423         p_cost_center => l_cost_center,
4424         p_charge_to_cost_center => l_charge_to_cost_center,
4425         p_comp_currency_code => l_comp_currency_code,
4426         p_commissionable_flag => l_commissionable_flag,
4427         p_hold_reason_code => l_hold_reason_code,
4428         p_hold_payment => l_hold_payment,
4429         p_comp_service_team_id => l_comp_service_team_id,
4430         p_user_id => l_user_id,
4431        -- p_location => l_location,
4432 	   x_return_status => x_return_status);
4433 
4434       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
4435 
4436 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
4437 
4438 
4439 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
4440 	   fnd_msg_pub.add;
4441 
4442 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
4443 		RAISE FND_API.G_EXC_ERROR;
4444 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
4445 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4446 	   END IF;
4447 
4448 
4449       END IF;
4450 
4451     END IF;
4452     END IF;
4453 
4454 
4455     /* Pre Call to the Vertical Type User Hook */
4456 
4457     IF jtf_resource_utl.ok_to_execute(
4458 	 'JTF_RS_RESOURCE_PVT',
4459 	 'UPDATE_RESOURCE',
4460 	 'B',
4461 	 'V')
4462     THEN
4463     IF jtf_usr_hks.ok_to_execute(
4464 	 'JTF_RS_RESOURCE_PVT',
4465 	 'UPDATE_RESOURCE',
4466 	 'B',
4467 	 'V')
4468     THEN
4469 
4470       jtf_rs_resource_vuhk.update_resource_pre(
4471 	   p_resource_id => l_resource_id,
4472         p_managing_emp_id => l_managing_emp_id,
4473         p_start_date_active => l_start_date_active,
4474         p_end_date_active => l_end_date_active,
4475         p_time_zone => l_time_zone,
4476         p_cost_per_hr => l_cost_per_hr,
4477         p_primary_language => l_primary_language,
4478         p_secondary_language => l_secondary_language,
4479         p_support_site_id => l_support_site_id,
4480         p_ies_agent_login => l_ies_agent_login,
4481         p_server_group_id => l_server_group_id,
4482         p_assigned_to_group_id => l_assigned_to_group_id,
4483         p_cost_center => l_cost_center,
4484         p_charge_to_cost_center => l_charge_to_cost_center,
4485         p_comp_currency_code => l_comp_currency_code,
4486         p_commissionable_flag => l_commissionable_flag,
4487         p_hold_reason_code => l_hold_reason_code,
4488         p_hold_payment => l_hold_payment,
4489         p_comp_service_team_id => l_comp_service_team_id,
4490         p_user_id => l_user_id,
4491        -- p_location => l_location,
4492 	   x_return_status => x_return_status);
4493 
4494       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
4495 
4496 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
4497 
4498 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
4499 	   fnd_msg_pub.add;
4500 
4501 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
4502 		RAISE FND_API.G_EXC_ERROR;
4503 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
4504 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4505 	   END IF;
4506 
4507 
4508       END IF;
4509 
4510     END IF;
4511     END IF;
4512 
4513 
4514     /* Pre Call to the Internal Type User Hook */
4515 
4516     IF jtf_resource_utl.ok_to_execute(
4517 	 'JTF_RS_RESOURCE_PVT',
4518 	 'UPDATE_RESOURCE',
4519 	 'B',
4520 	 'I')
4521     THEN
4522     IF jtf_usr_hks.ok_to_execute(
4523 	 'JTF_RS_RESOURCE_PVT',
4524 	 'UPDATE_RESOURCE',
4525 	 'B',
4526 	 'I')
4527     THEN
4528 
4529       jtf_rs_resource_iuhk.update_resource_pre(
4530 	   p_resource_id => l_resource_id,
4531         p_managing_emp_id => l_managing_emp_id,
4532         p_start_date_active => l_start_date_active,
4533         p_end_date_active => l_end_date_active,
4534         p_time_zone => l_time_zone,
4535         p_cost_per_hr => l_cost_per_hr,
4536         p_primary_language => l_primary_language,
4537         p_secondary_language => l_secondary_language,
4538         p_support_site_id => l_support_site_id,
4539         p_ies_agent_login => l_ies_agent_login,
4540         p_server_group_id => l_server_group_id,
4541         p_assigned_to_group_id => l_assigned_to_group_id,
4542         p_cost_center => l_cost_center,
4543         p_charge_to_cost_center => l_charge_to_cost_center,
4544         p_comp_currency_code => l_comp_currency_code,
4545         p_commissionable_flag => l_commissionable_flag,
4546         p_hold_reason_code => l_hold_reason_code,
4547         p_hold_payment => l_hold_payment,
4548         p_comp_service_team_id => l_comp_service_team_id,
4549         p_user_id => l_user_id,
4550         --p_location => l_location,
4551 	   x_return_status => x_return_status);
4552 
4553       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
4554 
4555 
4556 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
4557 	   fnd_msg_pub.add;
4558 
4559 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
4560 		RAISE FND_API.G_EXC_ERROR;
4561 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
4562 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4563 	   END IF;
4564 
4565 
4566       END IF;
4567 
4568     END IF;
4569     END IF;
4570 
4571 
4572     OPEN c_resource_update(l_resource_id);
4573 
4574     FETCH c_resource_update INTO resource_rec;
4575 
4576 
4577     IF c_resource_update%NOTFOUND THEN
4578 
4579       IF c_resource_update%ISOPEN THEN
4580 
4581         CLOSE c_resource_update;
4582 
4583       END IF;
4584 
4585       fnd_message.set_name('JTF', 'JTF_RS_INVALID_RESOURCE');
4586 	 fnd_message.set_token('P_RESOURCE_ID', l_resource_id);
4587       fnd_msg_pub.add;
4588 
4589       RAISE fnd_api.g_exc_error;
4590 
4591 
4592     END IF;
4593 
4594 
4595 
4596     /* Validate the Managing Employee Id if specified */
4597 
4598     IF l_managing_emp_id <> fnd_api.g_miss_num THEN
4599 
4600       jtf_resource_utl.validate_employee_resource(
4601         p_emp_resource_id => l_managing_emp_id,
4602         p_emp_resource_number => null,
4603         x_return_status => x_return_status,
4604         x_emp_resource_id => l_managing_emp_id_out
4605       );
4606 
4607 -- added for NOCOPY
4608       l_managing_emp_id := l_managing_emp_id_out;
4609 
4610       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
4611 
4612 	 IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
4613 	      RAISE FND_API.G_EXC_ERROR;
4614 	 ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
4615 	      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4616 	 END IF;
4617 
4618 
4619       END IF;
4620 
4621     END IF;
4622 
4623 
4624 
4625     /* Validate the Input Dates */
4626 
4627     IF l_start_date_active <> fnd_api.g_miss_date OR
4628 	  l_end_date_active <> fnd_api.g_miss_date THEN
4629 
4630     -- Code changes to fix bug 4171623. (G_MISS_DATE DOESN'T WORK PROPERLY ON JTF_RS_RESOURCE_PUB).
4631 
4632     -- Changing the values being passed to "validate_input_dates" procedure,
4633     -- from l_end_date_active to resource_rec.end_date_active (same for start date)
4634     -- so that it validates the correct dates which its supposed to validate.
4635 
4636       jtf_resource_utl.validate_input_dates(
4637         p_start_date_active => resource_rec.start_date_active,
4638         p_end_date_active => resource_rec.end_date_active,
4639         x_return_status => x_return_status
4640       );
4641 
4642       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
4643 
4644 	 IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
4645 	      RAISE FND_API.G_EXC_ERROR;
4646 	 ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
4647 	      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4648 	 END IF;
4649 
4650 
4651       END IF;
4652 
4653     END IF;
4654 
4655 
4656     /* Validate that the resource dates cover the role related dates for the resource */
4657 
4658     /* First part of the validation where the role relate end date active is not null */
4659 
4660     OPEN c_related_role_dates_first(l_resource_id);
4661 
4662     FETCH c_related_role_dates_first INTO l_min_start_date, l_max_end_date;
4663 
4664 
4665     IF l_min_start_date IS NOT NULL THEN
4666 
4667       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4668          l_min_start_date < l_start_date_active THEN
4669 
4670         /* Resource Start Date out of range for the role related start dates of the resource */
4671 
4672         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_START_DATE');
4673         fnd_msg_pub.add;
4674 
4675         RAISE fnd_api.g_exc_error;
4676 
4677 
4678       END IF;
4679 
4680       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
4681            l_max_end_date > l_end_date_active AND
4682            l_end_date_active IS NOT NULL ) THEN
4683 
4684         /* Resource End Date out of range for the role related End dates of the Resource */
4685 
4686         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_END_DATE');
4687         fnd_msg_pub.add;
4688 
4689         RAISE fnd_api.g_exc_error;
4690 
4691 
4692       END IF;
4693 
4694     END IF;
4695 
4696 
4697     /* Close the cursor */
4698 
4699     IF c_related_role_dates_first%ISOPEN THEN
4700 
4701       CLOSE c_related_role_dates_first;
4702 
4703     END IF;
4704 
4705 
4706 
4707     /* Second part of the validation where the role relate end date active is null */
4708 
4709     OPEN c_related_role_dates_sec(l_resource_id);
4710 
4711     FETCH c_related_role_dates_sec INTO l_min_start_date;
4712 
4713 
4714     IF l_min_start_date IS NOT NULL THEN
4715 
4716       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4717          l_min_start_date < l_start_date_active THEN
4718 
4719         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_START_DATE');
4720         fnd_msg_pub.add;
4721 
4722         RAISE fnd_api.g_exc_error;
4723 
4724 
4725       END IF;
4726 
4727       IF l_end_date_active <> FND_API.G_MISS_DATE AND
4728          l_end_date_active IS NOT NULL THEN
4729 
4730         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_ROLE_END_DATE');
4731         fnd_msg_pub.add;
4732 
4733         RAISE fnd_api.g_exc_error;
4734 
4735 
4736       END IF;
4737 
4738     END IF;
4739 
4740     /* Close the cursor */
4741 
4742     IF c_related_role_dates_sec%ISOPEN THEN
4743 
4744       CLOSE c_related_role_dates_sec;
4745 
4746     END IF;
4747 
4748 
4749     /* Validate that the resource dates cover the group member role related dates for the resource */
4750 
4751     /* First part of the validation where the group member role relate end date active is not null */
4752 
4753     OPEN c_grp_mbr_role_dates_first(l_resource_id);
4754 
4755     FETCH c_grp_mbr_role_dates_first INTO l_min_start_date, l_max_end_date;
4756 
4757 
4758     IF l_min_start_date IS NOT NULL THEN
4759 
4760       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4761          l_min_start_date < l_start_date_active THEN
4762 
4763         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_START_DATE');
4764         fnd_msg_pub.add;
4765 
4766         RAISE fnd_api.g_exc_error;
4767 
4768 
4769       END IF;
4770 
4771       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
4772            l_max_end_date > l_end_date_active AND
4773            l_end_date_active IS NOT NULL ) THEN
4774 
4775         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_END_DATE');
4776         fnd_msg_pub.add;
4777 
4778         RAISE fnd_api.g_exc_error;
4779 
4780 
4781       END IF;
4782 
4783     END IF;
4784 
4785 
4786     /* Close the cursor */
4787 
4788     IF c_grp_mbr_role_dates_first%ISOPEN THEN
4789 
4790       CLOSE c_grp_mbr_role_dates_first;
4791 
4792     END IF;
4793 
4794 
4795 
4796     /* Second part of the validation where the member role relate end date active is null */
4797 
4798     OPEN c_grp_mbr_role_dates_sec(l_resource_id);
4799 
4800     FETCH c_grp_mbr_role_dates_sec INTO l_min_start_date;
4801 
4802 
4803     IF l_min_start_date IS NOT NULL THEN
4804 
4805       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4806          l_min_start_date < l_start_date_active THEN
4807 
4808         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_START_DATE');
4809         fnd_msg_pub.add;
4810 
4811         RAISE fnd_api.g_exc_error;
4812 
4813 
4814       END IF;
4815 
4816       IF l_end_date_active <> FND_API.G_MISS_DATE AND
4817          l_end_date_active IS NOT NULL THEN
4818 
4819         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_GMBR_END_DATE');
4820         fnd_msg_pub.add;
4821 
4822         RAISE fnd_api.g_exc_error;
4823 
4824 
4825       END IF;
4826 
4827     END IF;
4828 
4829     /* Close the cursor */
4830 
4831     IF c_grp_mbr_role_dates_sec%ISOPEN THEN
4832 
4833       CLOSE c_grp_mbr_role_dates_sec;
4834 
4835     END IF;
4836 
4837 
4838 
4839     /* Validate that the resource dates cover the team member role related dates for the
4840 	  resource, where the team member is a resource */
4841 
4842     /* First part of the validation where the team member role relate end date active
4843 	  is not null */
4844 
4845     OPEN c_team_mbr_role_dates_first(l_resource_id);
4846 
4847     FETCH c_team_mbr_role_dates_first INTO l_min_start_date, l_max_end_date;
4848 
4849 
4850     IF l_min_start_date IS NOT NULL THEN
4851 
4852       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4853          l_min_start_date < l_start_date_active THEN
4854 
4855         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_START_DATE');
4856         fnd_msg_pub.add;
4857 
4858         RAISE fnd_api.g_exc_error;
4859 
4860 
4861       END IF;
4862 
4863       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
4864            l_max_end_date > l_end_date_active AND
4865            l_end_date_active IS NOT NULL ) THEN
4866 
4867         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_END_DATE');
4868         fnd_msg_pub.add;
4869 
4870         RAISE fnd_api.g_exc_error;
4871 
4872 
4873       END IF;
4874 
4875     END IF;
4876 
4877 
4878     /* Close the cursor */
4879 
4880     IF c_team_mbr_role_dates_first%ISOPEN THEN
4881 
4882       CLOSE c_team_mbr_role_dates_first;
4883 
4884     END IF;
4885 
4886 
4887     /* Second part of the validation where the member role relate end date active is null */
4888 
4889     OPEN c_team_mbr_role_dates_sec(l_resource_id);
4890 
4891     FETCH c_team_mbr_role_dates_sec INTO l_min_start_date;
4892 
4893 
4894     IF l_min_start_date IS NOT NULL THEN
4895 
4896       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4897          l_min_start_date < l_start_date_active THEN
4898 
4899         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_START_DATE');
4900         fnd_msg_pub.add;
4901 
4902         RAISE fnd_api.g_exc_error;
4903 
4904 
4905       END IF;
4906 
4907       IF l_end_date_active <> FND_API.G_MISS_DATE AND
4908          l_end_date_active IS NOT NULL THEN
4909 
4910         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_TMBR_END_DATE');
4911         fnd_msg_pub.add;
4912 
4913         RAISE fnd_api.g_exc_error;
4914 
4915 
4916       END IF;
4917 
4918     END IF;
4919 
4920 
4921     /* Close the cursor */
4922 
4923     IF c_team_mbr_role_dates_sec%ISOPEN THEN
4924 
4925       CLOSE c_team_mbr_role_dates_sec;
4926 
4927     END IF;
4928 
4929 
4930 
4931     /* Validate that the resource dates cover the salesrep related dates for the resource */
4932 
4933     /* First part of the validation where the salesrep end date active is not null */
4934 
4935     OPEN c_salesrep_dates_first(l_resource_id);
4936 
4937     FETCH c_salesrep_dates_first INTO l_min_start_date, l_max_end_date;
4938 
4939 
4940     IF l_min_start_date IS NOT NULL THEN
4941 
4942       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4943          l_min_start_date < l_start_date_active THEN
4944 
4945         /* Resource Start Date out of range for the salesrep related start dates of the resource */
4946 
4947         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_START_DATE');
4948         fnd_msg_pub.add;
4949 
4950         RAISE fnd_api.g_exc_error;
4951 
4952       END IF;
4953 
4954       IF ( l_end_date_active <> FND_API.G_MISS_DATE AND
4955            l_max_end_date > l_end_date_active AND
4956            l_end_date_active IS NOT NULL ) THEN
4957 
4958         /* Resource End Date out of range for the salesrep related End dates of the Resource */
4959 
4960         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_END_DATE');
4961         fnd_msg_pub.add;
4962 
4963         RAISE fnd_api.g_exc_error;
4964 
4965 
4966       END IF;
4967 
4968     END IF;
4969 
4970 
4971     /* Close the cursor */
4972 
4973     IF c_salesrep_dates_first%ISOPEN THEN
4974 
4975       CLOSE c_salesrep_dates_first;
4976 
4977     END IF;
4978 
4979 
4980 
4981     /* Second part of the validation where the role relate end date active
4982 	  is null */
4983 
4984     OPEN c_salesrep_dates_sec(l_resource_id);
4985 
4986     FETCH c_salesrep_dates_sec INTO l_min_start_date;
4987 
4988 
4989     IF l_min_start_date IS NOT NULL THEN
4990 
4991       IF l_start_date_active <> FND_API.G_MISS_DATE AND
4992          l_min_start_date < l_start_date_active THEN
4993 
4994         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_START_DATE');
4995         fnd_msg_pub.add;
4996 
4997         RAISE fnd_api.g_exc_error;
4998 
4999 
5000       END IF;
5001 
5002       IF l_end_date_active <> FND_API.G_MISS_DATE AND
5003          l_end_date_active IS NOT NULL THEN
5004 
5005         fnd_message.set_name('JTF', 'JTF_RS_ERR_RES_SRP_END_DATE');
5006         fnd_msg_pub.add;
5007 
5008         RAISE fnd_api.g_exc_error;
5009 
5010 
5011       END IF;
5012 
5013     END IF;
5014 
5015     /* Close the cursor */
5016 
5017     IF c_salesrep_dates_sec%ISOPEN THEN
5018 
5019       CLOSE c_salesrep_dates_sec;
5020 
5021     END IF;
5022 
5023 
5024 
5025     /* Validate the Time Zone */
5026 
5027     IF l_time_zone <> fnd_api.g_miss_num THEN
5028 
5029       IF l_time_zone IS NOT NULL THEN
5030 
5031         jtf_resource_utl.validate_time_zone(
5032           p_time_zone_id => l_time_zone,
5033           x_return_status => x_return_status
5034         );
5035 
5036         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5037 
5038 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5039 	       RAISE FND_API.G_EXC_ERROR;
5040 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5041 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5042 	  END IF;
5043 
5044 
5045         END IF;
5046 
5047       END IF;
5048 
5049     END IF;
5050 
5051 
5052 
5053     /* Validate the Primary Language */
5054 
5055     IF l_primary_language <> fnd_api.g_miss_char THEN
5056 
5057       IF l_primary_language IS NOT NULL THEN
5058 
5059         jtf_resource_utl.validate_nls_language(
5060           p_nls_language => l_primary_language,
5061           x_return_status => x_return_status
5062         );
5063 
5064         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5065 
5066 	    IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5067 		 RAISE FND_API.G_EXC_ERROR;
5068 	    ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5069 		 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5070 	    END IF;
5071 
5072 
5073         END IF;
5074 
5075       END IF;
5076 
5077     END IF;
5078 
5079 
5080 
5081     /* Validate the Secondary Language */
5082 
5083     IF l_secondary_language <> fnd_api.g_miss_char THEN
5084 
5085       IF l_secondary_language IS NOT NULL THEN
5086 
5087         jtf_resource_utl.validate_nls_language(
5088           p_nls_language => l_secondary_language,
5089           x_return_status => x_return_status
5090         );
5091 
5092         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5093 
5094 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5095 		RAISE FND_API.G_EXC_ERROR;
5096 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5097 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5098 	   END IF;
5099 
5100 
5101         END IF;
5102 
5103       END IF;
5104 
5105     END IF;
5106 
5107 
5108 
5109     /* Validate the Support Site */
5110 
5111     IF l_support_site_id <> fnd_api.g_miss_num THEN
5112 
5113       IF l_support_site_id IS NOT NULL THEN
5114 
5115         jtf_resource_utl.validate_support_site_id(
5116           p_support_site_id => l_support_site_id,
5117           x_return_status => x_return_status
5118         );
5119 
5120         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5121 
5122 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5123 		RAISE FND_API.G_EXC_ERROR;
5124 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5125 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5126 	   END IF;
5127 
5128 
5129         END IF;
5130 
5131       END IF;
5132 
5133     END IF;
5134 
5135 
5136 
5137     /* Validate the Server Group. */
5138 
5139     IF l_server_group_id <> fnd_api.g_miss_num THEN
5140 
5141       jtf_resource_utl.validate_server_group(
5142         p_server_group_id => l_server_group_id,
5143         p_server_group_name => null,
5144         x_return_status => x_return_status,
5145         x_server_group_id => l_server_group_id_out
5146       );
5147 
5148 -- added for NOCOPY
5149       l_server_group_id := l_server_group_id_out;
5150 
5151       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5152 
5153 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5154 		RAISE FND_API.G_EXC_ERROR;
5155 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5156 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5157 	   END IF;
5158 
5159 
5160       END IF;
5161 
5162     END IF;
5163 
5164 
5165 
5166     /* Validate the assigned_to_group_id if specified */
5167 
5168     IF l_assigned_to_group_id <> fnd_api.g_miss_num THEN
5169 
5170       IF l_assigned_to_group_id IS NOT NULL THEN
5171 
5172         OPEN c_assigned_to_group_id(l_assigned_to_group_id);
5173 
5174         FETCH c_assigned_to_group_id INTO l_assigned_to_group_id;
5175 
5176 
5177         IF c_assigned_to_group_id%NOTFOUND THEN
5178 
5179 --          dbms_output.put_line('Invalid Assigned To Group Id');
5180 
5181           fnd_message.set_name('JTF', 'JTF_RS_ERR_ASSIGN_TO_GRP_ID');
5182           fnd_message.set_token('P_ASSIGNED_TO_GROUP_ID', l_assigned_to_group_id);
5183           fnd_msg_pub.add;
5184 
5185           RAISE fnd_api.g_exc_error;
5186 
5187 
5188         END IF;
5189 
5190 
5191         /* Close the cursor */
5192 
5193         IF c_assigned_to_group_id%ISOPEN THEN
5194 
5195           CLOSE c_assigned_to_group_id;
5196 
5197         END IF;
5198 
5199       END IF;
5200 
5201     END IF;
5202 
5203 
5204 
5205     /* Validate the Comp Currency Code */
5206 
5207     IF l_comp_currency_code <> fnd_api.g_miss_char THEN
5208 
5209       IF l_comp_currency_code IS NOT NULL THEN
5210 
5211         jtf_resource_utl.validate_currency_code(
5212           p_currency_code => l_comp_currency_code,
5213           x_return_status => x_return_status
5214         );
5215 
5216         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5217 
5218 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5219 		RAISE FND_API.G_EXC_ERROR;
5220 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5221 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5222 	   END IF;
5223 
5224 
5225         END IF;
5226 
5227       END IF;
5228 
5229     END IF;
5230 
5231 
5232 
5233     /* Validate the value of the commisionable flag */
5234 
5235     IF l_commissionable_flag <> fnd_api.g_miss_char THEN
5236 
5237       IF l_commissionable_flag <> 'Y' AND l_commissionable_flag <> 'N' THEN
5238 
5239 --	   dbms_output.put_line('Commissionable Flag should either be ''Y'' or ''N'' ');
5240 
5241         fnd_message.set_name('JTF', 'JTF_RS_INVALID_FLAG_VALUE');
5242         fnd_msg_pub.add;
5243 
5244         RAISE fnd_api.g_exc_error;
5245 
5246 
5247       END IF;
5248 
5249     END IF;
5250 
5251 
5252 
5253     /* Validate the value of the Hold Payment flag */
5254 
5255     IF l_hold_payment <> fnd_api.g_miss_char THEN
5256 
5257       IF l_hold_payment <> 'Y' AND l_hold_payment <> 'N' THEN
5258 
5259 --	   dbms_output.put_line('Hold Payment should either be ''Y'' or ''N'' ');
5260 
5261         fnd_message.set_name('JTF', 'JTF_RS_INVALID_FLAG_VALUE');
5262         fnd_msg_pub.add;
5263 
5264         RAISE fnd_api.g_exc_error;
5265 
5266 
5267       END IF;
5268 
5269     END IF;
5270 
5271 
5272 
5273     /* Validate the Hold Reason Code */
5274 
5275     IF l_hold_reason_code <> fnd_api.g_miss_char THEN
5276 
5277       IF l_hold_reason_code IS NOT NULL THEN
5278 
5279         jtf_resource_utl.validate_hold_reason_code(
5280           p_hold_reason_code => l_hold_reason_code,
5281           x_return_status => x_return_status
5282         );
5283 
5284         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5285 
5286 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5287 		RAISE FND_API.G_EXC_ERROR;
5288 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5289 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5290 	   END IF;
5291 
5292 
5293         END IF;
5294 
5295       END IF;
5296 
5297     END IF;
5298 
5299 
5300     /* Validate that the user_id should only be specified in case of
5301 	  'EMPLOYEE', 'PARTY', 'SUPPLIER_CONTACT' categories */
5302 
5303     IF l_user_id <> fnd_api.g_miss_num THEN
5304 
5305       IF resource_rec.category NOT IN ('EMPLOYEE', 'PARTY', 'SUPPLIER_CONTACT') AND l_user_id IS NOT NULL THEN
5306 
5307         fnd_message.set_name('JTF', 'JTF_RS_USERID_ERROR');
5308         fnd_msg_pub.add;
5309 
5310         RAISE fnd_api.g_exc_error;
5311 
5312 
5313 	 END IF;
5314 
5315     END IF;
5316 
5317 
5318     IF l_user_id <> fnd_api.g_miss_num THEN
5319 
5320       /* Validate the User Id if specified */
5321 
5322       IF l_user_id IS NOT NULL THEN
5323 
5324         jtf_resource_utl.validate_user_id(
5325           p_user_id => l_user_id,
5326           p_category => resource_rec.category,
5327           p_source_id => resource_rec.source_id,
5328           x_return_status => x_return_status
5329         );
5330 
5331         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5332 
5333 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5334 	       RAISE FND_API.G_EXC_ERROR;
5335 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5336 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5337 	  END IF;
5338 
5339         else
5340 
5341         OPEN c_validate_user_id(l_resource_id,l_user_id);
5342 
5343         FETCH c_validate_user_id INTO l_check_flag
5344 ;
5345 
5346 
5347         IF c_validate_user_id%FOUND THEN
5348 
5349 --          dbms_output.put_line('duplicate user Id');
5350 
5351           fnd_message.set_name('JTF', 'JTF_RS_ERR_DUPLICATE_USER_ID');
5352           fnd_message.set_token('P_USER_ID', l_user_id);
5353           fnd_msg_pub.add;
5354 
5355           RAISE fnd_api.g_exc_error;
5356 
5357 
5358         END IF;
5359 
5360 
5361         /* Close the cursor */
5362 
5363         CLOSE c_validate_user_id;
5364 
5365 
5366 
5367         END IF;
5368 
5369       END IF;
5370 
5371     END IF;
5372 
5373 
5374     /* Validate the Comp Service Team Id if specified */
5375 
5376     IF l_comp_service_team_id <> fnd_api.g_miss_num THEN
5377 
5378       IF l_comp_service_team_id IS NOT NULL THEN
5379 
5380         jtf_resource_utl.validate_resource_team(
5381           p_team_id => l_comp_service_team_id,
5382           p_team_number => null,
5383           x_return_status => x_return_status,
5384           x_team_id => l_comp_service_team_id_out
5385         );
5386 -- added for NOCOPY
5387         l_comp_service_team_id := l_comp_service_team_id_out;
5388 
5389         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5390 
5391 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5392 	       RAISE FND_API.G_EXC_ERROR;
5393 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5394 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5395 	  END IF;
5396 
5397 
5398         END IF;
5399 
5400       END IF;
5401 
5402     END IF;
5403 
5404      if(resource_rec.category IN  ('PARTNER', 'PARTY'))
5405      THEN
5406        if(p_address_id <> fnd_api.g_miss_num)
5407        then
5408          if (nvl(p_address_id, fnd_api.g_miss_num) <> nvl(resource_rec.old_address_id, fnd_api.g_miss_num))
5409          then
5410              validate_party_address(p_source_id => resource_rec.source_id,
5411                             p_address_id => resource_rec.address_id,
5412                             p_action => 'U',
5413                             p_found  => l_address_found,
5414                             p_return_status => l_address_ret_status);
5415 
5416           if(l_address_ret_status <> fnd_api.g_ret_sts_success)
5417           then
5418 	    IF L_ADDRESS_RET_STATUS = FND_API.G_RET_STS_ERROR THEN
5419 		 RAISE FND_API.G_EXC_ERROR;
5420 	    ELSIF L_ADDRESS_RET_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5421 		 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5422 	    END IF;
5423 
5424           end if;
5425 
5426          if not(l_address_found)
5427          then
5428             fnd_message.set_name('JTF', 'JTF_RS_NOT_PRIMARY_ADDR');
5429             fnd_msg_pub.add;
5430             RAISE fnd_api.g_exc_error;
5431 
5432          end if;
5433         end if; -- end of nvl check
5434       end if; -- end of f_miss_num check
5435      END IF;
5436 
5437       /* Validate the FS Setup Complete Flat if specified */
5438      IF l_fs_setup_complete <> fnd_api.g_miss_char AND l_fs_setup_complete IS NOT NULL THEN
5439 
5440           IF ( l_fs_setup_complete <> 'Y' and l_fs_setup_complete <>'N') THEN
5441               l_jtf_rs_flag_name := 'FS Setup Complete Flag';
5442               fnd_message.set_name('JTF', 'JTF_RS_YES_NO');
5443               fnd_message.set_token('JTF_RS_FLAG', l_jtf_rs_flag_name);
5444               fnd_msg_pub.add;
5445 
5446               RAISE fnd_api.g_exc_error;
5447           END IF;
5448      END IF;
5449 
5450 
5451 
5452 
5453     /* Call the lock row procedure to ensure that the object version number
5454 	  is still valid. */
5455 
5456     BEGIN
5457 
5458       jtf_rs_resource_extns_pkg.lock_row(
5459         x_resource_id => l_resource_id,
5460 	   x_object_version_number => p_object_version_num
5461       );
5462 
5463     EXCEPTION
5464 
5465 	 WHEN OTHERS THEN
5466 
5467 --	   dbms_output.put_line('Error in Locking the Row');
5468 
5469 
5470 	   fnd_message.set_name('JTF', 'JTF_RS_ROW_LOCK_ERROR');
5471 	   fnd_msg_pub.add;
5472 
5473            RAISE fnd_api.g_exc_error;
5474 
5475 
5476     END;
5477 
5478 
5479     /* Make a call to the Resource Audit API */
5480 
5481     jtf_rs_resource_extns_aud_pvt.update_resource
5482     (P_API_VERSION => 1,
5483      P_INIT_MSG_LIST => fnd_api.g_false,
5484      P_COMMIT => fnd_api.g_false,
5485      P_RESOURCE_ID => l_resource_id,
5486      P_RESOURCE_NUMBER => resource_rec.resource_number,
5487      P_CATEGORY => resource_rec.category,
5488      P_SOURCE_ID => resource_rec.source_id,
5489      P_ADDRESS_ID => resource_rec.address_id,
5490      P_CONTACT_ID => resource_rec.contact_id,
5491      P_MANAGING_EMP_ID => resource_rec.managing_emp_id,
5492      P_START_DATE_ACTIVE => resource_rec.start_date_active,
5493      P_END_DATE_ACTIVE => resource_rec.end_date_active,
5494      P_TIME_ZONE => resource_rec.time_zone,
5495      P_COST_PER_HR => resource_rec.cost_per_hr,
5496      P_PRIMARY_LANGUAGE => resource_rec.primary_language,
5497      P_SECONDARY_LANGUAGE => resource_rec.secondary_language,
5498      P_SUPPORT_SITE_ID => resource_rec.support_site_id,
5499      P_IES_AGENT_LOGIN => resource_rec.ies_agent_login,
5500      P_SERVER_GROUP_ID => resource_rec.server_group_id,
5501      P_ASSIGNED_TO_GROUP_ID => resource_rec.assigned_to_group_id,
5502      P_COST_CENTER => resource_rec.cost_center,
5503      P_CHARGE_TO_COST_CENTER => resource_rec.charge_to_cost_center,
5504      P_COMP_CURRENCY_CODE => resource_rec.comp_currency_code,
5505      P_COMMISSIONABLE_FLAG => resource_rec.commissionable_flag,
5506      P_HOLD_REASON_CODE => resource_rec.hold_reason_code,
5507      P_HOLD_PAYMENT => resource_rec.hold_payment,
5508      P_COMP_SERVICE_TEAM_ID => resource_rec.comp_service_team_id,
5509      P_USER_ID => resource_rec.user_id,
5510      P_TRANSACTION_NUMBER => resource_rec.transaction_number,
5511     -- P_LOCATION => resource_rec.location,
5512       P_OBJECT_VERSION_NUMBER => p_object_version_num + 1,
5513       P_RESOURCE_NAME => resource_rec.RESOURCE_NAME ,
5514       P_SOURCE_NAME => resource_rec.SOURCE_NAME ,
5515       P_SOURCE_NUMBER => resource_rec.SOURCE_NUMBER ,
5516       P_SOURCE_JOB_TITLE  => resource_rec.SOURCE_JOB_TITLE  ,
5517       P_SOURCE_EMAIL  => resource_rec.SOURCE_EMAIL  ,
5518       P_SOURCE_PHONE  => resource_rec.SOURCE_PHONE  ,
5519       P_SOURCE_ORG_ID => resource_rec.SOURCE_ORG_ID ,
5520       P_SOURCE_ORG_NAME => resource_rec.SOURCE_ORG_NAME ,
5521       P_SOURCE_ADDRESS1 => resource_rec.SOURCE_ADDRESS1 ,
5522       P_SOURCE_ADDRESS2 => resource_rec.SOURCE_ADDRESS2 ,
5523       P_SOURCE_ADDRESS3 => resource_rec.SOURCE_ADDRESS3 ,
5524       P_SOURCE_ADDRESS4 => resource_rec.SOURCE_ADDRESS4 ,
5525       P_SOURCE_CITY => resource_rec.SOURCE_CITY ,
5526       P_SOURCE_POSTAL_CODE  => resource_rec.SOURCE_POSTAL_CODE  ,
5527       P_SOURCE_STATE  => resource_rec.SOURCE_STATE  ,
5528       P_SOURCE_PROVINCE => resource_rec.SOURCE_PROVINCE ,
5529       P_SOURCE_COUNTY => resource_rec.SOURCE_COUNTY ,
5530       P_SOURCE_COUNTRY  => resource_rec.SOURCE_COUNTRY  ,
5531       P_SOURCE_MGR_ID => resource_rec.SOURCE_MGR_ID ,
5532       P_SOURCE_MGR_NAME => resource_rec.SOURCE_MGR_NAME ,
5533       P_SOURCE_BUSINESS_GRP_ID  => resource_rec.SOURCE_BUSINESS_GRP_ID  ,
5534       P_SOURCE_BUSINESS_GRP_NAME => resource_rec.SOURCE_BUSINESS_GRP_NAME ,
5535       P_SOURCE_FIRST_NAME => resource_rec.SOURCE_FIRST_NAME ,
5536       P_SOURCE_MIDDLE_NAME => resource_rec.SOURCE_MIDDLE_NAME ,
5537       P_SOURCE_LAST_NAME => resource_rec.SOURCE_LAST_NAME ,
5538       P_SOURCE_CATEGORY => resource_rec.SOURCE_CATEGORY ,
5539       P_SOURCE_STATUS => resource_rec.SOURCE_STATUS ,
5540       P_SOURCE_OFFICE => resource_rec.SOURCE_OFFICE ,
5541       P_SOURCE_LOCATION => resource_rec.SOURCE_LOCATION ,
5542       P_SOURCE_MAILSTOP => resource_rec.SOURCE_MAILSTOP ,
5543       X_RETURN_STATUS => x_return_status,
5544       X_MSG_COUNT => x_msg_count,
5545       X_MSG_DATA => x_msg_data,
5546       P_SOURCE_MOBILE_PHONE => resource_rec.SOURCE_MOBILE_PHONE ,
5547       P_SOURCE_PAGER => resource_rec.SOURCE_PAGER,
5548       P_USER_NAME => resource_rec.USER_NAME,
5549       P_FS_SETUP_COMPLETE => resource_rec.fs_setup_complete
5550     );
5551 
5552     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5553 
5554 --	 dbms_output.put_line('Failed status from call to audit procedure');
5555 
5556       IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5557 	   RAISE FND_API.G_EXC_ERROR;
5558       ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5559 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5560       END IF;
5561 
5562     END IF;
5563 
5564 /* Calling publish API to raise update resource event. */
5565 /* added by baianand on 11/04/2002 */
5566 
5567     begin
5568 
5569        l_resource_rec.resource_id                := l_resource_id;
5570        l_resource_rec.category                   := resource_rec.category;
5571        l_resource_rec.user_id                    := resource_rec.user_id;
5572        l_resource_rec.resource_name              := resource_rec.resource_name;
5573        l_resource_rec.start_date_active          := resource_rec.start_date_active;
5574        l_resource_rec.end_date_active            := resource_rec.end_date_active;
5575        l_resource_rec.time_zone                  := resource_rec.time_zone;
5576        l_resource_rec.cost_per_hr                := resource_rec.cost_per_hr;
5577        l_resource_rec.primary_language           := resource_rec.primary_language;
5578        l_resource_rec.secondary_language         := resource_rec.secondary_language;
5579        l_resource_rec.ies_agent_login            := resource_rec.ies_agent_login;
5580        l_resource_rec.server_group_id            := resource_rec.server_group_id;
5581        l_resource_rec.assigned_to_group_id       := resource_rec.assigned_to_group_id;
5582        l_resource_rec.cost_center                := resource_rec.cost_center;
5583        l_resource_rec.charge_to_cost_center      := resource_rec.charge_to_cost_center;
5584        l_resource_rec.comp_currency_code         := resource_rec.comp_currency_code;
5585        l_resource_rec.commissionable_flag        := resource_rec.commissionable_flag;
5586        l_resource_rec.hold_reason_code           := resource_rec.hold_reason_code;
5587        l_resource_rec.hold_payment               := resource_rec.hold_payment;
5588        l_resource_rec.comp_service_team_id       := resource_rec.comp_service_team_id;
5589        l_resource_rec.support_site_id            := resource_rec.support_site_id;
5590 
5591        jtf_rs_wf_events_pub.update_resource
5592               (p_api_version               => 1.0
5593               ,p_init_msg_list             => fnd_api.g_false
5594               ,p_commit                    => fnd_api.g_false
5595               ,p_resource_rec              => l_resource_rec
5596               ,x_return_status             => l_return_status
5597               ,x_msg_count                 => l_msg_count
5598               ,x_msg_data                  => l_msg_data);
5599 
5600     EXCEPTION when others then
5601        null;
5602     end;
5603 
5604 /* End of publish API call */
5605 
5606 
5607   /* Calling work API for insert/update record into wf_local tables. */
5608   /* added by baianand on 08/15/2002 */
5609 
5610       begin
5611          jtf_rs_wf_integration_pub.update_resource
5612                 (p_api_version               => 1.0
5613                 ,p_init_msg_list             => fnd_api.g_false
5614                 ,p_commit                    => fnd_api.g_false
5615                 ,p_resource_id               => l_resource_id
5616                 ,p_resource_name             => resource_rec.resource_name
5617                 ,p_user_id                   => resource_rec.user_id
5618                 ,p_email_address             => resource_rec.source_email
5619                 ,p_start_date_active         => resource_rec.start_date_active
5620                 ,p_end_date_active           => resource_rec.end_date_active
5621                 ,x_return_status             => l_return_status
5622                 ,x_msg_count                 => l_msg_count
5623                 ,x_msg_data                  => l_msg_data);
5624 
5625       EXCEPTION when others then
5626          null;
5627       end;
5628 
5629   /* End of work API call */
5630 
5631     BEGIN
5632 
5633       /* Increment the object version number */
5634 
5635 	 l_object_version_num := p_object_version_num + 1;
5636 
5637 
5638       /* Update the row into the table by calling the table handler. */
5639 
5640       jtf_rs_resource_extns_pkg.update_row(
5641         x_resource_id 	 	  => l_resource_id,
5642         x_category 	 	  => resource_rec.category,
5643         x_resource_number 	  => resource_rec.resource_number,
5644         x_source_id 	 	  => resource_rec.source_id,
5645         x_address_id 	 	  => resource_rec.address_id,
5646         x_contact_id 	 	  => resource_rec.contact_id,
5647         x_managing_employee_id 	  => resource_rec.managing_emp_id,
5648         x_start_date_active 	  => resource_rec.start_date_active,
5649         x_end_date_active 	  => resource_rec.end_date_active,
5650         x_time_zone 	 	  => resource_rec.time_zone,
5651         x_cost_per_hr 	  	  => resource_rec.cost_per_hr,
5652         x_primary_language 	  => resource_rec.primary_language,
5653         x_secondary_language 	  => resource_rec.secondary_language,
5654         x_support_site_id 	  => resource_rec.support_site_id,
5655         x_ies_agent_login 	  => resource_rec.ies_agent_login,
5656         x_server_group_id 	  => resource_rec.server_group_id,
5657         x_assigned_to_group_id 	  => resource_rec.assigned_to_group_id,
5658         x_cost_center 	 	  => resource_rec.cost_center,
5659         x_charge_to_cost_center   => resource_rec.charge_to_cost_center,
5660         x_compensation_currency_code => resource_rec.comp_currency_code,
5661         x_commissionable_flag 	  => resource_rec.commissionable_flag,
5662         x_hold_reason_code 	  => resource_rec.hold_reason_code,
5663         x_hold_payment 	 	  => resource_rec.hold_payment,
5664         x_comp_service_team_id 	  => resource_rec.comp_service_team_id,
5665         x_user_id 	 	  => resource_rec.user_id,
5666         --x_location 	 	  => resource_rec.location,
5667         x_transaction_number 	  => resource_rec.transaction_number,
5668 	x_object_version_number   => l_object_version_num,
5669         x_attribute1 	 	  => resource_rec.attribute1,
5670         x_attribute2 	 	  => resource_rec.attribute2,
5671         x_attribute3 	 	  => resource_rec.attribute3,
5672         x_attribute4 	 	  => resource_rec.attribute4,
5673         x_attribute5 	 	  => resource_rec.attribute5,
5674         x_attribute6 	 	  => resource_rec.attribute6,
5675         x_attribute7 	 	  => resource_rec.attribute7,
5676         x_attribute8 	 	  => resource_rec.attribute8,
5677         x_attribute9 	 	  => resource_rec.attribute9,
5678         x_attribute10 	 	  => resource_rec.attribute10,
5679         x_attribute11 	 	  => resource_rec.attribute11,
5680         x_attribute12 	 	  => resource_rec.attribute12,
5681         x_attribute13 	 	  => resource_rec.attribute13,
5682         x_attribute14 	 	  => resource_rec.attribute14,
5683         x_attribute15 	 	  => resource_rec.attribute15,
5684         x_attribute_category 	  => resource_rec.attribute_category,
5685         x_last_update_date 	  => SYSDATE,
5686         x_last_updated_by 	  => jtf_resource_utl.updated_by,
5687         x_last_update_login 	  => jtf_resource_utl.login_id,
5688         x_resource_name           => resource_rec.resource_name,
5689         x_source_name             => resource_rec.source_name,
5690         x_source_number           => resource_rec.source_number,
5691         x_source_job_title        => resource_rec.source_job_title,
5692         x_source_email            => resource_rec.source_email,
5693         x_source_phone            => resource_rec.source_phone,
5694         x_source_org_id           => resource_rec.source_org_id,
5695         x_source_org_name         => resource_rec.source_org_name,
5696         x_source_address1         => resource_rec.source_address1,
5697         x_source_address2         => resource_rec.source_address2,
5698         x_source_address3         => resource_rec.source_address3,
5699         x_source_address4         => resource_rec.source_address4,
5700         x_source_city             => resource_rec.source_city,
5701         x_source_postal_code      => resource_rec.source_postal_code,
5702         x_source_state            => resource_rec.source_state,
5703         x_source_province         => resource_rec.source_province,
5704         x_source_county           => resource_rec.source_county,
5705         x_source_country          => resource_rec.source_country,
5706         x_source_mgr_id           => resource_rec.source_mgr_id,
5707         x_source_mgr_name         => resource_rec.source_mgr_name,
5708         x_source_business_grp_id  => resource_rec.source_business_grp_id,
5709         x_source_business_grp_name=> resource_rec.source_business_grp_name,
5710         x_SOURCE_FIRST_NAME       => resource_rec.SOURCE_FIRST_NAME ,
5711         x_SOURCE_MIDDLE_NAME      => resource_rec.SOURCE_MIDDLE_NAME ,
5712         x_SOURCE_LAST_NAME        => resource_rec.SOURCE_LAST_NAME ,
5713         x_SOURCE_CATEGORY         => resource_rec.SOURCE_CATEGORY ,
5714         x_SOURCE_STATUS           => resource_rec.SOURCE_STATUS ,
5715         x_SOURCE_OFFICE           => resource_rec.SOURCE_OFFICE ,
5716         x_SOURCE_LOCATION         => resource_rec.SOURCE_LOCATION ,
5717         x_SOURCE_MAILSTOP         => resource_rec.SOURCE_MAILSTOP ,
5718         x_USER_NAME               => resource_rec.USER_NAME ,
5719         x_SOURCE_JOB_ID           => resource_rec.SOURCE_JOB_ID,
5720         x_PARTY_ID                => resource_rec.PERSON_PARTY_ID,
5721         x_SOURCE_MOBILE_PHONE     => resource_rec.SOURCE_MOBILE_PHONE ,
5722         x_SOURCE_PAGER            => resource_rec.SOURCE_PAGER,
5723         X_FS_SETUP_COMPLETE       => resource_rec.fs_setup_complete
5724       );
5725 
5726 
5727 
5728       /* Return the new value of the object version number */
5729 
5730       p_object_version_num := l_object_version_num;
5731 
5732 
5733 
5734     EXCEPTION
5735 
5736 	 WHEN NO_DATA_FOUND THEN
5737 
5738 --	   dbms_output.put_line('Error in Table Handler');
5739 
5740         IF c_resource_update%ISOPEN THEN
5741 
5742           CLOSE c_resource_update;
5743 
5744         END IF;
5745 
5746 	   x_return_status := fnd_api.g_ret_sts_unexp_error;
5747 
5748 	   fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
5749 	   fnd_msg_pub.add;
5750 
5751            RAISE fnd_api.g_exc_error;
5752 
5753 
5754     END;
5755 
5756 --    dbms_output.put_line('Resource Successfully Updated');
5757 
5758 
5759     /* Close the cursors */
5760 
5761     IF c_resource_update%ISOPEN THEN
5762 
5763       CLOSE c_resource_update;
5764 
5765     END IF;
5766 
5767 
5768     /* Make the post processing call to the user hooks */
5769 
5770     /* Post Call to the Customer Type User Hook */
5771 
5772     IF jtf_resource_utl.ok_to_execute(
5773 	 'JTF_RS_RESOURCE_PVT',
5774 	 'UPDATE_RESOURCE',
5775 	 'A',
5776 	 'C')
5777     THEN
5778     IF jtf_usr_hks.ok_to_execute(
5779 	 'JTF_RS_RESOURCE_PVT',
5780 	 'UPDATE_RESOURCE',
5781 	 'A',
5782 	 'C')
5783     THEN
5784 
5785       jtf_rs_resource_cuhk.update_resource_post(
5786 	    p_resource_id          => l_resource_id,
5787         p_managing_emp_id      => l_managing_emp_id,
5788         p_start_date_active    => l_start_date_active,
5789         p_end_date_active      => l_end_date_active,
5790         p_time_zone            => l_time_zone,
5791         p_cost_per_hr          => l_cost_per_hr,
5792         p_primary_language     => l_primary_language,
5793         p_secondary_language   => l_secondary_language,
5794         p_support_site_id      => l_support_site_id,
5795         p_ies_agent_login      => l_ies_agent_login,
5796         p_server_group_id      => l_server_group_id,
5797         p_assigned_to_group_id => l_assigned_to_group_id,
5798         p_cost_center          => l_cost_center,
5799         p_charge_to_cost_center=> l_charge_to_cost_center,
5800         p_comp_currency_code   => l_comp_currency_code,
5801         p_commissionable_flag  => l_commissionable_flag,
5802         p_hold_reason_code     => l_hold_reason_code,
5803         p_hold_payment         => l_hold_payment,
5804         p_comp_service_team_id => l_comp_service_team_id,
5805         p_user_id              => l_user_id,
5806         --p_location           => l_location,
5807 	   x_return_status => x_return_status);
5808 
5809       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5810 
5811 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
5812 
5813 
5814 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
5815 	   fnd_msg_pub.add;
5816 
5817 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5818 		RAISE FND_API.G_EXC_ERROR;
5819 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5820 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5821 	   END IF;
5822 
5823       END IF;
5824 
5825     END IF;
5826     END IF;
5827 
5828 
5829     /* Post Call to the Vertical Type User Hook */
5830 
5831     IF jtf_resource_utl.ok_to_execute(
5832 	 'JTF_RS_RESOURCE_PVT',
5833 	 'UPDATE_RESOURCE',
5834 	 'A',
5835 	 'V')
5836     THEN
5837     IF jtf_usr_hks.ok_to_execute(
5838 	 'JTF_RS_RESOURCE_PVT',
5839 	 'UPDATE_RESOURCE',
5840 	 'A',
5841 	 'V')
5842     THEN
5843 
5844       jtf_rs_resource_vuhk.update_resource_post(
5845 	   p_resource_id => l_resource_id,
5846         p_managing_emp_id => l_managing_emp_id,
5847         p_start_date_active => l_start_date_active,
5848         p_end_date_active => l_end_date_active,
5849         p_time_zone => l_time_zone,
5850         p_cost_per_hr => l_cost_per_hr,
5851         p_primary_language => l_primary_language,
5852         p_secondary_language => l_secondary_language,
5853         p_support_site_id => l_support_site_id,
5854         p_ies_agent_login => l_ies_agent_login,
5855         p_server_group_id => l_server_group_id,
5856         p_assigned_to_group_id => l_assigned_to_group_id,
5857         p_cost_center => l_cost_center,
5858         p_charge_to_cost_center => l_charge_to_cost_center,
5859         p_comp_currency_code => l_comp_currency_code,
5860         p_commissionable_flag => l_commissionable_flag,
5861         p_hold_reason_code => l_hold_reason_code,
5862         p_hold_payment => l_hold_payment,
5863         p_comp_service_team_id => l_comp_service_team_id,
5864         p_user_id => l_user_id,
5865         --p_location => l_location,
5866 	   x_return_status => x_return_status);
5867 
5868       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5869 
5870 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
5871 
5872 
5873 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
5874 	   fnd_msg_pub.add;
5875 
5876 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5877 		RAISE FND_API.G_EXC_ERROR;
5878 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5879 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5880 	   END IF;
5881 
5882 
5883       END IF;
5884 
5885     END IF;
5886     END IF;
5887 
5888 
5889     /* Post Call to the Internal Type User Hook */
5890 
5891     IF jtf_resource_utl.ok_to_execute(
5892 	 'JTF_RS_RESOURCE_PVT',
5893 	 'UPDATE_RESOURCE',
5894 	 'A',
5895 	 'I')
5896     THEN
5897     IF jtf_usr_hks.ok_to_execute(
5898 	 'JTF_RS_RESOURCE_PVT',
5899 	 'UPDATE_RESOURCE',
5900 	 'A',
5901 	 'I')
5902     THEN
5903 
5904       jtf_rs_resource_iuhk.update_resource_post(
5905 	   p_resource_id => l_resource_id,
5906         p_managing_emp_id => l_managing_emp_id,
5907         p_start_date_active => l_start_date_active,
5908         p_end_date_active => l_end_date_active,
5909         p_time_zone => l_time_zone,
5910         p_cost_per_hr => l_cost_per_hr,
5911         p_primary_language => l_primary_language,
5912         p_secondary_language => l_secondary_language,
5913         p_support_site_id => l_support_site_id,
5914         p_ies_agent_login => l_ies_agent_login,
5915         p_server_group_id => l_server_group_id,
5916         p_assigned_to_group_id => l_assigned_to_group_id,
5917         p_cost_center => l_cost_center,
5918         p_charge_to_cost_center => l_charge_to_cost_center,
5919         p_comp_currency_code => l_comp_currency_code,
5920         p_commissionable_flag => l_commissionable_flag,
5921         p_hold_reason_code => l_hold_reason_code,
5922         p_hold_payment => l_hold_payment,
5923         p_comp_service_team_id => l_comp_service_team_id,
5924         p_user_id => l_user_id,
5925         --p_location => l_location,
5926 	   x_return_status => x_return_status);
5927 
5928       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5929 
5930 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
5931 
5932 
5933 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
5934 	   fnd_msg_pub.add;
5935 
5936 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5937 		RAISE FND_API.G_EXC_ERROR;
5938 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
5939 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5940 	   END IF;
5941 
5942 
5943       END IF;
5944 
5945     END IF;
5946     END IF;
5947 
5948 
5949     /* Standard call for Message Generation */
5950 
5951     IF jtf_resource_utl.ok_to_execute(
5952 	 'JTF_RS_RESOURCE_PVT',
5953 	 'UPDATE_RESOURCE',
5954 	 'M',
5955 	 'M')
5956     THEN
5957     IF jtf_usr_hks.ok_to_execute(
5958 	 'JTF_RS_RESOURCE_PVT',
5959 	 'UPDATE_RESOURCE',
5960 	 'M',
5961 	 'M')
5962     THEN
5963 
5964       IF (jtf_rs_resource_cuhk.ok_to_generate_msg(
5965 	       p_resource_id => l_resource_id,
5966 	       x_return_status => x_return_status) )
5967       THEN
5968 
5969         /* Get the bind data id for the Business Object Instance */
5970 
5971         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
5972 
5973 
5974         /* Set bind values for the bind variables in the Business Object SQL */
5975 
5976         jtf_usr_hks.load_bind_data(l_bind_data_id, 'resource_id', l_resource_id, 'S', 'N');
5977 
5978 
5979         /* Call the message generation API */
5980 
5981         jtf_usr_hks.generate_message(
5982 		p_prod_code => 'RS',
5983 		p_bus_obj_code => 'RES',
5984 		p_action_code => 'U',
5985 		p_bind_data_id => l_bind_data_id,
5986 		x_return_code => x_return_status);
5987 
5988 
5989         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
5990 
5991 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
5992 
5993 
5994 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
5995 	     fnd_msg_pub.add;
5996 
5997 	     IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
5998 		  RAISE FND_API.G_EXC_ERROR;
5999 	     ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6000 		  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6001 	     END IF;
6002 
6003 
6004         END IF;
6005 
6006       END IF;
6007 
6008     END IF;
6009     END IF;
6010 
6011 
6012     IF fnd_api.to_boolean(p_commit) THEN
6013 
6014 	 COMMIT WORK;
6015 
6016     END IF;
6017 
6018     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
6019 
6020   EXCEPTION
6021 
6022 
6023     WHEN fnd_api.g_exc_error THEN
6024       ROLLBACK TO update_resource_pvt;
6025       x_return_status := fnd_api.g_ret_sts_error;
6026       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
6027                                  p_data => x_msg_data);
6028     WHEN fnd_api.g_exc_unexpected_error THEN
6029       ROLLBACK TO update_resource_pvt;
6030       x_return_status := fnd_api.g_ret_sts_unexp_error;
6031       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
6032                                  p_data => x_msg_data);
6033     WHEN OTHERS THEN
6034       ROLLBACK TO update_resource_pvt;
6035 -- The below lines removed as a part of fixing GSCC errors in R12 for jtfrspub.pls
6036 --      IF NOT(jtf_resource_utl.check_access(l_value))
6037 --      THEN
6038 --            IF(l_value = 'XMLGEN')
6039 --            THEN
6040 --		 fnd_message.set_name ('JTF', 'JTF_RS_XMLGEN_ERR');
6041 --		 FND_MSG_PUB.add;
6042 --            ELSIF(l_value = 'JTF_USR_HKS')
6043 --            THEN
6044 --		 fnd_message.set_name ('JTF', 'JTF_RS_JUHK_ERR');
6045 --		 FND_MSG_PUB.add;
6046 --            END IF;
6047 --      ELSE
6048 	fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
6049 	fnd_message.set_token('P_SQLCODE',SQLCODE);
6050 	fnd_message.set_token('P_SQLERRM',SQLERRM);
6051 	fnd_message.set_token('P_API_NAME', l_api_name);
6052 	FND_MSG_PUB.add;
6053 --      END IF;
6054       x_return_status := fnd_api.g_ret_sts_unexp_error;
6055       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
6056                                  p_data => x_msg_data);
6057 
6058 
6059   END update_resource;
6060     /*
6061  	  | Modification History :
6062  	  |
6063  	  | Sudhir Gokavarapu      ER9864816 - Complete business logic moved from this procedure to new procedure
6064       |                        and calling new update_resource procedure with extra parameter.
6065     */
6066 
6067   /* Overloaded Procedure to update the resource for Resource Synchronization */
6068 
6069   PROCEDURE  update_resource
6070   (P_API_VERSION             IN   NUMBER,
6071    P_INIT_MSG_LIST           IN   VARCHAR2,
6072    P_COMMIT                  IN   VARCHAR2,
6073    P_RESOURCE_ID             IN   JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
6074    P_MANAGING_EMP_ID         IN   JTF_RS_RESOURCE_EXTNS.MANAGING_EMPLOYEE_ID%TYPE,
6075    P_START_DATE_ACTIVE       IN   JTF_RS_RESOURCE_EXTNS.START_DATE_ACTIVE%TYPE,
6076    P_END_DATE_ACTIVE         IN   JTF_RS_RESOURCE_EXTNS.END_DATE_ACTIVE%TYPE,
6077    P_TIME_ZONE               IN   JTF_RS_RESOURCE_EXTNS.TIME_ZONE%TYPE,
6078    P_COST_PER_HR             IN   JTF_RS_RESOURCE_EXTNS.COST_PER_HR%TYPE,
6079    P_PRIMARY_LANGUAGE        IN   JTF_RS_RESOURCE_EXTNS.PRIMARY_LANGUAGE%TYPE,
6080    P_SECONDARY_LANGUAGE      IN   JTF_RS_RESOURCE_EXTNS.SECONDARY_LANGUAGE%TYPE,
6081    P_SUPPORT_SITE_ID         IN   JTF_RS_RESOURCE_EXTNS.SUPPORT_SITE_ID%TYPE,
6082    P_IES_AGENT_LOGIN         IN   JTF_RS_RESOURCE_EXTNS.IES_AGENT_LOGIN%TYPE,
6083    P_SERVER_GROUP_ID         IN   JTF_RS_RESOURCE_EXTNS.SERVER_GROUP_ID%TYPE,
6084    P_ASSIGNED_TO_GROUP_ID    IN   JTF_RS_RESOURCE_EXTNS.ASSIGNED_TO_GROUP_ID%TYPE,
6085    P_COST_CENTER             IN   JTF_RS_RESOURCE_EXTNS.COST_CENTER%TYPE,
6086    P_CHARGE_TO_COST_CENTER   IN   JTF_RS_RESOURCE_EXTNS.CHARGE_TO_COST_CENTER%TYPE,
6087    P_COMP_CURRENCY_CODE      IN   JTF_RS_RESOURCE_EXTNS.COMPENSATION_CURRENCY_CODE%TYPE,
6088    P_COMMISSIONABLE_FLAG     IN   JTF_RS_RESOURCE_EXTNS.COMMISSIONABLE_FLAG%TYPE,
6089    P_HOLD_REASON_CODE        IN   JTF_RS_RESOURCE_EXTNS.HOLD_REASON_CODE%TYPE,
6090    P_HOLD_PAYMENT            IN   JTF_RS_RESOURCE_EXTNS.HOLD_PAYMENT%TYPE,
6091    P_COMP_SERVICE_TEAM_ID    IN   JTF_RS_RESOURCE_EXTNS.COMP_SERVICE_TEAM_ID%TYPE,
6092    P_USER_ID                 IN   JTF_RS_RESOURCE_EXTNS.USER_ID%TYPE,
6093    --P_LOCATION              IN   MDSYS.SDO_GEOMETRY,
6094    P_ATTRIBUTE1              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE1%TYPE,
6095    P_ATTRIBUTE2              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE2%TYPE,
6096    P_ATTRIBUTE3              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE3%TYPE,
6097    P_ATTRIBUTE4              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE4%TYPE,
6098    P_ATTRIBUTE5              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE5%TYPE,
6099    P_ATTRIBUTE6              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE6%TYPE,
6100    P_ATTRIBUTE7              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE7%TYPE,
6101    P_ATTRIBUTE8              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE8%TYPE,
6102    P_ATTRIBUTE9              IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE9%TYPE,
6103    P_ATTRIBUTE10             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE10%TYPE,
6104    P_ATTRIBUTE11             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE11%TYPE,
6105    P_ATTRIBUTE12             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE12%TYPE,
6106    P_ATTRIBUTE13             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE13%TYPE,
6107    P_ATTRIBUTE14             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE14%TYPE,
6108    P_ATTRIBUTE15             IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE15%TYPE,
6109    P_ATTRIBUTE_CATEGORY      IN   JTF_RS_RESOURCE_EXTNS.ATTRIBUTE_CATEGORY%TYPE,
6110    P_RESOURCE_NAME           IN   JTF_RS_RESOURCE_EXTNS_TL.RESOURCE_NAME%TYPE,
6111    P_SOURCE_NAME             IN   JTF_RS_RESOURCE_EXTNS.SOURCE_NAME%TYPE,
6112    P_SOURCE_NUMBER           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_NUMBER%TYPE,
6113    P_SOURCE_JOB_TITLE        IN   JTF_RS_RESOURCE_EXTNS.SOURCE_JOB_TITLE%TYPE,
6114    P_SOURCE_EMAIL            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_EMAIL%TYPE,
6115    P_SOURCE_PHONE            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_PHONE%TYPE,
6116    P_SOURCE_ORG_ID           IN   NUMBER,
6117    P_SOURCE_ORG_NAME         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ORG_NAME%TYPE,
6118    P_SOURCE_ADDRESS1         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS1%TYPE,
6119    P_SOURCE_ADDRESS2         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS2%TYPE,
6120    P_SOURCE_ADDRESS3         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS3%TYPE,
6121    P_SOURCE_ADDRESS4         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_ADDRESS4%TYPE,
6122    P_SOURCE_CITY             IN   JTF_RS_RESOURCE_EXTNS.SOURCE_CITY%TYPE,
6123    P_SOURCE_POSTAL_CODE      IN   JTF_RS_RESOURCE_EXTNS.SOURCE_POSTAL_CODE%TYPE,
6124    P_SOURCE_STATE            IN   JTF_RS_RESOURCE_EXTNS.SOURCE_STATE%TYPE,
6125    P_SOURCE_PROVINCE         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_PROVINCE%TYPE,
6126    P_SOURCE_COUNTY           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_COUNTY%TYPE,
6127    P_SOURCE_COUNTRY          IN   JTF_RS_RESOURCE_EXTNS.SOURCE_COUNTRY%TYPE,
6128    P_SOURCE_MGR_ID           IN   JTF_RS_RESOURCE_EXTNS.SOURCE_MGR_ID%type,
6129    P_SOURCE_MGR_NAME         IN   JTF_RS_RESOURCE_EXTNS.SOURCE_MGR_NAME%type,
6130    P_SOURCE_BUSINESS_GRP_ID  IN   JTF_RS_RESOURCE_EXTNS.SOURCE_BUSINESS_GRP_ID%type,
6131    P_SOURCE_BUSINESS_GRP_NAME IN  JTF_RS_RESOURCE_EXTNS.SOURCE_BUSINESS_GRP_NAME%type,
6132    P_SOURCE_FIRST_NAME        IN JTF_RS_RESOURCE_EXTNS.SOURCE_FIRST_NAME%TYPE,
6133    P_SOURCE_LAST_NAME         IN JTF_RS_RESOURCE_EXTNS.SOURCE_LAST_NAME%TYPE,
6134    P_SOURCE_MIDDLE_NAME       IN JTF_RS_RESOURCE_EXTNS.SOURCE_MIDDLE_NAME%TYPE,
6135    P_SOURCE_CATEGORY          IN JTF_RS_RESOURCE_EXTNS.SOURCE_CATEGORY%TYPE,
6136    P_SOURCE_STATUS            IN JTF_RS_RESOURCE_EXTNS.SOURCE_STATUS%TYPE,
6137    P_SOURCE_OFFICE            IN JTF_RS_RESOURCE_EXTNS.SOURCE_OFFICE%TYPE,
6138    P_SOURCE_LOCATION          IN JTF_RS_RESOURCE_EXTNS.SOURCE_LOCATION%TYPE,
6139    P_SOURCE_MAILSTOP          IN JTF_RS_RESOURCE_EXTNS.SOURCE_MAILSTOP%TYPE,
6140    P_ADDRESS_ID               IN JTF_RS_RESOURCE_EXTNS.ADDRESS_ID%TYPE,
6141    P_OBJECT_VERSION_NUM       IN OUT NOCOPY  JTF_RS_RESOURCE_EXTNS.OBJECT_VERSION_NUMBER%TYPE,
6142    P_USER_NAME                IN  VARCHAR2,
6143    X_RETURN_STATUS            OUT NOCOPY  VARCHAR2,
6144    X_MSG_COUNT                OUT NOCOPY  NUMBER,
6145    X_MSG_DATA                 OUT NOCOPY  VARCHAR2,
6146    P_SOURCE_MOBILE_PHONE      IN JTF_RS_RESOURCE_EXTNS.SOURCE_MOBILE_PHONE%TYPE,
6147    P_SOURCE_PAGER             IN JTF_RS_RESOURCE_EXTNS.SOURCE_PAGER%TYPE
6148   ) IS
6149   BEGIN
6150       UPDATE_RESOURCE(
6151                P_API_VERSION                  => P_API_VERSION,
6152                P_INIT_MSG_LIST                => P_INIT_MSG_LIST,
6153                P_COMMIT                       => P_COMMIT,
6154                P_RESOURCE_ID                  => P_RESOURCE_ID,
6155                P_MANAGING_EMP_ID              => P_MANAGING_EMP_ID,
6156                P_START_DATE_ACTIVE            => P_START_DATE_ACTIVE,
6157                P_END_DATE_ACTIVE              => P_END_DATE_ACTIVE,
6158                P_TIME_ZONE                    => P_TIME_ZONE,
6159                P_COST_PER_HR                  => P_COST_PER_HR,
6160                P_PRIMARY_LANGUAGE             => P_PRIMARY_LANGUAGE,
6161                P_SECONDARY_LANGUAGE           => P_SECONDARY_LANGUAGE,
6162                P_SUPPORT_SITE_ID              => P_SUPPORT_SITE_ID,
6163                P_IES_AGENT_LOGIN              => P_IES_AGENT_LOGIN,
6164                P_SERVER_GROUP_ID              => P_SERVER_GROUP_ID,
6165                P_ASSIGNED_TO_GROUP_ID         => P_ASSIGNED_TO_GROUP_ID,
6166                P_COST_CENTER                  => P_COST_CENTER,
6167                P_CHARGE_TO_COST_CENTER        => P_CHARGE_TO_COST_CENTER,
6168                P_COMP_CURRENCY_CODE           => P_COMP_CURRENCY_CODE,
6169                P_COMMISSIONABLE_FLAG          => P_COMMISSIONABLE_FLAG,
6170                P_HOLD_REASON_CODE             => P_HOLD_REASON_CODE,
6171                P_HOLD_PAYMENT                 => P_HOLD_PAYMENT,
6172                P_COMP_SERVICE_TEAM_ID         => P_COMP_SERVICE_TEAM_ID,
6173                P_USER_ID                      => P_USER_ID,
6174                --P_LOCATION                   => --P_LOCATION
6175                P_ATTRIBUTE1                   => P_ATTRIBUTE1,
6176                P_ATTRIBUTE2                   => P_ATTRIBUTE2,
6177                P_ATTRIBUTE3                   => P_ATTRIBUTE3,
6178                P_ATTRIBUTE4                   => P_ATTRIBUTE4,
6179                P_ATTRIBUTE5                   => P_ATTRIBUTE5,
6180                P_ATTRIBUTE6                   => P_ATTRIBUTE6,
6181                P_ATTRIBUTE7                   => P_ATTRIBUTE7,
6182                P_ATTRIBUTE8                   => P_ATTRIBUTE8,
6183                P_ATTRIBUTE9                   => P_ATTRIBUTE9,
6184                P_ATTRIBUTE10                  => P_ATTRIBUTE10,
6185                P_ATTRIBUTE11                  => P_ATTRIBUTE11,
6186                P_ATTRIBUTE12                  => P_ATTRIBUTE12,
6187                P_ATTRIBUTE13                  => P_ATTRIBUTE13,
6188                P_ATTRIBUTE14                  => P_ATTRIBUTE14,
6189                P_ATTRIBUTE15                  => P_ATTRIBUTE15,
6190                P_ATTRIBUTE_CATEGORY           => P_ATTRIBUTE_CATEGORY,
6191                P_RESOURCE_NAME                => P_RESOURCE_NAME,
6192                P_SOURCE_NAME                  => P_SOURCE_NAME,
6193                P_SOURCE_NUMBER                => P_SOURCE_NUMBER,
6194                P_SOURCE_JOB_TITLE             => P_SOURCE_JOB_TITLE,
6195                P_SOURCE_EMAIL                 => P_SOURCE_EMAIL,
6196                P_SOURCE_PHONE                 => P_SOURCE_PHONE,
6197                P_SOURCE_ORG_ID                => P_SOURCE_ORG_ID,
6198                P_SOURCE_ORG_NAME              => P_SOURCE_ORG_NAME,
6199                P_SOURCE_ADDRESS1              => P_SOURCE_ADDRESS1,
6200                P_SOURCE_ADDRESS2              => P_SOURCE_ADDRESS2,
6201                P_SOURCE_ADDRESS3              => P_SOURCE_ADDRESS3,
6202                P_SOURCE_ADDRESS4              => P_SOURCE_ADDRESS4,
6203                P_SOURCE_CITY                  => P_SOURCE_CITY,
6204                P_SOURCE_POSTAL_CODE           => P_SOURCE_POSTAL_CODE,
6205                P_SOURCE_STATE                 => P_SOURCE_STATE,
6206                P_SOURCE_PROVINCE              => P_SOURCE_PROVINCE,
6207                P_SOURCE_COUNTY                => P_SOURCE_COUNTY,
6208                P_SOURCE_COUNTRY               => P_SOURCE_COUNTRY,
6209                P_SOURCE_MGR_ID                => P_SOURCE_MGR_ID,
6210                P_SOURCE_MGR_NAME              => P_SOURCE_MGR_NAME,
6211                P_SOURCE_BUSINESS_GRP_ID       => P_SOURCE_BUSINESS_GRP_ID,
6212                P_SOURCE_BUSINESS_GRP_NAME     => P_SOURCE_BUSINESS_GRP_NAME,
6213                P_SOURCE_FIRST_NAME            => P_SOURCE_FIRST_NAME,
6214                P_SOURCE_LAST_NAME             => P_SOURCE_LAST_NAME,
6215                P_SOURCE_MIDDLE_NAME           => P_SOURCE_MIDDLE_NAME,
6216                P_SOURCE_CATEGORY              => P_SOURCE_CATEGORY,
6217                P_SOURCE_STATUS                => P_SOURCE_STATUS,
6218                P_SOURCE_OFFICE                => P_SOURCE_OFFICE,
6219                P_SOURCE_LOCATION              => P_SOURCE_LOCATION,
6220                P_SOURCE_MAILSTOP              => P_SOURCE_MAILSTOP,
6221                P_ADDRESS_ID                   => P_ADDRESS_ID,
6222                P_OBJECT_VERSION_NUM           => P_OBJECT_VERSION_NUM,
6223                P_USER_NAME                    => P_USER_NAME,
6224                X_RETURN_STATUS                => X_RETURN_STATUS,
6225                X_MSG_COUNT                    => X_MSG_COUNT,
6226                X_MSG_DATA                     => X_MSG_DATA,
6227                P_SOURCE_MOBILE_PHONE          => P_SOURCE_MOBILE_PHONE,
6228                P_SOURCE_PAGER                 => P_SOURCE_PAGER,
6229                P_FS_SETUP_COMPLETE            => FND_API.G_MISS_CHAR);
6230   END update_resource;
6231   /* Procedure to delete  the resource of category = TBH */
6232 
6233   PROCEDURE DELETE_RESOURCE(
6234     P_API_VERSION	IN  NUMBER,
6235     P_INIT_MSG_LIST	IN  VARCHAR2,
6236     P_COMMIT		IN  VARCHAR2,
6237     P_RESOURCE_ID       IN  NUMBER,
6238     X_RETURN_STATUS     OUT NOCOPY VARCHAR2,
6239     X_MSG_COUNT         OUT NOCOPY NUMBER,
6240     X_MSG_DATA          OUT NOCOPY VARCHAR2 )
6241   IS
6242   CURSOR res_cur(L_RESOURCE_ID     NUMBER)
6243       IS
6244   SELECT category
6245     FROM jtf_rs_resource_extns
6246    WHERE resource_id = l_resource_id;
6247 
6248     l_api_version         CONSTANT NUMBER := 1.0;
6249     l_api_name            CONSTANT VARCHAR2(30) := 'DELETE_RESOURCE';
6250     l_category            JTF_RS_RESOURCE_EXTNS.CATEGORY%TYPE ;
6251   /* Moved the initial assignment of below variable to inside begin */
6252     L_RESOURCE_ID         JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE;
6253     l_bind_data_id                 NUMBER;
6254     l_value                varchar2(100);
6255 
6256     l_return_status             VARCHAR2(2000);
6257     l_msg_count                 NUMBER;
6258     l_msg_data                  VARCHAR2(2000);
6259 
6260   BEGIN
6261 
6262     L_RESOURCE_ID   := p_resource_id;
6263 
6264    SAVEPOINT delete_resource_pvt;
6265 
6266     x_return_status := fnd_api.g_ret_sts_success;
6267 
6268 
6269     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
6270 
6271       RAISE fnd_api.g_exc_unexpected_error;
6272 
6273     END IF;
6274 
6275 
6276     IF fnd_api.to_boolean(p_init_msg_list) THEN
6277 
6278       fnd_msg_pub.initialize;
6279 
6280     END IF;
6281 
6282 
6283     /* Make the pre processing call to the user hooks */
6284 
6285     /* Pre Call to the Customer Type User Hook */
6286 
6287     IF jtf_resource_utl.ok_to_execute(
6288 	 'JTF_RS_RESOURCE_PVT',
6289 	 'DELETE_RESOURCE',
6290 	 'B',
6291 	 'C')
6292     THEN
6293     IF jtf_usr_hks.ok_to_execute(
6294 	 'JTF_RS_RESOURCE_PVT',
6295 	 'DELETE_RESOURCE',
6296 	 'B',
6297 	 'C')
6298     THEN
6299 
6300       jtf_rs_resource_cuhk.delete_resource_pre(
6301 	   p_resource_id => l_resource_id,
6302        	   x_return_status => x_return_status);
6303 
6304       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6305          fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
6306 	 fnd_msg_pub.add;
6307 	 IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6308 	      RAISE FND_API.G_EXC_ERROR;
6309 	 ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6310 	      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6311 	 END IF;
6312 
6313       END IF;
6314 
6315     END IF;
6316     END IF;
6317 
6318 
6319     /* Pre Call to the Vertical Type User Hook */
6320 
6321     IF jtf_resource_utl.ok_to_execute(
6322 	 'JTF_RS_RESOURCE_PVT',
6323 	 'DELETE_RESOURCE',
6324 	 'B',
6325 	 'V')
6326     THEN
6327     IF jtf_usr_hks.ok_to_execute(
6328 	 'JTF_RS_RESOURCE_PVT',
6329 	 'DELETE_RESOURCE',
6330 	 'B',
6331 	 'V')
6332     THEN
6333 
6334       jtf_rs_resource_vuhk.delete_resource_pre(
6335 	   p_resource_id => l_resource_id,
6336 	   x_return_status => x_return_status);
6337 
6338       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6339          fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
6340 	 fnd_msg_pub.add;
6341 	 IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6342 	      RAISE FND_API.G_EXC_ERROR;
6343 	 ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6344 	      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6345 	 END IF;
6346 
6347       END IF;
6348     END IF;
6349     END IF;
6350 
6351 
6352     /* Pre Call to the Internal Type User Hook */
6353 
6354     IF jtf_usr_hks.ok_to_execute(
6355 	 'JTF_RS_RESOURCE_PVT',
6356 	 'DELETE_RESOURCE',
6357 	 'B',
6358 	 'I')
6359     THEN
6360     IF jtf_usr_hks.ok_to_execute(
6361 	 'JTF_RS_RESOURCE_PVT',
6362 	 'DELETE_RESOURCE',
6363 	 'B',
6364 	 'I')
6365     THEN
6366 
6367       jtf_rs_resource_iuhk.delete_resource_pre(
6368 	   p_resource_id => l_resource_id,
6369       	   x_return_status => x_return_status);
6370 
6371       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6372         fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
6373 	fnd_msg_pub.add;
6374 
6375 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6376 	     RAISE FND_API.G_EXC_ERROR;
6377 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6378 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6379 	END IF;
6380 
6381 
6382       END IF;
6383 
6384     END IF;
6385     END IF;
6386 
6387 
6388     OPEN res_cur(l_resource_id);
6389     FETCH res_cur INTO l_category;
6390     CLOSE res_cur;
6391 
6392     --allow delete only for category of type TBH
6393     IF (l_category = 'TBH')
6394     THEN
6395          /* Make a call to the Resource Audit API */
6396 
6397          jtf_rs_resource_extns_aud_pvt.delete_resource
6398                     (P_API_VERSION => 1,
6399                      P_INIT_MSG_LIST => fnd_api.g_false,
6400                      P_COMMIT => fnd_api.g_false,
6401                      P_RESOURCE_ID => l_resource_id,
6402                      X_RETURN_STATUS => x_return_status,
6403                      X_MSG_COUNT => x_msg_count,
6404                      X_MSG_DATA => x_msg_data
6405                     );
6406 
6407          IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6408 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6409 		RAISE FND_API.G_EXC_ERROR;
6410 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6411 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6412 	   END IF;
6413 
6414 
6415          END IF;
6416 
6417        --delete the row from the table
6418           jtf_rs_resource_extns_pkg.delete_row(
6419                   x_resource_id => l_resource_id );
6420 
6421 
6422     END IF;  --end of category check for TBH
6423 
6424 
6425     /* Make the post processing call to the user hooks */
6426 
6427     /* Post Call to the Customer Type User Hook */
6428 
6429     IF jtf_usr_hks.ok_to_execute(
6430 	 'JTF_RS_RESOURCE_PVT',
6431 	 'DELETE_RESOURCE',
6432 	 'A',
6433 	 'C')
6434     THEN
6435 
6436       jtf_rs_resource_cuhk.delete_resource_post(
6437 	   p_resource_id => l_resource_id,
6438        	   x_return_status => x_return_status);
6439       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6440           fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
6441 	  fnd_msg_pub.add;
6442 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6443 	       RAISE FND_API.G_EXC_ERROR;
6444 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6445 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6446 	  END IF;
6447 
6448       END IF;
6449 
6450     END IF;
6451 
6452 
6453     /* Post Call to the Vertical Type User Hook */
6454 
6455     IF jtf_resource_utl.ok_to_execute(
6456 	 'JTF_RS_RESOURCE_PVT',
6457 	 'DELETE_RESOURCE',
6458 	 'A',
6459 	 'V')
6460     THEN
6461     IF jtf_usr_hks.ok_to_execute(
6462 	 'JTF_RS_RESOURCE_PVT',
6463 	 'DELETE_RESOURCE',
6464 	 'A',
6465 	 'V')
6466     THEN
6467 
6468       jtf_rs_resource_vuhk.delete_resource_post(
6469 	   p_resource_id => l_resource_id,
6470        	   x_return_status => x_return_status);
6471         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6472           fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
6473 	  fnd_msg_pub.add;
6474 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6475 	       RAISE FND_API.G_EXC_ERROR;
6476 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6477 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6478 	  END IF;
6479 
6480       END IF;
6481     END IF;
6482     END IF;
6483 
6484 
6485     /* Post Call to the Internal Type User Hook */
6486 
6487     IF jtf_resource_utl.ok_to_execute(
6488 	 'JTF_RS_RESOURCE_PVT',
6489 	 'DELETE_RESOURCE',
6490 	 'A',
6491 	 'I')
6492     THEN
6493     IF jtf_usr_hks.ok_to_execute(
6494 	 'JTF_RS_RESOURCE_PVT',
6495 	 'DELETE_RESOURCE',
6496 	 'A',
6497 	 'I')
6498     THEN
6499 
6500       jtf_rs_resource_iuhk.delete_resource_post(
6501 	   p_resource_id => l_resource_id,
6502 	   x_return_status => x_return_status);
6503 
6504       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6505           fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
6506 	  fnd_msg_pub.add;
6507 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6508 	       RAISE FND_API.G_EXC_ERROR;
6509 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6510 	       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6511 	  END IF;
6512 
6513       END IF;
6514 
6515     END IF;
6516     END IF;
6517 
6518 
6519     /* Standard call for Message Generation */
6520 
6521     IF jtf_resource_utl.ok_to_execute(
6522 	 'JTF_RS_RESOURCE_PVT',
6523 	 'DELETE_RESOURCE',
6524 	 'M',
6525 	 'M')
6526     THEN
6527     IF jtf_usr_hks.ok_to_execute(
6528 	 'JTF_RS_RESOURCE_PVT',
6529 	 'DELETE_RESOURCE',
6530 	 'M',
6531 	 'M')
6532     THEN
6533 
6534       IF (jtf_rs_resource_cuhk.ok_to_generate_msg(
6535 	       p_resource_id => l_resource_id,
6536 	       x_return_status => x_return_status) )
6537       THEN
6538 
6539         /* Get the bind data id for the Business Object Instance */
6540 
6541         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
6542 
6543 
6544         /* Set bind values for the bind variables in the Business Object SQL */
6545 
6546         jtf_usr_hks.load_bind_data(l_bind_data_id, 'resource_id', l_resource_id, 'S', 'N');
6547 
6548 
6549         /* Call the message generation API */
6550 
6551         jtf_usr_hks.generate_message(
6552 		p_prod_code => 'RS',
6553 		p_bus_obj_code => 'RES',
6554 		p_action_code => 'D',
6555 		p_bind_data_id => l_bind_data_id,
6556 		x_return_code => x_return_status);
6557 
6558 
6559         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
6560 
6561 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
6562 
6563 
6564 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
6565 	     fnd_msg_pub.add;
6566 
6567 	     IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
6568 		  RAISE FND_API.G_EXC_ERROR;
6569 	     ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
6570 		  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6571 	     END IF;
6572 
6573 
6574         END IF;
6575 
6576       END IF;
6577 
6578     END IF;
6579     END IF;
6580 
6581 
6582     IF fnd_api.to_boolean(p_commit) THEN
6583 
6584 	 COMMIT WORK;
6585 
6586     END IF;
6587 
6588     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
6589 
6590     if (l_category = 'TBH') then
6591 
6592     /* Calling publish API to raise create resource event. */
6593     /* added by baianand on 11/04/2002 */
6594 
6595        begin
6596           jtf_rs_wf_events_pub.delete_resource
6597                  (p_api_version               => 1.0
6598                  ,p_init_msg_list             => fnd_api.g_false
6599                  ,p_commit                    => fnd_api.g_false
6600                  ,p_resource_id               => l_resource_id
6601                  ,x_return_status             => l_return_status
6602                  ,x_msg_count                 => l_msg_count
6603                  ,x_msg_data                  => l_msg_data);
6604 
6605        EXCEPTION when others then
6606           null;
6607        end;
6608 
6609     /* End of publish API call */
6610 
6611     /* Calling work API for delete record from wf_local tables. */
6612     /* added by baianand on 08/13/2002 */
6613 
6614        begin
6615           jtf_rs_wf_integration_pub.delete_resource
6616               (p_api_version               => 1.0
6617               ,p_init_msg_list             => fnd_api.g_false
6618               ,p_commit                    => fnd_api.g_false
6619               ,p_resource_id               => l_resource_id
6620               ,x_return_status             => l_return_status
6621               ,x_msg_count                 => l_msg_count
6622               ,x_msg_data                  => l_msg_data);
6623 
6624        EXCEPTION when others then
6625           null;
6626        end;
6627     end if;
6628 
6629     /* End of work API call */
6630 
6631   EXCEPTION
6632 
6633 
6634     WHEN fnd_api.g_exc_error THEN
6635       ROLLBACK TO delete_resource_pvt;
6636       x_return_status := fnd_api.g_ret_sts_error;
6637       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
6638                                  p_data => x_msg_data);
6639     WHEN fnd_api.g_exc_unexpected_error THEN
6640       ROLLBACK TO delete_resource_pvt;
6641       x_return_status := fnd_api.g_ret_sts_unexp_error;
6642       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
6643                                  p_data => x_msg_data);
6644     WHEN OTHERS THEN
6645       ROLLBACK TO delete_resource_pvt;
6646 -- The below lines removed as a part of fixing GSCC errors in R12 for jtfrspub.pls
6647 --           IF NOT(jtf_resource_utl.check_access(l_value))
6648 --      THEN
6649 --            IF(l_value = 'XMLGEN')
6650 --            THEN
6651 --		 fnd_message.set_name ('JTF', 'JTF_RS_XMLGEN_ERR');
6652 --		 FND_MSG_PUB.add;
6653 --            ELSIF(l_value = 'JTF_USR_HKS')
6654 --            THEN
6655 --		 fnd_message.set_name ('JTF', 'JTF_RS_JUHK_ERR');
6656 --		 FND_MSG_PUB.add;
6657 --            END IF;
6658 --      ELSE
6659 	 fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
6660 	 fnd_message.set_token('P_SQLCODE',SQLCODE);
6661 	 fnd_message.set_token('P_SQLERRM',SQLERRM);
6662 	 fnd_message.set_token('P_API_NAME', l_api_name);
6663 	 FND_MSG_PUB.add;
6664 --      END IF;
6665       x_return_status := fnd_api.g_ret_sts_unexp_error;
6666       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
6667                                  p_data => x_msg_data);
6668 
6669   END delete_resource;
6670 
6671 END jtf_rs_resource_pvt;