[Home] [Help]
PACKAGE BODY: APPS.CN_EVENT_LOG_PKG
Source
1 PACKAGE BODY cn_event_log_pkg AS
2 -- $Header: cnsyevlb.pls 115.5 2002/11/21 21:08:28 hlchen ship $
3
4
5 --
6 -- Public Procedures
7 --
8
9
10 PROCEDURE Event_Log (
11 X_event_log_id IN OUT NOCOPY number,
12 X_event_name IN varchar2,
13 X_form_name IN varchar2,
14 X_object_id IN number,
15 X_object_type IN varchar2,
16 X_object_name IN varchar2,
17 X_delete_ndays IN number) IS
18
19 X_user_id NUMBER(15) ;
20
21 BEGIN
22
23 -- Get Current FND User ID.
24 X_user_id := FND_GLOBAL.USER_ID ;
25
26 -- Get Next Event Log sequence number.
27 -- This is returned to the caller for use in the Notify_Log call.
28 SELECT cn_event_log_s.NEXTVAL
29 INTO X_event_log_id
30 FROM sys.dual;
31
32 -- Update Event Log with event information
33 INSERT INTO cn_event_log(
34 event_log_id,
35 event_log_date,
36 delete_date,
37 event_name,
38 form_name,
39 user_id,
40 object_id,
41 object_type,
42 object_name)
43
44 VALUES(X_event_log_id,
45 SYSDATE,
46 (SYSDATE+X_delete_ndays),
47 X_event_name,
48 X_form_name,
49 X_user_id,
50 X_object_id,
51 X_object_type,
52 X_object_name) ;
53
54 END Event_Log;
55
56
57
58 PROCEDURE Notify_Log (
59 X_event_log_id IN number,
60 X_notify_name IN varchar2,
61 X_notify_action IN varchar2,
62 X_object_owner_id IN number,
63 X_object_id IN number,
64 X_object_type IN varchar2,
65 X_object_name IN varchar2,
66 X_status IN varchar2,
67 X_priority IN number,
68 X_delete_ndays IN number) IS
69
70 BEGIN
71
72 -- Update Notify Log with notify information
73 INSERT INTO cn_notify_log(
74 notify_log_id,
75 notify_log_date,
76 delete_date,
77
78 event_log_id,
79 notify_name,
80 notify_action,
81
82 object_owner_id,
83 object_id,
84 object_type,
85 object_name,
86
87 status,
88 priority)
89
90 VALUES(cn_notify_log_s.NEXTVAL,
91 SYSDATE,
92 (SYSDATE+X_delete_ndays),
93
94 X_event_log_id,
95 X_notify_name,
96 X_notify_action,
97
98 X_object_owner_id,
99 X_object_id,
100 X_object_type,
101 X_object_name,
102
103 X_status,
104 X_priority) ;
105
106 END Notify_Log;
107
108
109
110 PROCEDURE Comp_Plan_Event( X_comp_plan_id IN number) IS
111
112 X_event_log_id NUMBER(15) ;
113 X_plan_name cn_comp_plans.name%TYPE;
114 X_owner_id cn_salesreps.assigned_to_user_id%TYPE;
115 X_rep_id cn_salesreps.salesrep_id%TYPE;
116 X_rep_name cn_salesreps.name%TYPE;
117
118
119 CURSOR A1_cursor IS
120 SELECT sr.salesrep_id, sr.name, sr.assigned_to_user_id
121 FROM cn_salesreps sr
122 WHERE sr.salesrep_id IN (SELECT pa.salesrep_id
123 FROM cn_srp_plan_assigns pa
124 WHERE pa.comp_plan_id = X_comp_plan_id) ;
125
126 BEGIN
127
128 BEGIN
129 -- Get Comp Plan Name.
130 SELECT name
131 INTO X_plan_name
132 FROM cn_comp_plans
133 WHERE comp_plan_id = X_comp_plan_id ;
134
135 EXCEPTION
136 WHEN no_data_found THEN
137 -- Prevents ora-err after when called after deletion of plan
138 RETURN;
139 END;
140
141
142 -- Log the Event.
143 Event_Log( X_event_log_id => X_event_log_id,
144 X_event_name => 'Comp Plan Changed',
145 X_form_name => 'Comp Plans' ,
146 X_object_id => X_comp_plan_id,
147 X_object_type => 'Comp Plan',
148 X_object_name => X_plan_name ,
149 X_delete_ndays => 30 ) ;
150
151
152
153 -- For each commissions analyst in the A1_cursor group
154 -- Log the Notify event.
155
156 OPEN A1_cursor ;
157 LOOP
158 FETCH A1_cursor
159 INTO X_rep_id, X_rep_name, X_owner_id ;
160
161 EXIT WHEN A1_cursor%NOTFOUND ;
162
163 -- Log the Notify event.
164 Notify_Log( X_event_log_id => X_event_log_id,
165 X_notify_name => 'Comp Plan Changed',
166 X_notify_action => 'Recalc Salesrep',
167 X_object_owner_id => X_owner_id,
168 X_object_id => X_rep_id,
169 X_object_type => 'Salesrep',
170 X_object_name => X_rep_name,
171 X_status => 'Incomplete',
172 X_priority => 1 ,
173 X_delete_ndays => 30 ) ;
174
175 END LOOP ;
176 CLOSE A1_cursor ;
177
178 END Comp_Plan_Event ;
179
180
181
182 END cn_event_log_pkg;