[Home] [Help]
PACKAGE BODY: APPS.CCT_MQD_PUB
Source
1 PACKAGE BODY CCT_MQD_PUB AS
2 /* $Header: cctpmqdb.pls 115.7 2003/10/18 00:01:28 svinamda noship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'CCT_MQD_PUB';
5
6
7 PROCEDURE RECEIVE_MEDIA_ITEM
8 (
9 p_api_version IN NUMBER,
10 p_init_msg_list IN VARCHAR2 ,
11 p_commit IN VARCHAR2,
12 p_app_id IN NUMBER,
13 p_item_type IN NUMBER,
14 p_classification IN VARCHAR2,
15 p_kvp IN cct_keyvalue_varr,
16 p_server_group_name IN VARCHAR2,
17 p_direction IN VARCHAR2,
18 p_ih_item_type IN VARCHAR2,
19 x_return_status OUT NOCOPY VARCHAR2 ,
20 x_msg_count OUT NOCOPY NUMBER ,
21 x_msg_data OUT NOCOPY VARCHAR2,
22 x_media_id OUT NOCOPY NUMBER
23 )
24
25 IS
26 l_api_name CONSTANT VARCHAR2(30) := 'RECEIVE_MEDIA_ITEM';
27 l_api_version CONSTANT NUMBER := 1.0;
28 l_return_status varchar2(256);
29 l_msg_count number;
30 l_msg_data varchar2(256);
31 x_err_num NUMBER;
32 x_err_msg VARCHAR2(256);
33 l_server_group_id number;
34
35
36 BEGIN
37 IF NOT FND_API.Compatible_API_Call (l_api_version ,
38 p_api_version ,
39 l_api_name ,
40 G_PKG_NAME )
41 THEN
42 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
43 END IF;
44 -- Initialize message list if p_init_msg_list is set to TRUE.
45 IF FND_API.to_Boolean( p_init_msg_list ) THEN
46 FND_MSG_PUB.initialize;
47 END IF;
48 -- Initialize API return status to failure
49
50 x_return_status := FND_API.G_RET_STS_SUCCESS ;
51 x_msg_count := 0;
52 x_msg_data := null;
53
54 -- API body
55
56 select server_group_id into l_server_group_id
57 from ieo_svr_groups where group_name = p_server_group_name;
58
59 --dbms_output.put_line('RECEIVE_MEDIA_ITEM: pre CCT_IH_PUB.OPEN_MEDIA_ITEM ');
60
61 --dbms_output.put_line('CCT_MQD_PUB - printing kvp');
62 --FOR i IN p_kvp.FIRST..p_kvp.LAST
63 --LOOP
64 --dbms_output.put_line(p_kvp(i));
65 --END LOOP;
66
67 CCT_IH_PUB.OPEN_MEDIA_ITEM
68 (p_api_version => 1.0,
69 p_init_msg_list => p_init_msg_list,
70 p_commit => p_commit,
71 p_app_id => p_app_id,
72 p_user_id => FND_GLOBAL.USER_ID,
73 p_direction => p_direction,
74 p_start_date_time => sysdate,
75 p_source_item_create_date_time => sysdate,
76 p_media_item_type => p_ih_item_type,
77 p_server_group_id => l_server_group_id,
78 x_return_status => l_return_status,
79 x_msg_count => l_msg_count,
80 x_msg_data => l_msg_data,
81 x_media_id => x_media_id);
82
83 if (l_return_status <> 'S') then
84 raise_application_error(1000, 'CCT_MQD_PUB:RECEIVE_MEDIA_ITEM: '
85 || 'OPEN_MEDIA_ITEM FAILED: ' || l_msg_data );
86 end if;
87 --dbms_output.put_line('RECEIVE_MEDIA_ITEM: post CCT_IH_PUB.OPEN_MEDIA_ITEM ');
88
89 CCT_QDE_PUB.RECEIVE_ITEM
90 (p_api_version => 1.0,
91 p_init_msg_list => p_init_msg_list,
92 p_commit => p_commit,
93 p_app_id => p_app_id,
94 p_item_id => x_media_id,
95 p_item_type => p_item_type,
96 p_classification => p_classification,
97 p_kvp => p_kvp,
98 p_delay => 0,
99 x_return_status => l_return_status,
100 x_msg_count => l_msg_count,
101 x_msg_data => l_msg_data);
102
103 if (l_return_status <> 'S') then
104 raise_application_error(1000, 'CCT_MQD_PUB:RECEIVE_MEDIA_ITEM: '
105 || 'RECEIVE_ITEM FAILED: ' || l_msg_data );
106 end if;
107
108 IF FND_API.To_Boolean( p_commit ) THEN
109 COMMIT WORK;
110 END IF;
111
112
113 EXCEPTION
114
115 WHEN FND_API.G_EXC_ERROR THEN
116 rollback;
117 x_return_status := FND_API.G_RET_STS_ERROR ;
118 x_msg_count := 1;
119 x_err_num := SQLCODE;
120 x_err_msg := SUBSTR(SQLERRM, 1, 100);
121 x_msg_data := 'RECEIVE_MEDIA_ITEM: CCT_ERROR '
122 || ' ErrorCode = ' || x_err_num
123 || ' ErrorMsg = ' || x_err_msg;
124 --dbms_output.put_line(x_msg_data);
125
126 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
127 ROLLBACK;
128 x_return_status := FND_API.G_RET_STS_ERROR ;
129 x_msg_count := 1;
130 x_err_num := SQLCODE;
131 x_err_msg := SUBSTR(SQLERRM, 1, 100);
132 x_msg_data := 'RECEIVE_MEDIA_ITEM: CCT_ERROR '
133 || ' ErrorCode = ' || x_err_num
134 || ' ErrorMsg = ' || x_err_msg;
135
136 --dbms_output.put_line(x_msg_data);
137
138 WHEN OTHERS THEN
139 rollback;
140 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
141 --dbms_output.put_line('Unexpected error in others');
142 x_msg_count := 1;
143 x_err_num := SQLCODE;
144 x_err_msg := SUBSTR(SQLERRM, 1, 100);
145 x_msg_data := 'RECEIVE_MEDIA_ITEM: CCT_ERROR '
146 || ' ErrorCode = ' || x_err_num
147 || ' ErrorMsg = ' || x_err_msg;
148
149 --dbms_output.put_line(x_msg_data);
150
151 END RECEIVE_MEDIA_ITEM;
152
153
154 PROCEDURE GET_NEXT_MEDIA_ITEM
155 (
156 p_api_version IN NUMBER,
157 p_init_msg_list IN VARCHAR2,
158 p_commit IN VARCHAR2,
159 p_agent_id IN NUMBER,
160 p_item_type IN NUMBER,
161 p_classification IN VARCHAR2,
162 p_polling IN VARCHAR2,
163 x_return_status OUT NOCOPY VARCHAR2,
164 x_msg_count OUT NOCOPY NUMBER,
165 x_msg_data OUT NOCOPY VARCHAR2,
166 x_app_id OUT NOCOPY NUMBER,
167 x_item_id OUT NOCOPY NUMBER,
168 x_item_type OUT NOCOPY NUMBER,
169 x_classification OUT NOCOPY VARCHAR2,
170 x_kvp OUT NOCOPY VARCHAR2
171 )
172 IS
173 l_api_name CONSTANT VARCHAR2(30) := 'GET_NEXT_MEDIA_ITEM';
174 l_api_version CONSTANT NUMBER := 1.0;
175 l_return_status varchar2(256);
176 l_msg_count number;
177 l_msg_data varchar2(256);
178 l_classification varchar2(1024);
179 x_err_num NUMBER;
180 x_err_msg VARCHAR2(256);
181 l_kvp cct_keyvalue_varr := cct_keyvalue_varr();
182 dequeue_options dbms_aq.dequeue_options_t;
183 message_properties dbms_aq.message_properties_t;
184 message_handle RAW(16);
185 message SYSTEM.cct_qde_response;
186 no_messages exception;
187 pragma exception_init (no_messages, -25228);
188
189
190 BEGIN
191 IF NOT FND_API.Compatible_API_Call (l_api_version ,
192 p_api_version ,
193 l_api_name ,
194 G_PKG_NAME )
195 THEN
196 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
197 END IF;
198 -- Initialize message list if p_init_msg_list is set to TRUE.
199 IF FND_API.to_Boolean( p_init_msg_list ) THEN
200 FND_MSG_PUB.initialize;
201 END IF;
202 -- Initialize API return status to failure
203 -- API body
204 x_return_status := FND_API.G_RET_STS_SUCCESS ;
205 x_msg_count := 0;
206 x_msg_data := null;
207 x_item_id := -1;
208 x_item_type := -1;
209 x_classification := null;
210 x_kvp := null;
211
212 l_classification := p_classification;
213 if (l_classification = '<ANY>')
214 then l_classification := null;
215 end if;
216
217 begin
218 dequeue_options.correlation := p_agent_id;
219 dequeue_options.wait := 0 ;
220 dequeue_options.visibility := DBMS_AQ.IMMEDIATE;
221 dequeue_options.navigation := DBMS_AQ.FIRST_MESSAGE ;
222 dbms_aq.dequeue(
223 queue_name => CCT_QDE_QUEUE.queue_name,
224 dequeue_options => dequeue_options,
225 message_properties => message_properties,
226 payload => message,
227 msgid => message_handle);
228 x_app_id := 172;
229 x_item_id := message.item_id;
230 x_item_type := message.item_type;
231 x_classification := message.classification;
232 x_kvp := CCT_COLLECTION_UTIL_PUB.CCT_KeyValue_Varr_ToString(message.kvp);
233 exception
234 when no_messages then
235 x_item_id := -1;
236 x_item_type := -1;
237 x_classification := null;
238 x_kvp := null;
239 when others then
240 x_item_id := -1;
241 x_item_type := -1;
242 x_classification := null;
243 x_kvp := null;
244 end;
245
246 if ((p_polling <> 'Y') and (x_item_id = -1)) then
247 begin
248 CCT_QDE_PUB.GET_NEXT_ITEM (p_api_version => 1.0,
249 p_init_msg_list => p_init_msg_list,
250 p_commit => p_commit,
251 p_agent_id => p_agent_id,
252 p_item_type => p_item_type,
253 p_classification => l_classification,
254 x_return_status => x_return_status,
255 x_msg_count => x_msg_count,
256 x_msg_data => x_msg_data,
257 x_app_id => x_app_id,
258 x_item_id => x_item_id,
259 x_item_type => x_item_type,
260 x_classification => x_classification,
261 x_kvp => l_kvp);
262 x_kvp := CCT_COLLECTION_UTIL_PUB.CCT_KeyValue_Varr_ToString(l_kvp);
263 end;
264 end if;
265
266 --dbms_output.put_line('CCT_MQD_PUB.GET_NEXT_MEDIA_ITEM '
267 --|| x_return_status || ' '
268 --|| x_msg_count || ' '
269 --|| x_msg_data || ' '
270 --|| x_app_id || ' '
271 --|| x_item_id || ' '
272 --|| x_item_type || ' '
273 --|| x_classification || ' '
274 --|| x_kvp);
275
276 IF FND_API.To_Boolean( p_commit ) THEN
277 COMMIT WORK;
278 END IF;
279
280 EXCEPTION
281
282 WHEN FND_API.G_EXC_ERROR THEN
283 rollback;
284 x_return_status := FND_API.G_RET_STS_ERROR ;
285 x_msg_count := 1;
286 x_err_num := SQLCODE;
287 x_err_msg := SUBSTR(SQLERRM, 1, 100);
288 x_msg_data := 'GET_NEXT_MEDIA_ITEM: CCT_ERROR'
289 || ' ErrorCode = ' || x_err_num
290 || ' ErrorMsg = ' || x_err_msg;
291 --dbms_output.put_line(x_msg_data);
292 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
293 ROLLBACK;
294 x_return_status := FND_API.G_RET_STS_ERROR ;
295 x_msg_count := 1;
296 x_err_num := SQLCODE;
297 x_err_msg := SUBSTR(SQLERRM, 1, 100);
298 x_msg_data := 'GET_NEXT_MEDIA_ITEM: CCT_ERROR'
299 || ' ErrorCode = ' || x_err_num
300 || ' ErrorMsg = ' || x_err_msg;
301 --dbms_output.put_line(x_msg_data);
302 WHEN OTHERS THEN
303 rollback;
304 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
305 x_msg_count := 1;
306 x_err_num := SQLCODE;
307 x_err_msg := SUBSTR(SQLERRM, 1, 100);
308 x_msg_data := 'GET_NEXT_MEDIA_ITEM: CCT_ERROR'
309 || ' ErrorCode = ' || x_err_num
310 || ' ErrorMsg = ' || x_err_msg;
311 --dbms_output.put_line(x_msg_data);
312 END GET_NEXT_MEDIA_ITEM;
313
314
315 END CCT_MQD_PUB;