DBA Data[Home] [Help]

PACKAGE BODY: APPS.IES_TELESALES_BP_PKG

Source


1 PACKAGE BODY IES_TELESALES_BP_PKG AS
2 /* $Header: iestsbpb.pls 120.1 2005/06/16 11:16:32 appldev  $ */
3 PROCEDURE create_sales_lead(
4  p_api_version number,
5  p_user_name varchar2,
6  p_customer_id number,
7  p_contact_id number,
8  p_project_name varchar2,
9  p_channel_code varchar2,
10  p_budget_amount number,
11  p_budget_status_code varchar2,
12  p_currency_code varchar2,
13  p_decision_timeframe_code varchar2,
14  p_description varchar2,
15  p_source_promotion_id number,
16  p_status_code varchar2,
17  p_interest_type_id number,
18  p_primary_interest_code_id number,
19  p_secondary_interest_code_id number,
20  x_sales_lead_id OUT NOCOPY /* file.sql.39 change */ number,
21  x_return_status OUT NOCOPY /* file.sql.39 change */ varchar2,
22  x_msg_count OUT NOCOPY /* file.sql.39 change */ number,
23  x_msg_data OUT NOCOPY /* file.sql.39 change */ varchar2
24  )
25 is
26   l_msg_data		  VARCHAR2(2000);
27   my_message          VARCHAR2(2000);
28 BEGIN
29 
30  x_sales_lead_id := 0;
31  x_msg_count := 1;
32  FND_MESSAGE.SET_NAME ('IES', 'IES_LEAD_API_OBSOLETE');
33  l_msg_data   := FND_MESSAGE.GET;
34  x_msg_data := l_msg_data;
35  return;
36 
37 END CREATE_SALES_LEAD;
38 
39 PROCEDURE CREATE_INTEREST(
40  p_api_version number,
41  p_user_name varchar2,
42  p_party_type varchar2,
43  p_party_id number,
44  p_party_site_id number,
45  p_contact_id number,
46  p_interest_type_id number,
47  p_primary_interest_code_id number,
48  p_secondary_interest_code_id number,
49  x_interest_id OUT NOCOPY /* file.sql.39 change */ number,
50  x_return_status OUT NOCOPY /* file.sql.39 change */ varchar2,
51  x_msg_count OUT NOCOPY /* file.sql.39 change */ number,
52  x_msg_data OUT NOCOPY /* file.sql.39 change */ varchar2
53  )
54 is
55 l_user_id number;
56 l_interest_rec AS_INTEREST_PUB.interest_rec_type;
57 l_interest_use_code varchar2(80);
58 l_return_status varchar2(10);
59 l_msg_data varchar2(4000);
60 l_msg_count number;
61 l_count number;
62 l_interest_out_id number;
63 my_message varchar2(2000);
64 
65 begin
66 
67  	SELECT user_id
68  	INTO   l_user_id
69  	FROM   FND_USER
70  	where user_name = p_user_name;
71 
72 	FND_GLOBAL.apps_initialize(l_user_id, null, null, null);
73 
74   	l_interest_rec.interest_type_id := p_interest_type_id;
75   	l_interest_rec.primary_interest_code_id  := p_primary_interest_code_id;
76   	l_interest_rec.secondary_interest_code_id  := p_secondary_interest_code_id;
77 
78 	if p_party_type = 'PERSON' then
79 		l_interest_use_code := 'CONTACT_INTEREST';
80 	elsif p_party_type = 'ORGANIZATION' then
81 		l_interest_use_code := 'COMPANY_CLASSIFICATION' ;
82 	end if;
83 
84 	AS_INTEREST_PUB.Create_Interest(
85 				p_api_version_number     => 2.0 ,
86 			     p_init_msg_list          => FND_API.G_FALSE,
87 			     p_commit                 => FND_API.G_FALSE,
88 				p_interest_rec           => l_interest_rec,
89 				p_customer_id            => p_party_id,
90 			     p_address_id             => p_party_site_id,
91 			     p_contact_id             => null,
92 			     p_lead_id                => null,
93 			     p_interest_use_code      => l_interest_use_code,
94 			     p_check_access_flag      => 'N',
95 				p_admin_flag             => null,
96 				p_admin_group_id         => null,
97 				p_identity_salesforce_id => null,
98 				p_access_profile_rec     => null,
99 				p_return_status          => l_return_status,
100 				p_msg_count              => l_msg_count,
101 				p_msg_data               => l_msg_data,
102 				p_interest_out_id        => l_interest_out_id);
103 
104 --	 DBMS_OUTPUT.PUT_LINE('x_return_status:' || l_return_status);
105 --	 DBMS_OUTPUT.PUT_LINE('x_msg_data:     ' || l_msg_data);
106 --	 DBMS_OUTPUT.PUT_LINE('x_msg_count:     ' || l_msg_count);
107 
108 
109  l_count := FND_MSG_PUB.Count_Msg;
110 -- dbms_output.put_line('There are ' || l_count || ' messages.');
111  FOR l_index IN 1..l_count LOOP
112     my_message := FND_MSG_PUB.Get(
113         p_msg_index   =>  l_index,
114        p_encoded     =>  FND_API.G_FALSE);
115 --    dbms_output.put_line(substr(my_message,1,255));
116  END LOOP;
117 
118 
119  x_return_status := l_return_status;
120  x_interest_id := l_interest_out_id;
121  x_msg_count := l_msg_count;
122  x_msg_data := l_msg_data;
123 
124 END CREATE_INTEREST;
125 
126 
127 PROCEDURE CREATE_OPP_FOR_LEAD(
128  p_api_version number,
129  p_user_name varchar2,
130  p_sales_lead_id number,
131  x_opp_id OUT NOCOPY /* file.sql.39 change */ number,
132  x_return_status OUT NOCOPY /* file.sql.39 change */ varchar2,
133  x_msg_count OUT NOCOPY /* file.sql.39 change */ number,
134  x_msg_data OUT NOCOPY /* file.sql.39 change */ varchar2)
135  is
136 
137   l_application_id   NUMBER := 279;
138   l_commit            VARCHAR2(10) := FND_API.G_FALSE;
139   l_return_status     VARCHAR2(10) := 'S';
140   l_msg_count         NUMBER  := 0;
141   l_msg_data          VARCHAR2(4000) default NULL;
142   l_opp_id NUMBER;
143   l_user_id    NUMBER;
144   l_resource_id    NUMBER;
145   l_count NUMBER := 0;
146   my_message          VARCHAR2(2000);
147 
148 BEGIN
149  SELECT user_id
150  INTO   l_user_id
151  FROM   FND_USER
152  where user_name = p_user_name;
153 
154  SELECT resource_id
155  INTO   l_resource_id
156  FROM  jtf_rs_resource_extns
157  WHERE user_name = p_user_name;
158 
159 
160  FND_GLOBAL.APPS_INITIALIZE(l_user_id, null, 279);
161 
162  FND_MSG_PUB.G_MSG_LEVEL_THRESHOLD := FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW;
163 
164 
165   AS_SALES_LEADS_PUB.Create_Opportunity_For_Lead(
166            p_api_version_number     => 2.0
167           ,p_init_msg_list          => FND_API.G_FALSE
168           ,p_commit                 => FND_API.G_FALSE
169           ,p_validation_level       => 90
170           ,P_Check_Access_Flag      => 'Y'
171           ,P_Admin_Flag             => 'N'
172           ,P_Admin_Group_Id         => NULL
173 	     ,P_Identity_Salesforce_Id => l_resource_id
174           ,P_Sales_Lead_Profile_Tbl => AS_UTILITY_PUB.G_MISS_PROFILE_TBL
175           ,P_SALES_LEAD_ID          => p_sales_lead_id
176           ,x_return_status          => l_return_status
177           ,x_msg_count              => l_msg_count
178           ,x_msg_data               => l_msg_data
179           ,x_opportunity_id         => l_opp_id );
180 
181 
182      l_count := FND_MSG_PUB.Count_Msg;
183 --     dbms_output.put_line('There are ' || l_count || ' messages.');
184      FOR l_index IN 1..l_count LOOP
185           my_message := FND_MSG_PUB.Get(
186                p_msg_index   =>  l_index,
187                p_encoded     =>  FND_API.G_FALSE);
188 --         dbms_output.put_line(substr(my_message,1,255));
189      END LOOP;
190 
191  x_return_status := l_return_status;
192  x_opp_id := l_opp_id;
193  x_msg_count := l_msg_count;
194  x_msg_data := l_msg_data;
195 END CREATE_OPP_FOR_LEAD;
196 
197 procedure submit_collateral_to_fm(
198 p_api_version number,
199 p_deliverable_id number,
200 p_email	varchar2,
201 p_subject varchar2,
202 p_party_id number,
203 p_user_name varchar2,
204 p_user_note varchar2,
205 x_request_id OUT NOCOPY /* file.sql.39 change */ number,
206 x_return_status OUT NOCOPY /* file.sql.39 change */ varchar2,
207 x_msg_count OUT NOCOPY /* file.sql.39 change */ number,
208 x_msg_data OUT NOCOPY /* file.sql.39 change */ varchar2) is
209 
210 l_request_id number;
211 l_content_id number;
212 l_user_id number;
213 l_return_status varchar2(10);
214 l_request_type varchar2(15);
215 l_msg_count number;
216 l_msg_data varchar2(4000);
217 l_content_xml varchar2(2000);
218 
219 begin
220 	SELECT user_id
221 	INTO   l_user_id
222 	FROM   FND_USER
223 	where user_name = p_user_name;
224 
225 	SELECT jtf_amv_item_id
226 	INTO   l_content_id
227 	FROM AMS_DELIVERABLES_VL
228 	WHERE deliverable_id = p_deliverable_id;
229 
230 	FND_GLOBAL.APPS_INITIALIZE(l_user_id, null, 279);
231 
232 	JTF_FM_REQUEST_GRP.START_REQUEST(p_api_version => 1.0,
233 							   x_return_status => l_return_status,
234 							   x_msg_count => l_msg_count,
235 							   x_msg_data => l_msg_data,
236 							   x_request_id => l_request_id);
237 
238 	if (l_return_status = 'E') then
239 		x_return_status := l_return_status;
240 		x_msg_count := l_msg_count;
241 		x_msg_data := l_msg_data;
242 		return;
243 	end if;
244 
245 
246 	JTF_FM_REQUEST_GRP.GET_CONTENT_XML(p_api_version => 1.0,
247 							x_return_status => l_return_status,
248 							x_msg_count => l_msg_count,
249 							x_msg_data => l_msg_data,
250 							p_content_id => l_content_id,
251 							p_media_type => 'EMAIL',
252 							p_email => p_email,
253 							p_user_note => p_user_note,
254 							p_content_type => 'COLLATERAL',
255 							p_request_id => l_request_id,
256 							x_content_xml => l_content_xml);
257 	if (l_return_status = 'E') then
258 		x_return_status := l_return_status;
259 		x_msg_count := l_msg_count;
260 		x_msg_data := l_msg_data;
261 		return;
262 	end if;
263 
264 
265 	JTF_FM_REQUEST_GRP.SUBMIT_REQUEST (p_api_version => 1.0,
266 								p_commit => FND_API.G_FALSE,
267 							 	x_return_status => l_return_status,
268 								x_msg_count => l_msg_count,
269 								x_msg_data => l_msg_data,
270 								p_subject => p_subject,
271 								p_party_id => p_party_id,
272 								p_user_id => l_user_id,
273 								p_queue_response => FND_API.G_TRUE,
274 								p_content_xml => l_content_xml,
275 								p_request_id => l_request_id);
276 
277 
278 	x_return_status := l_return_status;
279 	x_msg_count := l_msg_count;
280 	x_msg_data := l_msg_data;
281 	x_request_id := l_request_id;
282 
283 end SUBMIT_COLLATERAL_TO_FM;
284 
285 
286 procedure register_for_event(p_api_version number,
287 p_source_code varchar2,
288 p_event_offer_id number,
289 p_registrant_party_id number,
290 p_registrant_contact_id number,
291 p_attendant_party_id number,
292 p_attendant_contact_id number,
293 p_user_name varchar2,
294 p_application_id number,
295 x_event_registration_id OUT NOCOPY /* file.sql.39 change */ number,
296 x_confirmation_code OUT NOCOPY /* file.sql.39 change */ varchar2,
297 x_system_status_code  OUT NOCOPY /* file.sql.39 change */ varchar2,
298 x_return_status  OUT NOCOPY /* file.sql.39 change */ varchar2,
299 x_msg_count  OUT NOCOPY /* file.sql.39 change */ number,
300 x_msg_data  OUT NOCOPY /* file.sql.39 change */ varchar2) is
301 
302 l_user_id number;
303 l_event_regs_rec AMS_EVTREGS_PVT.evt_regs_rec_type;
304 l_event_registration_id number;
305 l_confirmation_code varchar2(30);
306 l_system_status_code varchar2(30);
307 l_return_status varchar2(10);
308 l_msg_count number;
309 l_msg_data varchar2(4000);
310 
311 begin
312 
313 	SELECT user_id
314 	INTO   l_user_id
315 	FROM   FND_USER
316 	where user_name = p_user_name;
317 
318  	FND_GLOBAL.APPS_INITIALIZE(l_user_id, null, p_application_id);
319 	l_event_regs_rec.source_code := p_source_code;
320 	l_event_regs_rec.event_offer_id := p_event_offer_id;
321 	l_event_regs_rec.registrant_party_id := p_registrant_party_id;
322 	l_event_regs_rec.attendant_party_id := p_attendant_party_id;
323 	l_event_regs_rec.registrant_contact_id := p_registrant_contact_id;
324 	l_event_regs_rec.attendant_contact_id := p_attendant_contact_id;
325 	l_event_regs_rec.owner_user_id  := l_user_id;
326 	l_event_regs_rec.application_id  := p_application_id;
327 
328 	AMS_EVTREGS_PUB.Register(
329 		p_api_version_number => p_api_version,
330 		p_init_msg_list => FND_API.G_TRUE,
331 		p_commit => FND_API.G_FALSE,
332 		p_evt_regs_rec => l_event_regs_rec,
333 		x_event_registration_id => l_event_registration_id,
334 		x_confirmation_code => l_confirmation_code,
335 		x_system_status_code => l_system_status_code,
336 		x_return_status => l_return_status,
337 		x_msg_count => l_msg_count,
338 		x_msg_data => l_msg_data);
339 
340 		x_event_registration_id := l_event_registration_id;
341 		x_confirmation_code := l_confirmation_code;
342 		x_system_status_code := l_system_status_code;
343 		x_return_status := l_return_status;
344 		x_msg_count := l_msg_count;
345 		x_msg_data := l_msg_data;
346 
347 end register_for_event;
348 
349 END IES_TELESALES_BP_PKG;