DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_RS_WF_EVENTS_PUB

Source


1 PACKAGE BODY jtf_rs_wf_events_pub AS
2   /* $Header: jtfrswpb.pls 120.0 2005/05/11 08:23:27 appldev ship $ */
3 
4   /*****************************************************************************************
5    ******************************************************************************************/
6 
7   /* Package variables. */
8 
9   G_PKG_NAME         VARCHAR2(30) := 'JTF_RS_WF_EVENTS_PUB';
10 
11   FUNCTION item_key(p_event_name  IN VARCHAR2) RETURN VARCHAR2
12   /* Return Item_Key according to Resource Event to be raised
13      Item_Key is <Event_Name>-jtf_rs_wf_event_guid_s.nextval */
14   IS
15   l_key varchar2(240);
16   BEGIN
17      SELECT p_event_name ||'-'|| jtf_rs_wf_event_guid_s.nextval INTO l_key FROM DUAL;
18      RETURN l_key;
19   END item_key;
20 
21   PROCEDURE create_resource
22   (P_API_VERSION        IN      NUMBER,
23    P_INIT_MSG_LIST      IN      VARCHAR2,
24    P_COMMIT             IN      VARCHAR2,
25    P_RESOURCE_ID        IN      NUMBER,
26    P_RESOURCE_NAME      IN      VARCHAR2,
27    P_CATEGORY           IN      VARCHAR2,
28    P_USER_ID            IN      NUMBER,
29    P_START_DATE_ACTIVE  IN      DATE,
30    P_END_DATE_ACTIVE    IN      DATE,
31    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
32    X_MSG_COUNT          OUT     NOCOPY NUMBER,
33    X_MSG_DATA           OUT     NOCOPY VARCHAR2
34    ) IS
35 
36    l_api_version            CONSTANT NUMBER := 1.0;
37    l_api_name               CONSTANT VARCHAR2(30) := 'CREATE_RESOURCE';
38    l_sysdate                date  := trunc(sysdate);
39 
40    l_list                   WF_PARAMETER_LIST_T;
41    l_key                    varchar2(240);
42    l_exist                  varchar2(30);
43    l_event_name             varchar2(240) := 'oracle.apps.jtf.jres.resource.create';
44    l_resource_id            jtf_rs_resource_extns.resource_id%type := p_resource_id;
45    l_resource_name          jtf_rs_resource_extns_vl.resource_name%type := p_resource_name;
46    l_category               jtf_rs_resource_extns.category%type := p_category;
47    l_start_date_active      jtf_rs_resource_extns.start_date_active%type := trunc(p_start_date_active);
48    l_end_date_active        jtf_rs_resource_extns.end_date_active%type := trunc(p_end_date_active);
49    l_user_id                jtf_rs_resource_extns.user_id%type := p_user_id;
50 
51  BEGIN
52 
53     x_return_status := fnd_api.g_ret_sts_success;
54     savepoint cr_emp_publish_save;
55 
56     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
57        RAISE fnd_api.g_exc_unexpected_error;
58     END IF;
59 
60     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
61     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
62     then
63        fnd_msg_pub.Initialize;
64     end if;
65 
66     --Get the item key
67     l_key := item_key(l_event_name);
68 
69     -- initialization of object variables
70 
71     wf_event.AddParameterToList('RESOURCE_ID',l_resource_id,l_list);
72     wf_event.AddParameterToList('RESOURCE_NAME',l_resource_name,l_list);
73     wf_event.AddParameterToList('CATEGORY',l_category,l_list);
74     wf_event.AddParameterToList('USER_ID',l_user_id,l_list);
75     wf_event.AddParameterToList('START_DATE_ACTIVE',l_start_date_active,l_list);
76     wf_event.AddParameterToList('END_DATE_ACTIVE',l_end_date_active,l_list);
77 
78     -- Raise Event
79     wf_event.raise(
80                    p_event_name        => l_event_name
81                   ,p_event_key         => l_key
82                   ,p_parameters        => l_list
83                   );
84 
85     l_list.DELETE;
86 
87     EXCEPTION when OTHERS then
88        ROLLBACK TO cr_emp_publish_save;
89        x_return_status := fnd_api.g_ret_sts_unexp_error;
90 
91  END create_resource;
92 
93 PROCEDURE merge_resource
94   (P_API_VERSION        IN      NUMBER,
95    P_INIT_MSG_LIST      IN      VARCHAR2,
96    P_COMMIT             IN      VARCHAR2,
97    P_RESOURCE_ID        IN      NUMBER,
98    P_END_DATE_ACTIVE    IN      DATE,
99    P_REPL_RESOURCE_ID   IN      NUMBER,
100    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
101    X_MSG_COUNT          OUT     NOCOPY NUMBER,
102    X_MSG_DATA           OUT     NOCOPY VARCHAR2
103    ) IS
104 
105    l_api_version            CONSTANT NUMBER := 1.0;
106    l_api_name               CONSTANT VARCHAR2(30) := 'MERGE_RESOURCE';
107 
108    l_list                   WF_PARAMETER_LIST_T;
109    l_key                    varchar2(240);
110    l_exist                  varchar2(30);
111    l_event_name             varchar2(240) := 'oracle.apps.jtf.jres.resource.merge';
112    l_resource_id            jtf_rs_resource_extns.resource_id%type := p_resource_id;
113    l_repl_resource_id       jtf_rs_resource_extns.resource_id%type := p_repl_resource_id;
114    l_end_date_active        jtf_rs_resource_extns.end_date_active%type := trunc(p_end_date_active);
115 
116  BEGIN
117 
118     x_return_status := fnd_api.g_ret_sts_success;
119     savepoint merge_res_publish_save;
120 
121     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
122        RAISE fnd_api.g_exc_unexpected_error;
123     END IF;
124 
125     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
126     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
127     then
128        fnd_msg_pub.Initialize;
129     end if;
130 
131     --Get the item key
132     l_key := item_key(l_event_name);
133 
134     -- initialization of object variables
135 
136     wf_event.AddParameterToList('RESOURCE_ID',l_resource_id,l_list);
137     wf_event.AddParameterToList('REPLACEMENT_RESOURCE_ID',l_repl_resource_id,l_list);
138     wf_event.AddParameterToList('END_DATE_ACTIVE',l_end_date_active,l_list);
139 
140     -- Raise Event
141     wf_event.raise(
142                    p_event_name        => l_event_name
143                   ,p_event_key         => l_key
144                   ,p_parameters        => l_list
145                   );
146 
147     l_list.DELETE;
148 
149     EXCEPTION when OTHERS then
150        ROLLBACK TO merge_res_publish_save;
151        x_return_status := fnd_api.g_ret_sts_unexp_error;
152 
153  END merge_resource;
154 
155 
156   PROCEDURE update_resource
157   (P_API_VERSION        IN      NUMBER,
158    P_INIT_MSG_LIST      IN      VARCHAR2,
159    P_COMMIT             IN      VARCHAR2,
160    P_RESOURCE_REC       IN      jtf_rs_resource_pvt.RESOURCE_REC_TYPE,
161    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
162    X_MSG_COUNT          OUT     NOCOPY NUMBER,
163    X_MSG_DATA           OUT     NOCOPY VARCHAR2
164   ) IS
165 
166    l_api_version         CONSTANT NUMBER := 1.0;
167    l_api_name            CONSTANT VARCHAR2(30) := 'UPDATE_RESOURCE';
168 
169    l_sysdate                   date  := trunc(sysdate);
170 
171    l_list                       WF_PARAMETER_LIST_T;
172    l_key                        varchar2(240);
173    l_exist                      varchar2(30);
174    l_event_name                 varchar2(240);
175    l_resource_id                jtf_rs_resource_extns.resource_id%type := p_resource_rec.resource_id;
176    l_category                   jtf_rs_resource_extns.category%type := p_resource_rec.category;
177    l_new_resource_name          jtf_rs_resource_extns_vl.resource_name%type := p_resource_rec.resource_name;
178    l_new_start_date_active      jtf_rs_resource_extns.start_date_active%type := trunc(p_resource_rec.start_date_active);
179    l_new_end_date_active        jtf_rs_resource_extns.end_date_active%type := trunc(p_resource_rec.end_date_active);
180    l_new_user_id                jtf_rs_resource_extns.user_id%type := p_resource_rec.user_id;
181    l_new_time_zone              jtf_rs_resource_extns.time_zone%type := p_resource_rec.time_zone;
182    l_new_cost_per_hr            jtf_rs_resource_extns.cost_per_hr%type := p_resource_rec.cost_per_hr;
183    l_new_primary_language       jtf_rs_resource_extns.primary_language%type := p_resource_rec.primary_language;
184    l_new_secondary_language     jtf_rs_resource_extns.secondary_language%type := p_resource_rec.secondary_language;
185    l_new_ies_agent_login        jtf_rs_resource_extns.ies_agent_login%type := p_resource_rec.ies_agent_login;
186    l_new_server_group_id        jtf_rs_resource_extns.server_group_id%type := p_resource_rec.server_group_id;
187    l_new_assigned_to_group_id   jtf_rs_resource_extns.assigned_to_group_id%type := p_resource_rec.assigned_to_group_id;
188    l_new_cost_center            jtf_rs_resource_extns.cost_center%type := p_resource_rec.cost_center;
189    l_new_charge_to_cost_center  jtf_rs_resource_extns.charge_to_cost_center%type := p_resource_rec.charge_to_cost_center;
190    l_new_comp_currency_code     jtf_rs_resource_extns.compensation_currency_code%type := p_resource_rec.comp_currency_code;
191    l_new_commissionable_flag    jtf_rs_resource_extns.commissionable_flag%type := p_resource_rec.commissionable_flag;
192    l_new_hold_reason_code       jtf_rs_resource_extns.hold_reason_code%type := p_resource_rec.hold_reason_code;
193    l_new_hold_payment           jtf_rs_resource_extns.hold_payment%type := p_resource_rec.hold_payment;
194    l_new_comp_service_team_id   jtf_rs_resource_extns.comp_service_team_id%type := p_resource_rec.comp_service_team_id;
195    l_new_support_site_id        jtf_rs_resource_extns.support_site_id%type := p_resource_rec.support_site_id;
196 
197 
198    cursor res_cur IS
199    select user_id,
200           resource_name,
201           trunc(start_date_active) start_date_active,
202           trunc(end_date_active) end_date_active,
203           time_zone,
204           cost_per_hr,
205           primary_language,
206           secondary_language,
207           ies_agent_login,
208           server_group_id,
209           assigned_to_group_id,
210           cost_center,
211           charge_to_cost_center,
212           compensation_currency_code,
213           commissionable_flag,
214           hold_reason_code,
215           hold_payment,
216           comp_service_team_id,
217           support_site_id
218    from   jtf_rs_resource_extns_vl
219    where  resource_id  = p_resource_rec.resource_id;
220 
221    res_rec  res_cur%rowtype;
222 
223  BEGIN
224 
225     x_return_status := fnd_api.g_ret_sts_success;
226     savepoint upd_emp_publish_save;
227 
228     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
229        RAISE fnd_api.g_exc_unexpected_error;
230     END IF;
231 
232     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
233     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
234     then
235        fnd_msg_pub.Initialize;
236     end if;
237 
238     OPEN res_cur;
239     FETCH res_cur INTO res_rec;
240 
241     /* If user is changed, raise the event oracle.apps.jtf.jres.resource.update.user */
242     if (nvl(res_rec.user_id,-9999) <> nvl(l_new_user_id,-9999)) then
243 
244        l_event_name := 'oracle.apps.jtf.jres.resource.update.user';
245 
246        --Get the item key
247        l_key := item_key(l_event_name);
248 
249        -- initialization of object variables
250 
251        wf_event.AddParameterToList('RESOURCE_ID',l_resource_id,l_list);
252        wf_event.AddParameterToList('CATEGORY',l_category,l_list);
253        wf_event.AddParameterToList('RESOURCE_NAME',l_new_resource_name,l_list);
254        wf_event.AddParameterToList('OLD_USER_ID',res_rec.user_id,l_list);
255        wf_event.AddParameterToList('NEW_USER_ID',l_new_user_id,l_list);
256 
257        -- Raise Event
258        wf_event.raise(
259                       p_event_name        => l_event_name
260                      ,p_event_key         => l_key
261                      ,p_parameters        => l_list
262                      );
263 
264        l_list.DELETE;
265 
266     end if;
267 
268     /* If date effectivity is changed, raise the event oracle.apps.jtf.jres.resource.update.effectivedate */
269     if (((res_rec.end_date_active is NULL) AND (l_new_end_date_active is NOT NULL)) OR
270         ((res_rec.end_date_active is NOT NULL) AND (l_new_end_date_active is NULL)) OR
271         (res_rec.end_date_active <> l_new_end_date_active) OR
272         (res_rec.start_date_active <> l_new_start_date_active)
273        ) then
274 
275        l_event_name := 'oracle.apps.jtf.jres.resource.update.effectivedate';
276 
277        --Get the item key
278        l_key := item_key(l_event_name);
279 
280        -- initialization of object variables
281 
282        wf_event.AddParameterToList('RESOURCE_ID',l_resource_id,l_list);
283        wf_event.AddParameterToList('CATEGORY',l_category,l_list);
284        wf_event.AddParameterToList('RESOURCE_NAME',l_new_resource_name,l_list);
285        wf_event.AddParameterToList('OLD_START_DATE_ACTIVE',res_rec.start_date_active,l_list);
286        wf_event.AddParameterToList('NEW_START_DATE_ACTIVE',l_new_start_date_active,l_list);
287        wf_event.AddParameterToList('OLD_END_DATE_ACTIVE',res_rec.end_date_active,l_list);
288        wf_event.AddParameterToList('NEW_END_DATE_ACTIVE',l_new_end_date_active,l_list);
289 
290        -- Raise Event
291        wf_event.raise(
292                       p_event_name        => l_event_name
293                      ,p_event_key         => l_key
294                      ,p_parameters        => l_list
295                      );
296 
297        l_list.DELETE;
298 
299     end if;
300 
301     /* If any other attribute changes, other than user_id and date effectivity,
302       raise the event oracle.apps.jtf.jres.resource.update.attributes */
303     if (((res_rec.resource_name is NULL) AND (l_new_resource_name is NOT NULL)) OR
304         ((res_rec.resource_name is NOT NULL) AND (l_new_resource_name is NULL)) OR
305         (res_rec.resource_name <> l_new_resource_name) OR
306         ((res_rec.time_zone is NULL) AND (l_new_time_zone is NOT NULL)) OR
307         ((res_rec.time_zone is NOT NULL) AND (l_new_time_zone is NULL)) OR
308         (res_rec.time_zone <> l_new_time_zone) OR
309         ((res_rec.cost_per_hr is NULL) AND (l_new_cost_per_hr is NOT NULL)) OR
310         ((res_rec.cost_per_hr is NOT NULL) AND (l_new_cost_per_hr is NULL)) OR
311         (res_rec.cost_per_hr <> l_new_cost_per_hr) OR
312         ((res_rec.primary_language is NULL) AND (l_new_primary_language is NOT NULL)) OR
313         ((res_rec.primary_language is NOT NULL) AND (l_new_primary_language is NULL)) OR
314         (res_rec.primary_language <> l_new_primary_language) OR
315         ((res_rec.secondary_language is NULL) AND (l_new_secondary_language is NOT NULL)) OR
316         ((res_rec.secondary_language is NOT NULL) AND (l_new_secondary_language is NULL)) OR
317         (res_rec.secondary_language <> l_new_secondary_language) OR
318         ((res_rec.ies_agent_login is NULL) AND (l_new_ies_agent_login is NOT NULL)) OR
319         ((res_rec.ies_agent_login is NOT NULL) AND (l_new_ies_agent_login is NULL)) OR
320         (res_rec.ies_agent_login <> l_new_ies_agent_login) OR
321         ((res_rec.server_group_id is NULL) AND (l_new_server_group_id is NOT NULL)) OR
322         ((res_rec.server_group_id is NOT NULL) AND (l_new_server_group_id is NULL)) OR
323         (res_rec.server_group_id <> l_new_server_group_id) OR
324         ((res_rec.assigned_to_group_id is NULL) AND (l_new_assigned_to_group_id is NOT NULL)) OR
325         ((res_rec.assigned_to_group_id is NOT NULL) AND (l_new_assigned_to_group_id is NULL)) OR
326         (res_rec.assigned_to_group_id <> l_new_assigned_to_group_id) OR
327         ((res_rec.cost_center is NULL) AND (l_new_cost_center is NOT NULL)) OR
328         ((res_rec.cost_center is NOT NULL) AND (l_new_cost_center is NULL)) OR
329         (res_rec.cost_center <> l_new_cost_center) OR
330         ((res_rec.charge_to_cost_center is NULL) AND (l_new_charge_to_cost_center is NOT NULL)) OR
331         ((res_rec.charge_to_cost_center is NOT NULL) AND (l_new_charge_to_cost_center is NULL)) OR
332         (res_rec.charge_to_cost_center <> l_new_charge_to_cost_center) OR
333         ((res_rec.compensation_currency_code is NULL) AND (l_new_comp_currency_code is NOT NULL)) OR
334         ((res_rec.compensation_currency_code is NOT NULL) AND (l_new_comp_currency_code is NULL)) OR
335         (res_rec.compensation_currency_code <> l_new_comp_currency_code) OR
336         ((res_rec.commissionable_flag is NULL) AND (l_new_commissionable_flag is NOT NULL)) OR
337         ((res_rec.commissionable_flag is NOT NULL) AND (l_new_commissionable_flag is NULL)) OR
338         (res_rec.commissionable_flag <> l_new_commissionable_flag) OR
339         ((res_rec.hold_reason_code is NULL) AND (l_new_hold_reason_code is NOT NULL)) OR
340         ((res_rec.hold_reason_code is NOT NULL) AND (l_new_hold_reason_code is NULL)) OR
341         (res_rec.hold_reason_code <> l_new_hold_reason_code) OR
342         ((res_rec.hold_payment is NULL) AND (l_new_hold_payment is NOT NULL)) OR
343         ((res_rec.hold_payment is NOT NULL) AND (l_new_hold_payment is NULL)) OR
344         (res_rec.hold_payment <> l_new_hold_payment) OR
345         ((res_rec.comp_service_team_id is NULL) AND (l_new_comp_service_team_id is NOT NULL)) OR
346         ((res_rec.comp_service_team_id is NOT NULL) AND (l_new_comp_service_team_id is NULL)) OR
347         (res_rec.comp_service_team_id <> l_new_comp_service_team_id) OR
348         ((res_rec.support_site_id is NULL) AND (l_new_support_site_id is NOT NULL)) OR
349         ((res_rec.support_site_id is NOT NULL) AND (l_new_support_site_id is NULL)) OR
350         (res_rec.support_site_id <> l_new_support_site_id)
351        ) then
352 
353        l_event_name := 'oracle.apps.jtf.jres.resource.update.attributes';
354 
355        --Get the item key
356        l_key := item_key(l_event_name);
357 
358        -- initialization of object variables
359 
360        wf_event.AddParameterToList('RESOURCE_ID',l_resource_id,l_list);
361        wf_event.AddParameterToList('CATEGORY',l_category,l_list);
362        wf_event.AddParameterToList('OLD_RESOURCE_NAME',res_rec.resource_name,l_list);
363        wf_event.AddParameterToList('NEW_RESOURCE_NAME',l_new_resource_name,l_list);
364        wf_event.AddParameterToList('OLD_TIME_ZONE',res_rec.time_zone,l_list);
365        wf_event.AddParameterToList('NEW_TIME_ZONE',l_new_time_zone,l_list);
366        wf_event.AddParameterToList('OLD_COST_PER_HR',res_rec.cost_per_hr,l_list);
367        wf_event.AddParameterToList('NEW_COST_PER_HR',l_new_cost_per_hr,l_list);
368        wf_event.AddParameterToList('OLD_PRIMARY_LANGUAGE',res_rec.primary_language,l_list);
369        wf_event.AddParameterToList('NEW_PRIMARY_LANGUAGE',l_new_primary_language,l_list);
370        wf_event.AddParameterToList('OLD_SECONDARY_LANGUAGE',res_rec.secondary_language,l_list);
371        wf_event.AddParameterToList('NEW_SECONDARY_LANGUAGE',l_new_secondary_language,l_list);
372        wf_event.AddParameterToList('OLD_IES_AGENT_LOGIN',res_rec.ies_agent_login,l_list);
373        wf_event.AddParameterToList('NEW_IES_AGENT_LOGIN',l_new_ies_agent_login,l_list);
374        wf_event.AddParameterToList('OLD_SERVER_GROUP_ID',res_rec.server_group_id,l_list);
375        wf_event.AddParameterToList('NEW_SERVER_GROUP_ID',l_new_server_group_id,l_list);
376        wf_event.AddParameterToList('OLD_ASSIGNED_TO_GROUP_ID',res_rec.assigned_to_group_id,l_list);
377        wf_event.AddParameterToList('NEW_ASSIGNED_TO_GROUP_ID',l_new_assigned_to_group_id,l_list);
378        wf_event.AddParameterToList('OLD_COST_CENTER',res_rec.cost_center,l_list);
379        wf_event.AddParameterToList('NEW_COST_CENTER',l_new_cost_center,l_list);
380        wf_event.AddParameterToList('OLD_CHARGE_TO_COST_CENTER',res_rec.charge_to_cost_center,l_list);
381        wf_event.AddParameterToList('NEW_CHARGE_TO_COST_CENTER',l_new_charge_to_cost_center,l_list);
382        wf_event.AddParameterToList('OLD_COMPENSATION_CURRENCY_CODE',res_rec.compensation_currency_code,l_list);
383        wf_event.AddParameterToList('NEW_COMPENSATION_CURRENCY_CODE',l_new_comp_currency_code,l_list);
384        wf_event.AddParameterToList('OLD_COMMISSIONABLE_FLAG',res_rec.commissionable_flag,l_list);
385        wf_event.AddParameterToList('NEW_COMMISSIONABLE_FLAG',l_new_commissionable_flag,l_list);
386        wf_event.AddParameterToList('OLD_HOLD_REASON_CODE',res_rec.hold_reason_code,l_list);
387        wf_event.AddParameterToList('NEW_HOLD_REASON_CODE',l_new_hold_reason_code,l_list);
388        wf_event.AddParameterToList('OLD_HOLD_PAYMENT',res_rec.hold_payment,l_list);
389        wf_event.AddParameterToList('NEW_HOLD_PAYMENT',l_new_hold_payment,l_list);
390        wf_event.AddParameterToList('OLD_COMP_SERVICE_TEAM_ID',res_rec.comp_service_team_id,l_list);
391        wf_event.AddParameterToList('NEW_COMP_SERVICE_TEAM_ID',l_new_comp_service_team_id,l_list);
392        wf_event.AddParameterToList('OLD_SUPPORT_SITE_ID',res_rec.support_site_id,l_list);
393        wf_event.AddParameterToList('NEW_SUPPORT_SITE_ID',l_new_support_site_id,l_list);
394 
395        -- Raise Event
396        wf_event.raise(
397                       p_event_name        => l_event_name
398                      ,p_event_key         => l_key
399                      ,p_parameters        => l_list
400                      );
401 
402        l_list.DELETE;
403 
404     end if;
405 
406     CLOSE res_cur;
407 
408     EXCEPTION when OTHERS then
409        ROLLBACK TO upd_emp_publish_save;
410        x_return_status := fnd_api.g_ret_sts_unexp_error;
411 
412  END update_resource;
413 
414   PROCEDURE delete_resource
415   (P_API_VERSION        IN      NUMBER,
416    P_INIT_MSG_LIST      IN      VARCHAR2,
417    P_COMMIT             IN      VARCHAR2,
418    P_RESOURCE_ID        IN      NUMBER,
419    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
420    X_MSG_COUNT          OUT     NOCOPY NUMBER,
421    X_MSG_DATA           OUT     NOCOPY VARCHAR2
422   ) IS
423 
424    l_api_version         CONSTANT NUMBER := 1.0;
425    l_api_name            CONSTANT VARCHAR2(30) := 'DELETE_RESOURCE';
426 
427    l_sysdate             date  := trunc(sysdate);
428 
429    l_list                   WF_PARAMETER_LIST_T;
430    l_key                    varchar2(240);
431    l_exist                  varchar2(30);
432    l_event_name             varchar2(240) := 'oracle.apps.jtf.jres.resource.delete';
433    l_resource_id            jtf_rs_resource_extns.resource_id%type := p_resource_id;
434 
435  BEGIN
436 
437     x_return_status := fnd_api.g_ret_sts_success;
438     savepoint del_emp_publish_save;
439 
440     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
441        RAISE fnd_api.g_exc_unexpected_error;
442     END IF;
443 
444     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
445     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
446     then
447        fnd_msg_pub.Initialize;
448     end if;
449 
450     --Get the item key
451     l_key := item_key(l_event_name);
452 
453     -- initialization of object variables
454 
455     wf_event.AddParameterToList('RESOURCE_ID',l_resource_id,l_list);
456 
457     -- Raise Event
458     wf_event.raise(
459                    p_event_name        => l_event_name
460                   ,p_event_key         => l_key
461                   ,p_parameters        => l_list
462                   );
463 
464     l_list.DELETE;
465 
466     EXCEPTION when OTHERS then
467        ROLLBACK TO del_emp_publish_save;
468        x_return_status := fnd_api.g_ret_sts_unexp_error;
469  END delete_resource;
470 
471 
472   PROCEDURE create_resource_role
473   (P_API_VERSION        IN      NUMBER,
474    P_INIT_MSG_LIST      IN      VARCHAR2,
475    P_COMMIT             IN      VARCHAR2,
476    P_ROLE_ID            IN      NUMBER,
477    P_ROLE_TYPE_CODE     IN      VARCHAR2,
478    P_ROLE_CODE          IN      VARCHAR2,
479    P_ROLE_NAME          IN      VARCHAR2,
480    P_ROLE_DESC          IN      VARCHAR2,
481    P_ACTIVE_FLAG        IN      VARCHAR2,
482    P_MEMBER_FLAG        IN      VARCHAR2,
483    P_ADMIN_FLAG         IN      VARCHAR2,
484    P_LEAD_FLAG          IN      VARCHAR2,
485    P_MANAGER_FLAG       IN      VARCHAR2,
486    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
487    X_MSG_COUNT          OUT     NOCOPY NUMBER,
488    X_MSG_DATA           OUT     NOCOPY VARCHAR2
489    ) IS
490 
491    l_api_version            CONSTANT NUMBER := 1.0;
492    l_api_name               CONSTANT VARCHAR2(30) := 'CREATE_RESOURCE_ROLE';
493    l_sysdate                date  := trunc(sysdate);
494 
495    l_list                   WF_PARAMETER_LIST_T;
496    l_key                    varchar2(240);
497    l_exist                  varchar2(30);
498    l_event_name             varchar2(240) := 'oracle.apps.jtf.jres.role.create';
499 
500    l_role_id                jtf_rs_roles_b.role_id%type := p_role_id;
501    l_role_type_code         jtf_rs_roles_b.role_type_code%type := p_role_type_code;
502    l_role_code              jtf_rs_roles_b.role_code%type := p_role_code;
503    l_role_name              jtf_rs_roles_tl.role_name%type := p_role_name;
504    l_role_desc              jtf_rs_roles_tl.role_desc%type := p_role_desc;
505    l_active_flag            jtf_rs_roles_b.active_flag%type := p_active_flag;
506    l_member_flag            jtf_rs_roles_b.member_flag%type := p_member_flag;
507    l_admin_flag             jtf_rs_roles_b.admin_flag%type := p_admin_flag;
508    l_lead_flag              jtf_rs_roles_b.lead_flag%type := p_lead_flag;
509    l_manager_flag           jtf_rs_roles_b.manager_flag%type := p_manager_flag;
510 
511  BEGIN
512 
513     x_return_status := fnd_api.g_ret_sts_success;
514     savepoint cr_res_role_publish_save;
515 
516     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
517        RAISE fnd_api.g_exc_unexpected_error;
518     END IF;
519 
520     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
521     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
522     then
523        fnd_msg_pub.Initialize;
524     end if;
525 
526     --Get the item key
527     l_key := item_key(l_event_name);
528 
529     -- initialization of object variables
530 
531     wf_event.AddParameterToList('ROLE_ID',l_role_id,l_list);
532     wf_event.AddParameterToList('ROLE_TYPE_CODE',l_role_type_code,l_list);
533     wf_event.AddParameterToList('ROLE_CODE',l_role_code,l_list);
534     wf_event.AddParameterToList('ROLE_NAME',l_role_name,l_list);
535     wf_event.AddParameterToList('ROLE_DESC',l_role_desc,l_list);
536     wf_event.AddParameterToList('ACTIVE_FLAG',l_active_flag,l_list);
537     wf_event.AddParameterToList('MEMBER_FLAG',l_member_flag,l_list);
538     wf_event.AddParameterToList('ADMIN_FLAG',l_admin_flag,l_list);
539     wf_event.AddParameterToList('LEAD_FLAG',l_lead_flag,l_list);
540     wf_event.AddParameterToList('MANAGER_FLAG',l_manager_flag,l_list);
541 
542     -- Raise Event
543     wf_event.raise(
544                    p_event_name        => l_event_name
545                   ,p_event_key         => l_key
546                   ,p_parameters        => l_list
547                   );
548 
549     l_list.DELETE;
550 
551     EXCEPTION when OTHERS then
552        ROLLBACK TO cr_res_role_publish_save;
553        x_return_status := fnd_api.g_ret_sts_unexp_error;
554 
555  END create_resource_role;
556 
557 
558   PROCEDURE update_resource_role
559   (P_API_VERSION        IN      NUMBER,
560    P_INIT_MSG_LIST      IN      VARCHAR2,
561    P_COMMIT             IN      VARCHAR2,
562    P_RESOURCE_ROLE_REC  IN      jtf_rs_roles_pvt.RESOURCE_ROLE_REC_TYPE,
563    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
564    X_MSG_COUNT          OUT     NOCOPY NUMBER,
565    X_MSG_DATA           OUT     NOCOPY VARCHAR2
566   ) IS
567 
568    l_api_version         CONSTANT NUMBER := 1.0;
569    l_api_name            CONSTANT VARCHAR2(30) := 'UPDATE_RESOURCE_ROLE';
570 
571    l_sysdate                   date  := trunc(sysdate);
572 
573    l_list                       WF_PARAMETER_LIST_T;
574    l_key                        varchar2(240);
575    l_exist                      varchar2(30);
576    l_event_name                 varchar2(240) := 'oracle.apps.jtf.jres.role.update';
577 
578    l_role_id                    jtf_rs_roles_b.role_id%type := p_resource_role_rec.role_id;
579    l_new_role_type_code         jtf_rs_roles_b.role_type_code%type := p_resource_role_rec.role_type_code;
580    l_new_role_code              jtf_rs_roles_b.role_code%type := p_resource_role_rec.role_code;
581    l_new_role_name              jtf_rs_roles_tl.role_name%type := p_resource_role_rec.role_name;
582    l_new_role_desc              jtf_rs_roles_tl.role_desc%type := p_resource_role_rec.role_desc;
583    l_new_active_flag            jtf_rs_roles_b.active_flag%type := p_resource_role_rec.active_flag;
584    l_new_member_flag            jtf_rs_roles_b.member_flag%type := p_resource_role_rec.member_flag;
585    l_new_admin_flag             jtf_rs_roles_b.admin_flag%type := p_resource_role_rec.admin_flag;
586    l_new_lead_flag              jtf_rs_roles_b.lead_flag%type := p_resource_role_rec.lead_flag;
587    l_new_manager_flag           jtf_rs_roles_b.manager_flag%type := p_resource_role_rec.manager_flag;
588 
589    cursor res_role_cur IS
590    select
591           role_id,
592           role_type_code,
593           role_code,
594           role_name,
595           role_desc,
596           active_flag,
597           member_flag,
598           admin_flag,
599           lead_flag,
600           manager_flag
601    from   jtf_rs_roles_vl
602    where  role_id  = p_resource_role_rec.role_id;
603 
604    res_role_rec  res_role_cur%rowtype;
605 
606  BEGIN
607 
608     x_return_status := fnd_api.g_ret_sts_success;
609     savepoint upd_res_role_publish_save;
610 
611     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
612        RAISE fnd_api.g_exc_unexpected_error;
613     END IF;
614 
615     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
616     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
617     then
618        fnd_msg_pub.Initialize;
619     end if;
620 
621     OPEN res_role_cur;
622     FETCH res_role_cur INTO res_role_rec;
623 
624     /* If any of the following attributes changes, raise the event oracle.apps.jtf.jres.role.update */
625 
626     if ((res_role_rec.role_type_code <> l_new_role_type_code) OR
627         (res_role_rec.role_code <> l_new_role_code) OR
628         (res_role_rec.role_name <> l_new_role_name) OR
629         ((res_role_rec.role_desc is NULL) AND (l_new_role_desc is NOT NULL)) OR
630         ((res_role_rec.role_desc is NOT NULL) AND (l_new_role_desc is NULL)) OR
631         (res_role_rec.role_desc <> l_new_role_desc) OR
632         (res_role_rec.active_flag <> l_new_active_flag) OR
633         (nvl(res_role_rec.member_flag,'X') <> nvl(l_new_member_flag,'X')) OR
634         (nvl(res_role_rec.admin_flag,'X') <> nvl(l_new_admin_flag,'X')) OR
635         (nvl(res_role_rec.lead_flag,'X') <> nvl(l_new_lead_flag,'X')) OR
636         (nvl(res_role_rec.manager_flag,'X') <> nvl(l_new_manager_flag,'X'))
637        ) then
638 
639        --Get the item key
640        l_key := item_key(l_event_name);
641 
642        -- initialization of object variables
643 
644        wf_event.AddParameterToList('ROLE_ID',l_role_id,l_list);
645        wf_event.AddParameterToList('OLD_ROLE_TYPE_CODE',res_role_rec.role_type_code,l_list);
646        wf_event.AddParameterToList('NEW_ROLE_TYPE_CODE',l_new_role_type_code,l_list);
647        wf_event.AddParameterToList('OLD_ROLE_CODE',res_role_rec.role_code,l_list);
648        wf_event.AddParameterToList('NEW_ROLE_CODE',l_new_role_code,l_list);
649        wf_event.AddParameterToList('OLD_ROLE_NAME',res_role_rec.role_name,l_list);
650        wf_event.AddParameterToList('NEW_ROLE_NAME',l_new_role_name,l_list);
651        wf_event.AddParameterToList('OLD_ROLE_DESC',res_role_rec.role_desc,l_list);
652        wf_event.AddParameterToList('NEW_ROLE_DESC',l_new_role_desc,l_list);
653        wf_event.AddParameterToList('OLD_ACTIVE_FLAG',res_role_rec.active_flag,l_list);
654        wf_event.AddParameterToList('NEW_ACTIVE_FLAG',l_new_active_flag,l_list);
655        wf_event.AddParameterToList('OLD_MEMBER_FLAG',res_role_rec.member_flag,l_list);
656        wf_event.AddParameterToList('NEW_MEMBER_FLAG',l_new_member_flag,l_list);
657        wf_event.AddParameterToList('OLD_ADMIN_FLAG',res_role_rec.admin_flag,l_list);
658        wf_event.AddParameterToList('NEW_ADMIN_FLAG',l_new_admin_flag,l_list);
659        wf_event.AddParameterToList('OLD_LEAD_FLAG',res_role_rec.lead_flag,l_list);
660        wf_event.AddParameterToList('NEW_LEAD_FLAG',l_new_lead_flag,l_list);
661        wf_event.AddParameterToList('OLD_MANAGER_FLAG',res_role_rec.manager_flag,l_list);
662        wf_event.AddParameterToList('NEW_MANAGER_FLAG',l_new_manager_flag,l_list);
663 
664        -- Raise Event
665        wf_event.raise(
666                       p_event_name        => l_event_name
667                      ,p_event_key         => l_key
668                      ,p_parameters        => l_list
669                      );
670 
671        l_list.DELETE;
672 
673     end if;
674 
675     CLOSE res_role_cur;
676 
677     EXCEPTION when OTHERS then
678        ROLLBACK TO upd_res_role_publish_save;
679        x_return_status := fnd_api.g_ret_sts_unexp_error;
680 
681  END update_resource_role;
682 
683  PROCEDURE delete_resource_role
684   (P_API_VERSION        IN      NUMBER,
685    P_INIT_MSG_LIST      IN      VARCHAR2,
686    P_COMMIT             IN      VARCHAR2,
687    P_ROLE_ID	        IN      NUMBER,
688    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
689    X_MSG_COUNT          OUT     NOCOPY NUMBER,
690    X_MSG_DATA           OUT     NOCOPY VARCHAR2
691   ) IS
692 
693    l_api_version         CONSTANT NUMBER := 1.0;
694    l_api_name            CONSTANT VARCHAR2(30) := 'DELETE_RESOURCE_ROLE';
695 
696    l_sysdate             date  := trunc(sysdate);
697 
698    l_list                WF_PARAMETER_LIST_T;
699    l_key                 varchar2(240);
700    l_exist               varchar2(30);
701    l_event_name          varchar2(240) := 'oracle.apps.jtf.jres.role.delete';
702 
703    l_role_id             jtf_rs_roles_b.role_id%type := p_role_id;
704 
705  BEGIN
706 
707     x_return_status := fnd_api.g_ret_sts_success;
708     savepoint del_res_role_publish_save;
709 
710     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
711        RAISE fnd_api.g_exc_unexpected_error;
712     END IF;
713 
714     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
715     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
716     then
717        fnd_msg_pub.Initialize;
718     end if;
719 
720     --Get the item key
721     l_key := item_key(l_event_name);
722 
723     -- initialization of object variables
724 
725     wf_event.AddParameterToList('ROLE_ID',l_role_id,l_list);
726 
727     -- Raise Event
728     wf_event.raise(
729                    p_event_name        => l_event_name
730                   ,p_event_key         => l_key
731                   ,p_parameters        => l_list
732                   );
733 
734     l_list.DELETE;
735 
736     EXCEPTION when OTHERS then
737        ROLLBACK TO del_res_role_publish_save;
738        x_return_status := fnd_api.g_ret_sts_unexp_error;
739  END delete_resource_role;
740 
741 
742  PROCEDURE create_resource_role_relate
743   (P_API_VERSION        IN      NUMBER,
744    P_INIT_MSG_LIST      IN      VARCHAR2,
745    P_COMMIT             IN      VARCHAR2,
746    P_ROLE_RELATE_ID     IN      NUMBER,
747    P_ROLE_RESOURCE_TYPE IN      VARCHAR2,
748    P_ROLE_RESOURCE_ID   IN      NUMBER,
749    P_ROLE_ID            IN      NUMBER,
750    P_START_DATE_ACTIVE  IN      DATE,
751    P_END_DATE_ACTIVE    IN      DATE,
752    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
753    X_MSG_COUNT          OUT     NOCOPY NUMBER,
754    X_MSG_DATA           OUT     NOCOPY VARCHAR2
755    ) IS
756 
757    l_api_version            CONSTANT NUMBER := 1.0;
758    l_api_name               CONSTANT VARCHAR2(30) := 'CREATE_RESOURCE_ROLE_RELATE';
759    l_sysdate                date  := trunc(sysdate);
760 
761    l_list                   WF_PARAMETER_LIST_T;
762    l_key                    varchar2(240);
763    l_exist                  varchar2(30);
764    l_event_name             varchar2(240) := 'oracle.apps.jtf.jres.rolerelate.create';
765 
766    l_role_relate_id         jtf_rs_role_relations.role_relate_id%type      := p_role_relate_id;
767    l_role_resource_type     jtf_rs_role_relations.role_resource_type%type  := p_role_resource_type;
768    l_role_resource_id       jtf_rs_role_relations.role_resource_id%type    := p_role_resource_id;
769    l_role_id                jtf_rs_role_relations.role_id%type             := p_role_id;
770    l_start_date_active      jtf_rs_role_relations.start_date_active%type   := trunc(p_start_date_active);
771    l_end_date_active        jtf_rs_role_relations.end_date_active%type     := trunc(p_end_date_active);
772 
773 
774  BEGIN
775 
776     x_return_status := fnd_api.g_ret_sts_success;
777     savepoint cr_rolerelate_publish_save;
778 
779     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
780        RAISE fnd_api.g_exc_unexpected_error;
781     END IF;
782 
783     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
784     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
785     then
786        fnd_msg_pub.Initialize;
787     end if;
788 
789     --Get the item key
790     l_key := item_key(l_event_name);
791 
792     -- initialization of object variables
793 
794     wf_event.AddParameterToList('ROLE_RELATE_ID',l_role_relate_id,l_list);
795     wf_event.AddParameterToList('ROLE_RESOURCE_TYPE',l_role_resource_type,l_list);
796     wf_event.AddParameterToList('ROLE_RESOURCE_ID',l_role_resource_id,l_list);
797     wf_event.AddParameterToList('ROLE_ID',l_role_id,l_list);
798     wf_event.AddParameterToList('START_DATE_ACTIVE',l_start_date_active,l_list);
799     wf_event.AddParameterToList('END_DATE_ACTIVE',l_end_date_active,l_list);
800 
801     -- Raise Event
802     wf_event.raise(
803                    p_event_name        => l_event_name
804                   ,p_event_key         => l_key
805                   ,p_parameters        => l_list
806                   );
807 
808     l_list.DELETE;
809 
810     EXCEPTION when OTHERS then
811        ROLLBACK TO cr_rolerelate_publish_save;
812        x_return_status := fnd_api.g_ret_sts_unexp_error;
813 
814  END create_resource_role_relate;
815 
816 
817  PROCEDURE update_resource_role_relate
818   (P_API_VERSION                IN      NUMBER,
819    P_INIT_MSG_LIST              IN      VARCHAR2,
820    P_COMMIT                     IN      VARCHAR2,
821    P_ROLE_RELATE_ID             IN      NUMBER,
822    P_ROLE_RESOURCE_TYPE         IN      VARCHAR2,
823    P_ROLE_RESOURCE_ID           IN      NUMBER,
824    P_ROLE_ID                    IN      NUMBER,
825    P_START_DATE_ACTIVE          IN      DATE,
826    P_END_DATE_ACTIVE            IN      DATE,
827    X_RETURN_STATUS              OUT     NOCOPY VARCHAR2,
828    X_MSG_COUNT                  OUT     NOCOPY NUMBER,
829    X_MSG_DATA                   OUT     NOCOPY VARCHAR2
830   ) IS
831 
832    l_api_version                CONSTANT NUMBER := 1.0;
833    l_api_name                   CONSTANT VARCHAR2(30) := 'UPDATE_RESOURCE_ROLE_RELATE';
834 
835    l_sysdate                    date  := trunc(sysdate);
836 
837    l_list                       WF_PARAMETER_LIST_T;
838    l_key                        varchar2(240);
839    l_exist                      varchar2(30);
840    l_event_name                 varchar2(240) := 'oracle.apps.jtf.jres.rolerelate.update';
841 
842    l_role_relate_id             jtf_rs_role_relations.role_relate_id%type      := p_role_relate_id;
843    l_role_resource_type         jtf_rs_role_relations.role_resource_type%type  := p_role_resource_type;
844    l_role_resource_id           jtf_rs_role_relations.role_resource_id%type    := p_role_resource_id;
845    l_role_id                    jtf_rs_role_relations.role_id%type             := p_role_id;
846    l_new_start_date_active      jtf_rs_role_relations.start_date_active%type   := trunc(p_start_date_active);
847    l_new_end_date_active        jtf_rs_role_relations.end_date_active%type     := trunc(p_end_date_active);
848 
849    cursor res_rolerelate_cur IS
850    select trunc(start_date_active) start_date_active,
851           trunc(end_date_active) end_date_active
852    from   jtf_rs_role_relations
853    where  role_relate_id  = p_role_relate_id;
854 
855    res_rolerelate_rec  res_rolerelate_cur%rowtype;
856 
857  BEGIN
858 
859     x_return_status := fnd_api.g_ret_sts_success;
860     savepoint upd_rolerelate_publish_save;
861 
862     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
863        RAISE fnd_api.g_exc_unexpected_error;
864     END IF;
865 
866     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
867     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
868     then
869        fnd_msg_pub.Initialize;
870     end if;
871 
872     OPEN res_rolerelate_cur;
873     FETCH res_rolerelate_cur INTO res_rolerelate_rec;
874 
875     /* If any of the following attributes changes, raise the event oracle.apps.jtf.jres.rolerelate.update */
876 
877     if (((res_rolerelate_rec.end_date_active is NULL) AND (l_new_end_date_active is NOT NULL)) OR
878         ((res_rolerelate_rec.end_date_active is NOT NULL) AND (l_new_end_date_active is NULL)) OR
879         (res_rolerelate_rec.end_date_active <> l_new_end_date_active) OR
880         (res_rolerelate_rec.start_date_active <> l_new_start_date_active)
881        ) then
882 
883        --Get the item key
884        l_key := item_key(l_event_name);
885 
886        -- initialization of object variables
887 
888        wf_event.AddParameterToList('ROLE_RELATE_ID',l_role_relate_id,l_list);
889        wf_event.AddParameterToList('ROLE_RESOURCE_TYPE',l_role_resource_type,l_list);
890        wf_event.AddParameterToList('ROLE_RESOURCE_ID',l_role_resource_id,l_list);
891        wf_event.AddParameterToList('ROLE_ID',l_role_id,l_list);
892        wf_event.AddParameterToList('OLD_START_DATE_ACTIVE',res_rolerelate_rec.start_date_active,l_list);
893        wf_event.AddParameterToList('NEW_START_DATE_ACTIVE',l_new_start_date_active,l_list);
894        wf_event.AddParameterToList('OLD_END_DATE_ACTIVE',res_rolerelate_rec.end_date_active,l_list);
895        wf_event.AddParameterToList('NEW_END_DATE_ACTIVE',l_new_end_date_active,l_list);
896 
897        -- Raise Event
898        wf_event.raise(
899                       p_event_name        => l_event_name
900                      ,p_event_key         => l_key
901                      ,p_parameters        => l_list
902                      );
903 
904        l_list.DELETE;
905 
906     end if;
907 
908     CLOSE res_rolerelate_cur;
909 
910     EXCEPTION when OTHERS then
911        ROLLBACK TO upd_rolerelate_publish_save;
912        x_return_status := fnd_api.g_ret_sts_unexp_error;
913 
914  END update_resource_role_relate;
915 
916  PROCEDURE delete_resource_role_relate
917   (P_API_VERSION        IN      NUMBER,
918    P_INIT_MSG_LIST      IN      VARCHAR2,
919    P_COMMIT             IN      VARCHAR2,
920    P_ROLE_RELATE_ID     IN      NUMBER,
921    X_RETURN_STATUS      OUT     NOCOPY VARCHAR2,
922    X_MSG_COUNT          OUT     NOCOPY NUMBER,
923    X_MSG_DATA           OUT     NOCOPY VARCHAR2
924   ) IS
925 
926    l_api_version         CONSTANT NUMBER := 1.0;
927    l_api_name            CONSTANT VARCHAR2(30) := 'DELETE_RESOURCE_ROLE_RELATE';
928 
929    l_sysdate             date  := trunc(sysdate);
930 
931    l_list                WF_PARAMETER_LIST_T;
932    l_key                 varchar2(240);
933    l_exist               varchar2(30);
934    l_event_name          varchar2(240) := 'oracle.apps.jtf.jres.rolerelate.delete';
935 
936    l_role_relate_id      jtf_rs_role_relations.role_relate_id%type      := p_role_relate_id;
937 
938    cursor del_rolerelate_cur IS
939    select role_resource_type,
940           role_resource_id,
941           role_id
942    from   jtf_rs_role_relations
943    where  role_relate_id  = p_role_relate_id
944    and    nvl(delete_flag,'N') = 'Y';
945 
946    del_rolerelate_rec  del_rolerelate_cur%rowtype;
947 
948  BEGIN
949 
950     x_return_status := fnd_api.g_ret_sts_success;
951     savepoint del_rolerelate_publish_save;
952 
953     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
954        RAISE fnd_api.g_exc_unexpected_error;
955     END IF;
956 
957     --Initialize the message List if P_INIT_MSG_LIST is NOT NULL and set to TRUE
958     if p_init_msg_list is not NULL AND fnd_api.to_boolean(p_init_msg_list)
959     then
960        fnd_msg_pub.Initialize;
961     end if;
962 
963     OPEN del_rolerelate_cur;
964     FETCH del_rolerelate_cur INTO del_rolerelate_rec;
965 
966     --Get the item key
967     l_key := item_key(l_event_name);
968 
969     -- initialization of object variables
970 
971     wf_event.AddParameterToList('ROLE_RELATE_ID',l_role_relate_id,l_list);
972     wf_event.AddParameterToList('ROLE_RESOURCE_TYPE',del_rolerelate_rec.role_resource_type,l_list);
973     wf_event.AddParameterToList('ROLE_RESOURCE_ID',del_rolerelate_rec.role_resource_id,l_list);
974     wf_event.AddParameterToList('ROLE_ID',del_rolerelate_rec.role_id,l_list);
975 
976     -- Raise Event
977     wf_event.raise(
978                    p_event_name        => l_event_name
979                   ,p_event_key         => l_key
980                   ,p_parameters        => l_list
981                   );
982 
983     l_list.DELETE;
984 
985     CLOSE del_rolerelate_cur;
986 
987     EXCEPTION when OTHERS then
988        ROLLBACK TO del_rolerelate_publish_save;
989        x_return_status := fnd_api.g_ret_sts_unexp_error;
990  END delete_resource_role_relate;
991 
992 END jtf_rs_wf_events_pub;