DBA Data[Home] [Help]

PACKAGE BODY: APPS.SOA_GENERATE

Source


1 package body SOA_GENERATE as
2 /* $Header: SOAGENRB.pls 120.2 2008/03/31 14:02:07 abhverma noship $ */
3 
4 
5 procedure create_class_entry_detail
6 	(
7 	p_base_class_id in number,
8 	p_class_name in varchar2,
9 	p_irep_name  in varchar2,
10 	p_created_by in pls_integer,
11 	p_creation_date in date,
12 	p_security_group_id in number,
13 	p_class_type in varchar2,
14 	p_product_code in varchar,
15 	p_implementation_name in varchar2,
16 	p_deployed_flag in varchar2,
17 	p_generated_flag in varchar2,
18 	p_compatibility_flag in varchar,
19 	p_assoc_class_id in pls_integer,
20 	p_scope_type in varchar,
21 	p_lifecycle_mode in varchar,
22 	p_source_file_product in varchar,
23 	p_source_file_path in varchar,
24 	p_source_file_name in varchar,
25 	p_source_file_version in varchar,
26 	p_description in varchar,
27 	p_xml_description in clob,
28 	p_standard_type in varchar,
29 	p_standard_version in varchar,
30 	p_standard_spec in varchar2,
31 	p_load_err in varchar2,
32 	p_load_err_msgs in varchar2,
33 	p_open_interface_flag in varchar2,
34 	p_map_code in varchar2,
35 	p_entry_type in varchar2,
36 	p_class_id_out OUT NOCOPY pls_integer,
37 	p_err_code OUT NOCOPY pls_integer,
38 	p_err_message OUT NOCOPY varchar2
39 	) ;
40 
41 procedure create_class_lang_entries
42 	(
43 	p_base_class_id in number,
44 	p_class_id in number,
45 	p_err_code OUT NOCOPY pls_integer,
46 	p_err_message OUT NOCOPY varchar2
47 	);
48 
49 
50 procedure create_class_language
51 	(
52 	p_class_id  in number,
53 	p_language in varchar2,
54 	p_source_lang in varchar2,
55 	p_display_name in varchar2,
56 	p_short_description in varchar2,
57 	p_security_group_id in number,
58 	p_err_code OUT NOCOPY pls_integer,
59 	p_err_message OUT NOCOPY varchar2
60 	) ;
61 
62 
63 procedure create_function_entry_detail
64 	(
65 	p_function_name in varchar,
66 	p_application_id in number,
67 	p_form_id in number,
68 	p_parameters in varchar2,
69 	p_creation_date in date,
70 	p_created_by in pls_integer,
71 	p_type in varchar2,
72 	p_web_host_name in varchar2,
73 	p_web_agent_name in varchar2,
74 	p_web_html_call in varchar2,
75 	p_web_encrypt_parameters in varchar2,
76 	p_web_secured in varchar2,
77 	p_web_icon in varchar2,
78 	p_object_id in pls_integer,
79 	p_region_application_id in pls_integer,
80 	p_region_code in varchar2,
81 	p_maintenance_mode_support in varchar2,
82 	p_context_dependence in varchar2,
83 	p_jrad_ref_path in varchar2,
84 	p_irep_method_name  in varchar2,
85 	p_irep_overload_sequence in pls_integer,
86 	p_irep_scope in varchar2,
87 	p_irep_lifecycle in varchar2,
88 	p_irep_description in clob,
89 	p_irep_compatibility in varchar2,
90 	p_irep_inbound_xml_desc in clob,
91 	p_irep_outbound_xml_desc in clob,
92 	p_irep_synchro in varchar2,
93 	p_irep_direction in varchar2,
94 	p_irep_assoc_function_name in varchar2,
95 	p_irep_class_id in pls_integer,
96 	p_base_function_id in number,
97 	p_err_code OUT NOCOPY pls_integer,
98 	p_err_message OUT NOCOPY varchar2
99 	) ;
100 
101 procedure create_function_lang_entries
102 	(
103 	p_base_function_id in number,
104 	p_function_id in number,
105 	p_err_code OUT NOCOPY pls_integer,
106 	p_err_message OUT NOCOPY varchar2
107 	);
108 
109 
110 procedure create_function_language
111 	(
112 	p_function_id  in number,
113 	p_language in varchar2,
114 	p_user_function_name in varchar2,
115 	p_description in varchar2,
116 	p_source_lang in varchar2,
117 	p_err_code OUT NOCOPY pls_integer,
118 	p_err_message OUT NOCOPY varchar2
119 	) ;
120 
121 procedure create_xmlg_schema
122 	(
123 	p_clob OUT NOCOPY clob,
124 	p_root_element in varchar,
125 	p_product_code in varchar2,
126 	p_direction in varchar,
127 	p_port_type in varchar,
128 	p_operation in varchar,
129 	p_err_code OUT NOCOPY pls_integer,
130 	p_err_message OUT NOCOPY varchar2
131 	) ;
132 
133 procedure to_upper
134 	(
135 	p_name in varchar2,
136 	p_new_name OUT NOCOPY varchar2,
137 	p_err_code OUT NOCOPY pls_integer,
138 	p_err_message OUT NOCOPY varchar2
139 	) ;
140 
141 
142 
143 /**
144 Procedure for creating a Derived Entry for a given Base Entry Interface
145 **/
146 procedure create_class_derived_entry
147 	(
148 	p_base_class_id in pls_integer,
149 	p_entry_type in varchar2,
150 	x_derived_class_id OUT NOCOPY pls_integer,
151 	p_err_code OUT NOCOPY pls_integer,
152 	p_err_message OUT NOCOPY varchar2
153 	)
154 
155 is
156 	cursor c_class(c_class_id in number) is
157  	select count(*) l_count
158  	from fnd_irep_classes
159  	where class_id = c_class_id;
160 
161         cursor c_class_name(c_class_id in number) is
162         select class_name ,irep_name
163         from fnd_irep_classes
164         where class_id = c_class_id;
165 
166  	c_class_rec c_class%ROWTYPE;
167 
168 	cursor 	c_methods(c_class_id in number) is
169 	select function_id
170 	from fnd_form_functions
171 	where irep_class_id = c_class_id ;
172 
173 	method_count pls_integer := 0;
174 	p_base_class_name varchar2(430) := null;
175 	x_irep_name varchar2(500) := null;
176 
177 begin
178 	if (p_base_class_id is null ) then
179 		p_err_code := -1;
180 		p_err_message := wf_core.translate('WF_WS_MISSING_CLASS_ID');
181 		raise program_exit;
182 	end if;
183 
184 	if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
185 		FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Process Class ID='||p_base_class_id);
186 	end if;
187 
188 	open c_class(p_base_class_id);
189 	fetch c_class into c_class_rec;
190 	close c_class;
191 
192         open c_class_name(p_base_class_id);
193         fetch c_class_name into p_base_class_name,x_irep_name;
194         close c_class_name;
195 
196 	if c_class_rec.l_count = 0 then
197 		p_err_code := -1;
198 		wf_core.token('BaseClassId',p_base_class_id);
199 		p_err_message := wf_core.translate('WF_WS_BASE_CLASS_NOT_EXIST');
200 		raise program_exit;
201 	end if;
202 
203 	for c1 in c_methods(p_base_class_id)
204 	loop
205 		method_count := method_count + 1;
206 
207 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
208 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Processing FunctionID='||c1.function_id);
209 		end if;
210 
211 
212 		begin
213 	                create_function_derived_entry(p_base_class_id,c1.function_id,p_entry_type,x_derived_class_id,p_err_code,p_err_message);
214 		exception
215 		when ignore_rec  then
216 			null;
217 		when program_exit then
218 			raise program_exit;
219 		when others then
220 			p_err_code := -1;
221 			wf_core.token('BaseClassId',p_base_class_id);
222                         wf_core.token('BaseClassName', p_base_class_name);
223 			wf_core.token('FunctionId',c1.function_id);
224 			wf_core.token('SqlErr',SQLERRM);
225 			p_err_message := wf_core.translate('WF_WS_CLASS_FUNC_ITER');
226 			raise program_exit;
227 		end;
228 
229 	end loop;
230 
231 	wf_core.token('BaseClassId',p_base_class_id);
232         wf_core.token('BaseClassName', p_base_class_name);
233 	if (method_count = 0 ) then
234 		p_err_code := -1;
235 		p_err_message := wf_core.translate('WF_WS_NO_BASE_METHODS');
236 	elsif ( method_count > 0 ) then
237 		p_err_code := 0;
238 		p_err_message := wf_core.translate('WF_WS_SUCCESS');
239 	end if;
240 
241 exception
242 when program_exit then
243 	null;
244 when others then
245 	p_err_code := -1;
246 	wf_core.token('BaseClassId',p_base_class_id);
247         wf_core.token('BaseClassName', p_base_class_name);
248 	wf_core.token('SqlErr',SQLERRM);
249 	p_err_message := wf_core.translate('WF_WS_CLASS_DERIVED');
250 end create_class_derived_entry;
251 
252 
253 /**
254 Procedure for creating a Derived Entry for all functions of a base class Entry
255 **/
256 procedure create_function_derived_entry
257 	(
258 	p_base_class_id in pls_integer,
259 	p_base_function_id in pls_integer,
260 	p_entry_type in varchar2,
261 	l_derived_class_id OUT NOCOPY pls_integer,
262 	p_err_code OUT NOCOPY pls_integer,
263 	p_err_message OUT NOCOPY varchar2
264 	)
265 
266 is
267 
268 	cursor c_base_class_entry(c_base_class_id in number) is
269 	select 	*
270 	from fnd_irep_classes_vl
271 	where class_id = c_base_class_id;
272 
273 	c_base_class_entry_rec c_base_class_entry%ROWTYPE;
274 
275 	cursor c_base_function_entry(c_base_function_id in number) is
276 	select  *
277 	from fnd_form_functions_vl
278 	where function_id = c_base_function_id;
279 
280 	c_base_function_entry_rec c_base_function_entry%ROWTYPE;
281 
282 	i_function_name varchar2(2000) :=null;
283 	i_port_type varchar2(2000) := null;
284 	i_operation varchar2(2000) := null;
285 	i_delimitor pls_integer;
286 	i_delimitor2 pls_integer;
287 	i_derived_class_name varchar2(2000) := null;
288 	i_xmlg_prefix varchar2(2000) := null;
289         i_root_element varchar2(255) := null;
290 
291 --	l_derived_class_id pls_integer;
292 	in_xml clob := null;
293 	out_xml clob := null;
294 
295 begin
296 	/**Get the base entry**
297 	**If its XML Gateway then care about grouping otherwise don't**
298 	**/
299 
300 
301 	if ( (p_base_class_id is null) or (p_base_function_id is null)) then
302 		p_err_code := -1;
303 		p_err_message := wf_core.translate('WF_WS_MISSING_CLASS_FUNC_ID');
304 		raise program_exit;
305 	end if;
306 
307 
308 	/*Get the Base Entry class**/
309 	open c_base_class_entry(p_base_class_id);
310 	fetch c_base_class_entry into c_base_class_entry_rec;
311 
312 	if c_base_class_entry%NOTFOUND then
313 
314 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
315 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Base Class ID='||p_base_class_id||' does not exist');
316 		end if;
317 
318 		p_err_code := -1;
319 		p_err_message := wf_core.translate('WF_WS_BASE_CLASS_NOT_EXIST');
320 		raise program_exit;
321 
322 	elsif c_base_class_entry%FOUND then
323 
324 
325 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
326 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Base Class ID='||p_base_class_id||' exists');
327 		end if;
328 
329 		open c_base_function_entry(p_base_function_id);
330 		fetch c_base_function_entry into c_base_function_entry_rec;
331 
332 		if c_base_function_entry%FOUND then
333 
334 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
335 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Base Function='||p_base_function_id||' exist');
336 			end if;
337 
338 			if ( c_base_function_entry_rec.irep_class_id <> p_base_class_id ) then
339 				p_err_code :=-1;
340 				p_err_message := wf_core.translate('WF_WS_CLASS_FUNC_MISMATCH');
341 				raise program_exit;
342 			end if;
343 
344 			if ( c_base_class_entry_rec.scope_type = 'PUBLIC' AND c_base_function_entry_rec.irep_scope = 'PUBLIC' ) then
345 
346 				if ( c_base_class_entry_rec.class_type = 'XMLGATEWAY' ) then
347 
348 					if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
349 						FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Class Type:XMLGATEWAY ');
350 					end if;
351 
352 					if ( upper(c_base_function_entry_rec.irep_direction) = 'O' ) then
353 
354 						if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
355 							FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Ignoring Outbound Entry ');
356 						end if;
357 
358 
359 						p_err_code :=-1;
360 						p_err_message := wf_core.translate('WF_WS_XMLG_OUTBOUND');
361 						raise ignore_rec;
362 					end if;
363 
364 					/**
365 					Base
366 					class Name							irep_name
367 					XMLGATEWAY:AR:PROCESS_INVOICE					AR:PROCESS_INVOICE
368 
369 					Function Name
370 					XMLGATEWAY:AR:PROCESS_INVOICE:PROCESS_INVOICE			PROCESS_INVOICE
371 
372 					Derived
373 					p_entry_type:oracle.apps.ar.Ar.ProcessInvoice			oracle.apps.ar.Ar
374 
375 					Function Name
376 					p_entry_type:oracle.apps.ar.Ar.ProcessInvoice.ProcessInvoice	oracle.apps.ar.Ar.ProcessInvoice
377 					**/
378 
379 					i_function_name := c_base_class_entry_rec.irep_name;
380 
381 					if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
382 						FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Function Name='||c_base_function_entry_rec.function_name||', Irep Name='||i_function_name );
383 					end if;
384 
385 					i_delimitor := instr(i_function_name,':',1);
386 					--i_delimitor2 := instr(c_base_function_entry_rec.function_name,':',1,2);
387 
388 
389 					if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
390 						FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Delimitor1 ='||i_delimitor||', Delimitor2='||i_delimitor2 );
391 					end if;
392 
393 
394 					if ( i_delimitor <> 0 ) then
395 
396 						i_port_type := substr(i_function_name,1,i_delimitor-1);
397 						i_port_type := replace(initcap(i_port_type),'_','');
398 						i_operation := substr(i_function_name,i_delimitor+1,length(i_function_name)-i_delimitor);
399 						i_operation := replace(initcap(i_operation),'_','');
400 
401 						i_xmlg_prefix := 'oracle.apps.'||lower(c_base_class_entry_rec.product_code);
402 						i_derived_class_name :=i_xmlg_prefix||'.'||i_port_type||'.'||i_operation;
403 
404 						if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
405 							FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry','Port Type='||i_port_type||',Operation='||i_operation);
406 						end if;
407 
408 						if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
409 							FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry','Description='||c_base_class_entry_rec.description);
410 						end if;
411 
412 						if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
413 							FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry','Method Description='||c_base_function_entry_rec.irep_description);
414 						end if;
415 
416 						if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
417 							FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry','Derived Class Name='||i_derived_class_name);
418 						end if;
419 
420 						create_class_entry_detail
421 						(
422 						c_base_class_entry_rec.class_id,
423 						p_entry_type ||':'||i_derived_class_name,
424 						i_derived_class_name,
425 						c_base_class_entry_rec.created_by,
426 						c_base_class_entry_rec.creation_date,
427 						c_base_class_entry_rec.security_group_id,
428 						p_entry_type,
429 						c_base_class_entry_rec.product_code,
430 						c_base_class_entry_rec.implementation_name,
431 						c_base_class_entry_rec.deployed_flag,
432 						c_base_class_entry_rec.generated_flag,
433 						c_base_class_entry_rec.compatibility_flag,
434 						c_base_class_entry_rec.class_id,
435 						c_base_class_entry_rec.scope_type,
436 						c_base_class_entry_rec.lifecycle_mode,
437 						c_base_class_entry_rec.source_file_product,
438 						c_base_class_entry_rec.source_file_path,
439 						c_base_class_entry_rec.source_file_name,
443 						c_base_class_entry_rec.standard_type,
440 						c_base_class_entry_rec.source_file_version,
441 						c_base_class_entry_rec.description,
442 						c_base_class_entry_rec.xml_description,
444 						c_base_class_entry_rec.standard_version,
445 						c_base_class_entry_rec.standard_spec,
446 						null,
447 						null,
448 						null,
449                                                 c_base_class_entry_rec.map_code,
450 						p_entry_type,
451 						l_derived_class_id,
452 						p_err_code,
453 						p_err_message
454 						);
455 
456 					        /**
457 						assign_business_entities
458 							(
459 							c_base_class_entry_rec.class_id,
460 							l_derived_class_id,
461 							p_err_code,
462 							p_err_message);
463 						**/
464 
465 						/**
466 						1.Description for the Class/description and
467 						user function is an issue for XMLG entries
468 						2.Get the new field for root element
469 						**/
470 				                get_root_element
471                                                 (
472                                                 c_base_class_entry_rec.map_code,
473                                                 i_root_element,
474                                                 p_err_code,
475                                                 p_err_message
476                                                 );
477 
478 						if c_base_function_entry_rec.irep_inbound_xml_description is null then
479 							create_xmlg_schema
480 							(
481 							in_xml,
482                                                         i_root_element,
483 							c_base_class_entry_rec.product_code,
484 							'IN',
485 							i_port_type,
486                                                         i_operation,
487 							p_err_code,
488 							p_err_message
489 							);
490 						else
491 							in_xml :=c_base_function_entry_rec.irep_inbound_xml_description;
492 						end if;
493 
494 						if c_base_function_entry_rec.irep_outbound_xml_description is null then
495 							create_xmlg_schema
496 							(
497 							out_xml,
498                                                         i_root_element,
499 							c_base_class_entry_rec.product_code,
500 							'OUT',
501 							i_port_type,
502                                                         i_operation,
503 							p_err_code,
504 							p_err_message
505 							);
506 						else
507 							out_xml :=c_base_function_entry_rec.irep_outbound_xml_description;
508 						end if;
509 
510 						create_function_entry_detail
511 						(
512 						p_entry_type ||':'||i_derived_class_name||':'||i_operation,
513 						c_base_function_entry_rec.application_id,
514 						c_base_function_entry_rec.form_id,
515 						c_base_function_entry_rec.parameters,
516 						c_base_function_entry_rec.creation_date,
517 						c_base_function_entry_rec.created_by,
518 						c_base_function_entry_rec.type,
519 						c_base_function_entry_rec.web_host_name,
520 						c_base_function_entry_rec.web_agent_name,
521 						c_base_function_entry_rec.web_html_call,
522 						c_base_function_entry_rec.web_encrypt_parameters,
523 						c_base_function_entry_rec.web_secured,
524 						c_base_function_entry_rec.web_icon,
525 						c_base_function_entry_rec.object_id,
526 						c_base_function_entry_rec.region_application_id,
527 						c_base_function_entry_rec.region_code,
528 						c_base_function_entry_rec.maintenance_mode_support,
529 						c_base_function_entry_rec.context_dependence,
530 						c_base_function_entry_rec.jrad_ref_path,
531 						i_derived_class_name||'.'||i_operation,
532 						c_base_function_entry_rec.irep_overload_sequence,
533 						c_base_function_entry_rec.irep_scope,
534 						c_base_function_entry_rec.irep_lifecycle,
535 						c_base_function_entry_rec.irep_description,
536 						c_base_function_entry_rec.irep_compatibility,
537 						in_xml,
538 						out_xml,
539 						c_base_function_entry_rec.irep_synchro,
540 						c_base_function_entry_rec.irep_direction,
541 						c_base_function_entry_rec.function_name,
542 						l_derived_class_id,
543 						p_base_function_id,
544 						p_err_code,
545 						p_err_message
546 						);
547 
548 					else
549 						if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
550 							FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Invalid Function Name does not have : ');
551 						end if;
552 
553 						p_err_code := -1;
554 						p_err_message :=wf_core.translate('WF_WS_XMLG_INVALID_ENTRY');
555 					end if;
556 
557 				elsif ( c_base_class_entry_rec.class_type = 'SERVICEBEAN' or c_base_class_entry_rec.class_type = 'WSDL' or
558 				     c_base_class_entry_rec.class_type = 'PLSQL' or c_base_class_entry_rec.class_type = 'CONCURRENTPROGRAM' or
559 				     c_base_class_entry_rec.class_type = 'EDI' ) then
560 
561 					if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
562 						FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'Class Type:SERVICEBEAN ');
563 					end if;
564 
565 					i_function_name := c_base_class_entry_rec.irep_name;
566 
567 
568 
569 					i_port_type := i_function_name;
570 					i_derived_class_name := i_port_type;
571 
572 					i_operation := c_base_function_entry_rec.irep_method_name;
573 					--dbms_output.put_line('I_Operation='||i_operation||'x');
574 					--dbms_output.put_line('I_Operation length='||length(i_operation)||'x');
575 					if ( (i_operation is null ) or (length(i_operation) is NULL ) ) then
576 						p_err_code := -1;
577 						p_err_message :=wf_core.translate('WF_WS_MISSING_IREP_METHOD_NAME');
578 						raise program_exit;
579 					end if;
580 
584 					p_entry_type||':'||i_derived_class_name,
581 					create_class_entry_detail
582 					(
583 					c_base_class_entry_rec.class_id,
585 					i_derived_class_name,
586 					c_base_class_entry_rec.created_by,
587 					c_base_class_entry_rec.creation_date,
588 					c_base_class_entry_rec.security_group_id,
589 					p_entry_type,
590 					c_base_class_entry_rec.product_code,
591 					c_base_class_entry_rec.implementation_name,
592 					c_base_class_entry_rec.deployed_flag,
593 					c_base_class_entry_rec.generated_flag,
594 					c_base_class_entry_rec.compatibility_flag,
595 					c_base_class_entry_rec.class_id,
596 					c_base_class_entry_rec.scope_type,
597 					c_base_class_entry_rec.lifecycle_mode,
598 					c_base_class_entry_rec.source_file_product,
599 					c_base_class_entry_rec.source_file_path,
600 					c_base_class_entry_rec.source_file_name,
601 					c_base_class_entry_rec.source_file_version,
602 					c_base_class_entry_rec.description,
603 					c_base_class_entry_rec.xml_description,
604 					c_base_class_entry_rec.standard_type,
605 					c_base_class_entry_rec.standard_version,
606 					c_base_class_entry_rec.standard_spec,
607 					null,
608 					null,
609 					null,
610                                         c_base_class_entry_rec.map_code,
611 					p_entry_type,
612 					l_derived_class_id,
613 					p_err_code,
614 					p_err_message
615 					);
616 					/**
617 					assign_business_entities
618 					(
619 					c_base_class_entry_rec.class_id,
620 					l_derived_class_id,
621 					p_err_code,
622 					p_err_message
623 					);
624 					**/
625 
626 
627 					/**What should be the value for description and user_function in method tl table**/
628 					i_operation := upper(substr(i_operation,0,1))||substr(i_operation,2,length(i_operation));
629 					create_function_entry_detail
630 					(
631 					p_entry_type||':'||i_derived_class_name||':'||i_operation,
632 					c_base_function_entry_rec.application_id,
633 					c_base_function_entry_rec.form_id,
634 					c_base_function_entry_rec.parameters,
635 					c_base_function_entry_rec.creation_date,
636 					c_base_function_entry_rec.created_by,
637 					c_base_function_entry_rec.type,
638 					c_base_function_entry_rec.web_host_name,
639 					c_base_function_entry_rec.web_agent_name,
640 					c_base_function_entry_rec.web_html_call,
641 					c_base_function_entry_rec.web_encrypt_parameters,
642 					c_base_function_entry_rec.web_secured,
643 					c_base_function_entry_rec.web_icon,
644 					c_base_function_entry_rec.object_id,
645 					c_base_function_entry_rec.region_application_id,
646 					c_base_function_entry_rec.region_code,
647 					c_base_function_entry_rec.maintenance_mode_support,
648 					c_base_function_entry_rec.context_dependence,
649 					c_base_function_entry_rec.jrad_ref_path,
650 					i_operation,
651 					c_base_function_entry_rec.irep_overload_sequence,
652 					c_base_function_entry_rec.irep_scope,
653 					c_base_function_entry_rec.irep_lifecycle,
654 					c_base_function_entry_rec.irep_description,
655 					c_base_function_entry_rec.irep_compatibility,
656 					c_base_function_entry_rec.irep_inbound_xml_description,
657 					c_base_function_entry_rec.irep_outbound_xml_description,
658 					c_base_function_entry_rec.irep_synchro,
659 					c_base_function_entry_rec.irep_direction,
660 					c_base_function_entry_rec.function_name,
661 					l_derived_class_id,
662 					p_base_function_id,
663 					p_err_code,
664 					p_err_message
665 					);
666 
667 				end if;
668 			else
669 				if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
670 					FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', 'ClassID,FunctionID:'||c_base_class_entry_rec.class_id||','||c_base_function_entry_rec.function_id||' Not a public interface/method to be exposed');
671 				end if;
672 
673 				p_err_code := -1;
674 				p_err_message := wf_core.translate('WF_WS_NOT_PUBLIC');
675 				raise program_exit;
676 			end if;
677 		else
678 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
679 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_derived_entry', ' No records found for FunctionID='||c_base_function_entry_rec.function_id);
680 			end if;
681 
682 			p_err_code := -1;
683 			p_err_message := wf_core.translate('WF_WS_BASE_FUNC_NOT_EXIST');
684 			raise program_exit;
685 		end if;
686 
687 		close c_base_function_entry;
688 	end if;
689 
690 	close c_base_class_entry;
691 
692 	p_err_code := 0;
693 	wf_core.token('ClassId',p_base_class_id);
694 	p_err_message :=wf_core.translate('WF_WS_SUCCESS');
695 
696 exception
697 when ignore_rec then
698 	raise ignore_rec;
699 when program_exit then
700 	raise program_exit;
701 when others then
702 	p_err_code := -1;
703 	p_err_message :=wf_core.translate('WF_WS_GENERIC_CLASS_ERROR')||'Error in Creating Derived Entry for Base FUNCTION_ID='||p_base_function_id||SQLERRM;
704 	raise program_exit;
705 end create_function_derived_entry;
706 
707 procedure create_class_entry_detail
708 	(
709 	p_base_class_id in number,
710 	p_class_name in varchar2,
711 	p_irep_name  in varchar2,
712 	p_created_by in pls_integer,
713 	p_creation_date in date,
714 	p_security_group_id in number,
715 	p_class_type in varchar2,
716 	p_product_code in varchar,
717 	p_implementation_name in varchar2,
718 	p_deployed_flag in varchar2,
719 	p_generated_flag in varchar2,
720 	p_compatibility_flag in varchar,
721 	p_assoc_class_id in pls_integer,
722 	p_scope_type in varchar,
723 	p_lifecycle_mode in varchar,
724 	p_source_file_product in varchar,
725 	p_source_file_path in varchar,
726 	p_source_file_name in varchar,
730 	p_standard_type in varchar,
727 	p_source_file_version in varchar,
728 	p_description in varchar,
729 	p_xml_description in clob,
731 	p_standard_version in varchar,
732 	p_standard_spec in varchar2,
733 	p_load_err in varchar2,
734 	p_load_err_msgs in varchar2,
735 	p_open_interface_flag in varchar2,
736 	p_map_code in varchar2,
737 	p_entry_type in varchar2,
738 	p_class_id_out OUT NOCOPY pls_integer,
739 	p_err_code OUT NOCOPY pls_integer,
740 	p_err_message OUT NOCOPY varchar2
741 	)
742 is
743 	cursor c_derived_class(c_class_name in varchar, c_entry_type in varchar) is
744 	select *
745 	from fnd_irep_classes
746 	where  class_name = c_class_name
747 	and class_type = c_entry_type
748 	for update ;
749 
750 	cursor c_irep_class_id is
751 		select fnd_objects_s.nextval
752 		from dual;
753 
754 	l_class_id number;
755 
756 
757 	c_derived_class_rec c_derived_class%ROWTYPE;
758 
759 begin
760 
761 	if ( (p_class_name is null) or (p_base_class_id is null) ) then
762 		p_err_code := -1;
763 		p_err_message := wf_core.translate('WF_WS_CLASS_NAME_IS_NULL');
764 		raise program_exit;
765 	end if;
766 
767 	open c_derived_class(p_class_name,p_entry_type);
768 	fetch c_derived_class into c_derived_class_rec;
769 
770 	if c_derived_class%NOTFOUND then
771 
772 		begin
773 
774 			open c_irep_class_id;
775 			fetch c_irep_class_id into l_class_id;
776 			close c_irep_class_id;
777 
778 			insert into fnd_irep_classes
779 			(
783 			CREATED_BY,
780 			CLASS_ID,
781 			CLASS_NAME,
782 			IREP_NAME,
784 			CREATION_DATE,
785 			LAST_UPDATED_BY,
786 			LAST_UPDATE_DATE,
787 			LAST_UPDATE_LOGIN,
788 			SECURITY_GROUP_ID,
789 			CLASS_TYPE,
790 			PRODUCT_CODE,
791 			IMPLEMENTATION_NAME,
792 			DEPLOYED_FLAG,
793 			GENERATED_FLAG,
794 			COMPATIBILITY_FLAG,
795 			ASSOC_CLASS_ID,
796 			SCOPE_TYPE,
797 			LIFECYCLE_MODE,
798 			SOURCE_FILE_PRODUCT,
799 			SOURCE_FILE_PATH,
800 			SOURCE_FILE_NAME,
801 			SOURCE_FILE_VERSION,
802 			DESCRIPTION,
803 			XML_DESCRIPTION,
804 			STANDARD_TYPE,
805 			STANDARD_VERSION,
806 			STANDARD_SPEC,
807 			LOAD_ERR,
808 			LOAD_ERR_MSGS,
809 			OPEN_INTERFACE_FLAG,
810                         MAP_CODE
811 			)
812 			values
813 			(
814 			l_class_id,
815 			p_class_name,
816 			p_irep_name,
817 			1,
818 			sysdate,
819 			1,
820 			sysdate,
821 			0,
822 			0,
823 			p_entry_type,
824 			p_product_code,
825 			p_implementation_name,
826 			'N', -- p_deployed_flag,
827 			p_generated_flag,
828 			p_compatibility_flag,
829 			p_assoc_class_id,
830 			p_scope_type,
831 			p_lifecycle_mode,
832 			p_source_file_product,
833 			p_source_file_path,
834 			p_source_file_name,
835 			p_source_file_version,
836 			p_description,
837 			p_xml_description,
838 			p_standard_type,
839 			p_standard_version,
840 			p_standard_spec,
841 			p_load_err,
842 			p_load_err_msgs,
843 			p_open_interface_flag,
844                         p_map_code
845 			);
846 
847 			create_class_lang_entries
848 			(
849 			p_base_class_id ,
850 			l_class_id ,
851 			p_err_code,
852 			p_err_message
853 			);
854 
855 		exception
856 		when program_exit then
857 			raise program_exit;
858 		when others then
859 			p_err_code := -1;
860 			p_err_message := wf_core.translate('WF_WS_CLASS_INSERT')||SQLERRM;
861 		end;
862 
863 		p_class_id_out := l_class_id;
864 
865 	elsif c_derived_class%FOUND then
866 		--Update the existing record
867 
868 		begin
869 			update fnd_irep_classes
870 			set	irep_name = p_irep_name,
871 				last_updated_by = 0,
872 				last_update_date = sysdate,
873 				last_update_login = 0,
874 				security_group_id = p_security_group_id,
875 				class_type = p_class_type,
876 				product_code = p_product_code,
877 				implementation_name = p_implementation_name,
878 				deployed_flag = 'N', -- p_deployed_flag,
879 				generated_flag = p_generated_flag,
880 				compatibility_flag = p_compatibility_flag,
881 				assoc_class_id = p_assoc_class_id,
882 				scope_type = p_scope_type,
883 				lifecycle_mode = p_lifecycle_mode,
884 				source_file_product = p_source_file_product,
885 				source_file_path = p_source_file_path,
886 				source_file_name = p_source_file_name,
887 				source_file_version = p_source_file_version,
888 				description = p_description,
889 				xml_description = p_xml_description,
890 				standard_type = p_standard_type,
891 				standard_version = p_standard_version,
892 				standard_spec = p_standard_spec,
893 				load_err = p_load_err,
894 				load_err_msgs = p_load_err_msgs,
895 				open_interface_flag = p_open_interface_flag
896 
897 			where current of c_derived_class;
898 
899 			create_class_lang_entries
900 			(
901 			p_base_class_id ,
902 			c_derived_class_rec.class_id ,
903 			p_err_code,
904 			p_err_message
905 			);
906 		exception
907 		when program_exit then
908 			raise program_exit;
909 		when others then
910 			p_err_code := -1;
911 			p_err_message := wf_core.translate('WF_WS_CLASS_UPDATE')||SQLERRM;
912 		end;
913 
914 		p_class_id_out := c_derived_class_rec.class_id;
915 	end if;
916 
917 	close c_derived_class;
918 
919 	p_err_code := 0;
920 	p_err_message := wf_core.translate('WF_WS_SUCCESS');
921 exception
922 when program_exit then
923 	raise program_exit;
924 when others then
925 	p_err_code := -1;
926 	wf_core.token('BaseClassName',p_class_name);
927 	wf_core.token('SqlErr',SQLERRM);
928 	p_err_message := wf_core.translate('WF_WS_CLASS_CREATE');
929 	raise program_exit;
930 end create_class_entry_detail;
931 
932 
933 procedure create_function_entry_detail
934 	(
935 	p_function_name in varchar,
936 	p_application_id in number,
937 	p_form_id in number,
938 	p_parameters in varchar2,
939 	p_creation_date in date,
940 	p_created_by in pls_integer,
941 	p_type in varchar2,
942 	p_web_host_name in varchar2,
943 	p_web_agent_name in varchar2,
944 	p_web_html_call in varchar2,
945 	p_web_encrypt_parameters in varchar2,
946 	p_web_secured in varchar2,
947 	p_web_icon in varchar2,
948 	p_object_id in pls_integer,
949 	p_region_application_id in pls_integer,
950 	p_region_code in varchar2,
951 	p_maintenance_mode_support in varchar2,
952 	p_context_dependence in varchar2,
953 	p_jrad_ref_path in varchar2,
954 	p_irep_method_name  in varchar2,
955 	p_irep_overload_sequence in pls_integer,
956 	p_irep_scope in varchar2,
957 	p_irep_lifecycle in varchar2,
958 	p_irep_description in clob,
959 	p_irep_compatibility in varchar2,
960 	p_irep_inbound_xml_desc in clob,
961 	p_irep_outbound_xml_desc in clob,
962 	p_irep_synchro in varchar2,
963 	p_irep_direction in varchar2,
964 	p_irep_assoc_function_name in varchar2,
965 	p_irep_class_id in pls_integer,
966 	p_base_function_id in number,
970 is
967 	p_err_code OUT NOCOPY pls_integer,
968 	p_err_message OUT NOCOPY varchar2
969 	)
971 	cursor c_derived_method(c_function_name in varchar) is
972 	select *
973 	from fnd_form_functions
974 	where  function_name = c_function_name
975 	and type = 'INTERFACE'
976 	for update;
977 
978 	cursor c_irep_function_id is
979 	select fnd_form_functions_s.nextval
980 	from dual;
981 
982 	l_function_id number := 0;
983 
984 
985 	c_derived_method_rec c_derived_method%ROWTYPE;
986 
987 begin
988 	open c_derived_method(p_function_name);
989 	fetch c_derived_method into c_derived_method_rec;
990 
991 	if c_derived_method%NOTFOUND then
992 
993 		begin
994 
995 			open c_irep_function_id;
996 			fetch c_irep_function_id into l_function_id;
997 			close c_irep_function_id;
998 
999 			insert into FND_FORM_FUNCTIONS
1000 			(
1001 			 FUNCTION_ID,
1002 			 FUNCTION_NAME,
1003 			 APPLICATION_ID,
1004 			 FORM_ID,
1005 			 PARAMETERS,
1006 			 CREATION_DATE,
1007 			 CREATED_BY,
1008 			 LAST_UPDATE_DATE,
1009 			 LAST_UPDATED_BY,
1010 			 LAST_UPDATE_LOGIN,
1011 			 TYPE,
1012 			 WEB_HOST_NAME,
1013 			 WEB_AGENT_NAME,
1014 			 WEB_HTML_CALL,
1015 			 WEB_ENCRYPT_PARAMETERS,
1016 			 WEB_SECURED,
1017 			 WEB_ICON,
1018 			 OBJECT_ID,
1019 			 REGION_APPLICATION_ID,
1020 			 REGION_CODE,
1021 			 MAINTENANCE_MODE_SUPPORT,
1022 			 CONTEXT_DEPENDENCE,
1023 			 JRAD_REF_PATH,
1024 			 IREP_METHOD_NAME,
1025 			 IREP_DESCRIPTION,
1026 			 IREP_OVERLOAD_SEQUENCE,
1027 			 IREP_SCOPE,
1028 			 IREP_LIFECYCLE,
1029 			 IREP_COMPATIBILITY,
1030 			 IREP_INBOUND_XML_DESCRIPTION,
1031 			 IREP_OUTBOUND_XML_DESCRIPTION,
1032 			 IREP_SYNCHRO,
1033 			 IREP_DIRECTION,
1034 			 IREP_CLASS_ID,
1035 			 IREP_ASSOC_FUNCTION_NAME
1036 			)
1037 			values
1038 			(
1039 			l_function_id,
1040 			p_function_name,
1041 			p_application_id,
1042 			null,
1043 			null,
1044 			sysdate,
1045 			0,
1046 			sysdate,
1047 			0,
1048 			0,
1049 			'INTERFACE',
1050 			null,
1051 			null,
1052 			null,
1053 			null,
1054 			null,
1055 			null,
1056 			p_object_id,
1057 			null,
1058 			null,
1059 			'NONE',
1060 			'NONE',
1061 			null,
1062 			p_irep_method_name,
1063 			p_irep_description,
1064 			p_irep_overload_sequence,
1065 			p_irep_scope,
1066 			p_irep_lifecycle,
1067 			p_irep_compatibility,
1068 			p_irep_inbound_xml_desc,
1069 			p_irep_outbound_xml_desc,
1070 			p_irep_synchro,
1071 			p_irep_direction,
1072 			p_irep_class_id,
1073 			p_irep_assoc_function_name
1074 			);
1075 			/**We don't really need this**/
1076 			/**
1077 			ws_base_method_overload
1078 			(
1079 			l_function_id,
1080 			p_irep_description,
1081 			p_irep_scope,
1082 			p_irep_lifecycle,
1083 			p_irep_compatibility,
1084 			p_err_code,
1085 			p_err_message
1086 			);
1087 			**/
1088 
1089 			create_function_lang_entries
1090 			(
1091 			p_base_function_id,
1092 			l_function_id,
1093 			p_err_code,
1094 			p_err_message
1095 			);
1096 		exception
1097 		when program_exit then
1098 			raise program_exit;
1099 		when others then
1100 			p_err_code := -1;
1101 			p_err_message := 'Error in inserting to fnd_form_functions'||SQLERRM;
1102 			raise program_exit;
1103 		end;
1104 
1105 
1106 
1107 	elsif c_derived_method%FOUND then
1108 		--Update the existing entry
1109 		begin
1110 			update fnd_form_functions
1111 			set
1112 				APPLICATION_ID = p_application_id,
1113 				FORM_ID = p_form_id,
1114 				PARAMETERS = p_parameters,
1115 				CREATION_DATE = p_creation_date,
1116 				CREATED_BY = p_created_by,
1117 				LAST_UPDATE_DATE = sysdate,
1118 				LAST_UPDATED_BY = 0,
1119 				LAST_UPDATE_LOGIN = 0,
1120 				TYPE = p_type,
1121 				WEB_HOST_NAME = p_web_host_name,
1122 				WEB_AGENT_NAME = p_web_agent_name,
1123 				WEB_HTML_CALL = p_web_html_call,
1124 				WEB_ENCRYPT_PARAMETERS = p_web_encrypt_parameters,
1125 				WEB_SECURED = p_web_secured,
1126 				WEB_ICON = p_web_icon,
1127 				OBJECT_ID = p_object_id,
1128 				REGION_APPLICATION_ID = p_region_application_id,
1129 				REGION_CODE = p_region_code,
1130 				MAINTENANCE_MODE_SUPPORT = p_maintenance_mode_support,
1131 				CONTEXT_DEPENDENCE = p_context_dependence,
1132 				JRAD_REF_PATH = p_jrad_ref_path,
1133 				IREP_METHOD_NAME = p_irep_method_name,
1134 				IREP_DESCRIPTION = p_irep_description,
1135 				IREP_OVERLOAD_SEQUENCE = p_irep_overload_sequence,
1136 				IREP_SCOPE = p_irep_scope,
1137 				IREP_LIFECYCLE = p_irep_lifecycle,
1138 				IREP_COMPATIBILITY = p_irep_compatibility,
1139 				IREP_INBOUND_XML_DESCRIPTION = p_irep_inbound_xml_desc,
1140 				IREP_OUTBOUND_XML_DESCRIPTION = p_irep_outbound_xml_desc,
1141 				IREP_SYNCHRO = p_irep_synchro,
1142 				IREP_DIRECTION = p_irep_direction,
1143 				IREP_CLASS_ID =p_irep_class_id,
1144 				IREP_ASSOC_FUNCTION_NAME = p_irep_assoc_function_name
1145 			where current of c_derived_method;
1146 			/**
1147 			ws_base_method_overload
1148 			(
1149 			c_derived_method_rec.function_id,
1150 			p_irep_description,
1151 			p_irep_scope,
1152 			p_irep_lifecycle,
1153 			p_irep_compatibility,
1154 			p_err_code,
1155 			p_err_message
1156 			);
1157 			**/
1158 
1159 			create_function_lang_entries
1160 			(
1161 			p_base_function_id,
1162 			c_derived_method_rec.function_id,
1163 			p_err_code,
1164 			p_err_message
1168 		when program_exit then
1165 			);
1166 
1167 		exception
1169 			raise program_exit;
1170 		when others then
1171 			p_err_code := -1;
1172 			p_err_message := 'Error in Updating fnd_form_functions'||SQLERRM;
1173 			raise program_exit;
1174 		end;
1175 
1176 	end if;
1177 
1178 	close c_derived_method;
1179 
1180 	p_err_code := 0;
1181 	p_err_message := wf_core.translate('WF_WS_SUCCESS');
1182 exception
1183 when program_exit then
1184 	raise program_exit;
1185 when others then
1186 	p_err_code := -1;
1187         wf_core.token('FunctionName',p_function_name);
1188 	wf_core.token('BaseFunctionId',p_base_function_id);
1189 	wf_core.token('DerivedClassId',p_irep_class_id);
1190 	wf_core.token('SqlErr',SQLERRM);
1191 	p_err_message := wf_core.translate('WF_WS_FUNCTION_CREATE');
1192 	raise program_exit;
1193 end create_function_entry_detail;
1194 
1195 procedure create_function_lang_entries
1196 	(
1197 	p_base_function_id in number,
1198 	p_function_id in number,
1199 	p_err_code OUT NOCOPY pls_integer,
1200 	p_err_message OUT NOCOPY varchar2
1201 	)
1202 
1203 is
1204 	cursor c_base_function_tl(c_base_function_id in pls_integer) is
1205 	select *
1206 	from fnd_form_functions_tl
1207 	where function_id = c_base_function_id;
1208 
1209         cursor c_function_name(c_function_id in number) is
1210         select function_name
1211         from fnd_form_functions
1212         where function_id = c_function_id;
1213 
1214         p_function_name varchar2(430) := null;
1215   	c_base_function_tl_rec c_base_function_tl%ROWTYPE;
1216 
1217 begin
1218 	if ( (p_base_function_id is null) or (p_function_id is null) ) then
1219 		p_err_code := -1;
1220 		p_err_message := 'Base Function ID or Function ID is null';
1221 		raise program_exit;
1222 	end if;
1223 
1224         open c_function_name(p_function_id);
1225         fetch c_function_name into p_function_name;
1226         close c_function_name;
1227 
1228 	for c_base_function_tl_rec in c_base_function_tl(p_base_function_id)
1229 	loop
1230 		create_function_language
1231 		(
1232 		p_function_id,
1233 		c_base_function_tl_rec.language,
1234 		c_base_function_tl_rec.user_function_name,
1235 		c_base_function_tl_rec.description,
1236 		c_base_function_tl_rec.source_lang,
1237 		p_err_code,
1238 		p_err_message
1239 		);
1240 	end loop;
1241 	p_err_code := 0;
1242 	p_err_message := wf_core.translate('WF_WS_SUCCESS');
1243 
1244 exception
1245 when program_exit then
1246 	raise program_exit;
1247 when others then
1248 	p_err_code := -1;
1249 	wf_core.token('BaseFunctionId',p_base_function_id);
1250 	wf_core.token('DerivedFunctionId',p_function_id);
1251         wf_core.token('DerivedFunctionName',p_function_name);
1252 	wf_core.token('SqlErr',SQLERRM);
1253 	p_err_message := wf_core.translate('WF_WS_FUNC_LANG_ENTRIES');
1254 	raise program_exit;
1255 end create_function_lang_entries;
1256 
1257 
1258 
1259 procedure create_function_language
1260 	(
1261 	p_function_id  in number,
1262 	p_language in varchar2,
1263 	p_user_function_name in varchar2,
1264 	p_description in varchar2,
1265 	p_source_lang in varchar2,
1266 	p_err_code OUT NOCOPY pls_integer,
1267 	p_err_message OUT NOCOPY varchar2
1268 	)
1269 is
1270 	cursor c_function_language
1271 	(
1272 	c_function_id number,
1273 	c_language in varchar2
1274 	) is
1275 	select *
1276 	from fnd_form_functions_tl
1277 	where  function_id = c_function_id
1278 	and language = c_language
1279 	for update ;
1280 
1281 	c_function_language_rec c_function_language%ROWTYPE;
1282 
1283         cursor c_function_name(c_function_id in number) is
1284         select function_name
1285         from fnd_form_functions
1286         where function_id = c_function_id;
1287 
1288         p_function_name varchar2(430) := null;
1289 
1290 begin
1291 
1292 	if ( (p_function_id is null) or (p_language is null) ) then
1293 		p_err_code := -1;
1294 		p_err_message := 'Function ID or Language is null';
1295 		raise program_exit;
1296 	end if;
1297 
1298         open c_function_name(p_function_id);
1299         fetch c_function_name into p_function_name;
1300         close c_function_name;
1301 
1302 	open c_function_language(p_function_id,p_language);
1303 	fetch c_function_language into c_function_language_rec;
1304 
1305 	if c_function_language%NOTFOUND then
1306 
1307 		insert into FND_FORM_FUNCTIONS_TL
1308 		(
1309 		LANGUAGE,
1310 		FUNCTION_ID,
1311 		USER_FUNCTION_NAME,
1312 		CREATION_DATE,
1313 		CREATED_BY,
1314 		LAST_UPDATE_DATE,
1315 		LAST_UPDATED_BY,
1316 		LAST_UPDATE_LOGIN,
1317 		DESCRIPTION,
1318 		SOURCE_LANG
1319 		)
1320 		values
1321 		(
1322 		p_language,
1323 		p_function_id,
1324 		p_user_function_name,
1325 		sysdate,
1326 		0,
1327 		sysdate,
1328 		0,
1329 		0,
1330 		p_description,
1331 		p_source_lang
1332 		);
1333 
1334 	elsif c_function_language%FOUND then
1335 
1336 		update fnd_form_functions_tl
1337 		set 	user_function_name = p_user_function_name,
1338 			description = p_description,
1339 			source_lang = p_source_lang,
1340 			last_update_date = sysdate,
1341 			last_updated_by = 0,
1342 			last_update_login = 0
1343 		where current of c_function_language;
1344 
1345 	end if;
1346 
1347 	close c_function_language;
1348 
1349 	p_err_message :=wf_core.translate('WF_WS_SUCCESS');
1350 	p_err_code :=0;
1351 exception
1352 when program_exit then
1353 	raise program_exit;
1354 when others then
1355 	p_err_code := -1;
1356         wf_core.token('DerivedFunctionName', p_function_name);
1357 	wf_core.token('DerivedFunctionId',p_function_id);
1358 	wf_core.token('Lang',p_language);
1359 	wf_core.token('SqlErr',SQLERRM);
1360 	p_err_message := wf_core.translate('WF_WS_FUNC_LANG');
1361 	raise program_exit;
1362 end create_function_language;
1363 
1364 procedure create_class_language
1365 	(
1366 	p_class_id  in number,
1367 	p_language in varchar2,
1368 	p_source_lang in varchar2,
1369 	p_display_name in varchar2,
1370 	p_short_description in varchar2,
1371 	p_security_group_id in number,
1372 	p_err_code OUT NOCOPY pls_integer,
1373 	p_err_message OUT NOCOPY varchar2
1374 	)
1375 is
1376 	cursor c_class_language
1377 	(
1378 	c_class_id number,
1379 	c_language in varchar2
1380 	) is
1381 	select *
1382 	from fnd_irep_classes_tl
1383 	where  class_id = c_class_id
1384 	and language = c_language
1385 	for update ;
1386 
1387 	c_class_language_rec c_class_language%ROWTYPE;
1388 
1389         cursor c_class_name(c_class_id in number) is
1390         select class_name
1391         from fnd_irep_classes
1392         where class_id = c_class_id;
1393 
1394         p_derived_class_name varchar2(430) := null;
1395 
1396 begin
1397 	if ( (p_class_id is null) or (p_language is null) ) then
1398 		p_err_code := -1;
1399 		p_err_message := 'Class ID or Language is null';
1400 		raise program_exit;
1401 	end if;
1402 
1403         open c_class_name(p_class_id);
1404         fetch c_class_name into p_derived_class_name;
1405         close c_class_name;
1406 
1407 	open c_class_language(p_class_id,p_language);
1408 	fetch c_class_language into c_class_language_rec;
1409 
1410 	if c_class_language%NOTFOUND then
1411 
1412 		insert into fnd_irep_classes_TL
1413 		(
1414 		CLASS_ID,
1415 		LANGUAGE,
1416 		SOURCE_LANG,
1417 		DISPLAY_NAME,
1418 		SHORT_DESCRIPTION,
1419 		CREATED_BY,
1420 		CREATION_DATE,
1421 		LAST_UPDATED_BY,
1422 		LAST_UPDATE_DATE,
1423 		LAST_UPDATE_LOGIN,
1424 		SECURITY_GROUP_ID
1425 		)
1426 		values
1427 		(
1428 		p_class_id,
1429 		p_language,
1430 		p_source_lang,
1431 		p_display_name,
1432 		p_short_description,
1433 		0,
1434 		sysdate,
1435 		0,
1436 		sysdate,
1437 		0,
1438 		0
1439 		);
1440 
1441 	elsif c_class_language%FOUND then
1442 
1443 		update fnd_irep_classes_tl
1444 		set 	display_name = p_display_name,
1445 			short_description = p_short_description,
1446 			source_lang = p_source_lang,
1447 			last_update_date = sysdate,
1448 			last_updated_by = 0,
1449 			last_update_login = 0,
1450 			security_group_id = p_security_group_id
1451 		where current of c_class_language;
1452 
1453 	end if;
1454 
1455 	close c_class_language;
1456 
1457 	p_err_message :=wf_core.translate('WF_WS_SUCCESS');
1458 	p_err_code :=0;
1459 exception
1460 when program_exit then
1461 	raise program_exit;
1462 when others then
1463 	p_err_code := -1;
1464         wf_core.token('DerivedClassName', p_derived_class_name);
1465 	wf_core.token('DerivedClassId',p_class_id);
1466 	wf_core.token('Lang',p_language);
1467 	wf_core.token('SqlErr',SQLERRM);
1468 	p_err_message := wf_core.translate('WF_WS_CLASS_LANG');
1469 	raise program_exit;
1470 end create_class_language;
1471 
1472 
1473 procedure create_class_lang_entries
1474 	(
1475 	p_base_class_id in number,
1476 	p_class_id in number,
1477 	p_err_code OUT NOCOPY pls_integer,
1478 	p_err_message OUT NOCOPY varchar2
1479 	)
1480 
1481 is
1482 	cursor c_base_class_tl(c_base_class_id in pls_integer) is
1483 	select *
1484 	from fnd_irep_classes_tl
1485 	where class_id = c_base_class_id;
1486 
1487   	c_base_class_tl_rec c_base_class_tl%ROWTYPE;
1488 
1489         cursor c_class_name(c_class_id in number) is
1490         select class_name
1491         from fnd_irep_classes
1492         where class_id = c_class_id;
1493 
1494         p_derived_class_name varchar2(430) := null;
1495 
1496 begin
1497 	if ( (p_base_class_id is null) or (p_class_id is null) ) then
1498 		p_err_code := -1;
1499 		p_err_message := 'Base Class ID or Class ID is null';
1500 		raise program_exit;
1501 	end if;
1502 
1503         open c_class_name(p_class_id);
1504         fetch c_class_name into p_derived_class_name;
1505         close c_class_name;
1506 
1507 	for c_base_class_tl_rec in c_base_class_tl(p_base_class_id)
1508 	loop
1509 		create_class_language
1510 		(
1511 		p_class_id,
1512 		c_base_class_tl_rec.language,
1513 		c_base_class_tl_rec.source_lang,
1514 		c_base_class_tl_rec.display_name,
1515 		c_base_class_tl_rec.short_description,
1516 		c_base_class_tl_rec.security_group_id,
1517 		p_err_code,
1518 		p_err_message
1519 		);
1520 	end loop;
1521 
1522 	p_err_code := 0;
1523 	p_err_message := wf_core.translate('WF_WS_SUCCESS');
1524 
1525 exception
1526 when program_exit then
1527 	raise program_exit;
1528 when others then
1529 	p_err_code := -1;
1530         wf_core.token('DerivedClassName', p_derived_class_name);
1531 	wf_core.token('DerivedClassId',p_class_id);
1532 	wf_core.token('SqlErr',SQLERRM);
1533 	p_err_message := wf_core.translate('WF_WS_CLASS_LANG_ENTRIES');
1534 	raise program_exit;
1535 end create_class_lang_entries;
1536 
1537 procedure create_xmlg_schema
1538 	(
1539 	p_clob OUT NOCOPY clob,
1540 	p_root_element in varchar,
1541 	p_product_code in varchar2,
1542 	p_direction in varchar,
1543 	p_port_type in varchar,
1544         p_operation in varchar,
1545 	p_err_code OUT NOCOPY pls_integer,
1546 	p_err_message OUT NOCOPY varchar2
1547 	)
1548 is
1549 
1550 	i_tmp				clob;
1551 	i_buffer varchar2(32767) 	:= null;
1552 	i_lob_len			pls_integer;
1553 	i_root				varchar2(200);
1554 begin
1555 	dbms_lob.createtemporary(i_tmp,true,dbms_lob.session);
1556 
1557 	if ( p_direction = 'IN') then
1558 
1559 
1560 		i_buffer := '<xsd:schema elementFormDefault="qualified"'||
1561 				 ' targetNamespace="http://xmlns.oracle.com/apps/'||lower(p_product_code)||'/'||p_port_type||'/'||p_operation||'">'||
1562 			    '	<xsd:element name="'||p_root_element||'" type="xsd:anyType"/>'||
1563 		            '</xsd:schema>';
1564 	elsif (p_direction = 'OUT') then
1565 		i_buffer :='<xsd:schema elementFormDefault="qualified"'||
1566 				 ' targetNamespace="http://xmlns.oracle.com/apps/fnd/XMLGateway">'||
1567 			    '	<xsd:element name="ReceiveDocument_Response">'||
1568 			    '		<xsd:complexType>'||
1569 			    '			<xsd:sequence>'||
1570 			    '				<xsd:element name="ResponseCode" type="xsd:string" />'||
1571 			    '				<xsd:element name="ResponseCode" type="xsd:string" />'||
1572 		            '		 		<xsd:element name="ResponseCode" type="xsd:string" />'||
1573 		            '			</xsd:sequence>'||
1574 		            '		</xsd:complexType>'||
1575 		            '	</xsd:element>'||
1576 		            '</xsd:schema>';
1577 	end if;
1578 
1579 	i_lob_len := length(i_buffer);
1580 	dbms_lob.write(i_tmp,i_lob_len,1,i_buffer);
1581 	p_clob := i_tmp;
1582 	dbms_lob.freetemporary(i_tmp);
1583 
1584 	p_err_code := 0;
1585 	p_err_message := wf_core.translate('WF_WS_SUCCESS');
1586 exception
1587 when program_exit then
1588 	raise program_exit;
1589 when others then
1590 	p_err_code := -1;
1591 	wf_core.token('InterfaceName',p_port_type);
1592 	wf_core.token('SqlErr',SQLERRM);
1593 	p_err_message := wf_core.translate('WF_WS_XMLG_SCHEMA');
1594 	raise program_exit;
1595 end create_xmlg_schema;
1596 
1597 
1598 procedure to_upper
1599 	(
1600 	p_name in varchar2,
1601 	p_new_name OUT NOCOPY varchar2,
1602 	p_err_code OUT NOCOPY pls_integer,
1603 	p_err_message OUT NOCOPY varchar2
1604 	) is
1605 	l_var varchar2(100);
1606 begin
1607 	if length(p_name) >0 then
1608 		l_var := substr(p_name,1,1);
1609 		l_var := upper(l_var);
1610 		l_var := l_var||lower(substr(p_name,2,length(p_name)));
1611 		p_new_name := l_var;
1612 	end if;
1613 
1614 	p_err_code := 0;
1615 	p_err_message := wf_core.translate('WF_WS_SUCCESS');
1616 exception
1617 when program_exit then
1618 	raise program_exit;
1619 when others then
1620 	p_err_code := -1;
1621 	wf_core.token('Name',p_name);
1622 	wf_core.token('SqlErr',SQLERRM);
1623 	p_err_message := wf_core.translate('WF_WS_XMLG_NS');
1624 	raise program_exit;
1625 end to_upper;
1626 
1627 
1628 procedure get_root_element
1629         (
1630         p_map_code in varchar2,
1631         p_root_element OUT NOCOPY varchar2,
1632         p_err_code OUT NOCOPY pls_integer,
1633         p_err_message OUT NOCOPY varchar2
1634         ) is
1635 
1636         i_map_id  number;
1637         invalid_input     exception;
1638 begin
1639 
1640         if (p_map_code = '') or (p_map_code is null)
1641         then
1642            raise invalid_input;
1643         end if;
1644 
1645         select map_id
1646         into i_map_id
1647         from ecx_mappings
1648         where map_code = p_map_code;
1649 
1650 
1651         select root_element
1652         into p_root_element
1653         from  ecx_objects
1654         where map_id = i_map_id and
1655               (object_type = 'XML' or
1656                object_type = 'DTD');
1657 
1658 
1659 exception
1660 when others then
1661         p_err_code := -1;
1662         wf_core.token('GetRootElement mapCode', p_map_code);
1663         wf_core.token('SqlErr',SQLERRM);
1664         p_err_message := wf_core.translate('WF_WS_MODULE_FAILED');
1665         raise program_exit;
1666 end get_root_element;
1667 
1668 procedure create_object_derived_entry
1669 	(
1670 	p_base_object_id in pls_integer,
1671 	p_entry_type in varchar2,
1672 	x_derived_class_id OUT NOCOPY pls_integer,
1673 	p_err_code OUT NOCOPY pls_integer,
1674 	p_err_message OUT NOCOPY varchar2
1675 	)
1676 
1677 is
1678 
1679 	cursor c_object(c_object_id in number) is
1680  	select count(*) l_count
1681  	from fnd_objects
1682  	where object_id = c_object_id;
1683 
1684 
1685         cursor c_object_name(c_object_id in number) is
1686         select obj_name ,irep_name
1687         from fnd_objects
1688         where object_id = c_object_id;
1689 
1690  	c_object_rec c_object%ROWTYPE;
1691 
1692 	cursor 	c_methods(c_object_id in number) is
1693 	select function_id
1694 	from fnd_form_functions
1695 	where irep_class_id = c_object_id ;
1696 
1697 	method_count pls_integer := 0;
1698 	p_base_object_name varchar2(430) := null;
1699 	x_irep_name varchar2(500) := null;
1700 
1701 
1702 begin
1703 
1704 	if (p_base_object_id is null ) then
1705 		p_err_code := -1;
1706 		p_err_message := wf_core.translate('WF_WS_MISSING_CLASS_ID');
1707 		raise program_exit;
1708 	end if;
1709 
1710 	if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1711 		FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_object_derived_entry', 'Process Object ID='||p_base_object_id);
1712 	end if;
1713 
1714 	open c_object(p_base_object_id);
1715 	fetch c_object into c_object_rec;
1716 	close c_object;
1717 
1721 
1718         open c_object_name(p_base_object_id);
1719         fetch c_object_name into p_base_object_name,x_irep_name;
1720         close c_object_name;
1722 	if c_object_rec.l_count = 0 then
1723 		p_err_code := -1;
1724 		--todo create new token
1725 		--wf_core.token('BaseClassId',p_base_class_id);
1726 		p_err_message := wf_core.translate('WF_WS_BASE_CLASS_NOT_EXIST');
1727 		raise program_exit;
1728 	end if;
1729 
1730 	for c1 in c_methods(p_base_object_id)
1731 	loop
1732 		method_count := method_count + 1;
1733 
1734 
1735 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1736 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_object_derived_entry', 'Processing FunctionID='||c1.function_id);
1737 		end if;
1738 
1739 
1740 		begin
1741 	                create_obj_func_derived_entry(p_base_object_id,c1.function_id,p_entry_type,x_derived_class_id,p_err_code,p_err_message);
1742 		exception
1743 		when ignore_rec  then
1744 			null;
1745 		when program_exit then
1746 			raise program_exit;
1747 		when others then
1748 			p_err_code := -1;
1749 			--todo create new tokens
1750 			--wf_core.token('BaseClassId',p_base_object_id);
1751                         --wf_core.token('BaseClassName', p_base_object_name);
1752 			--wf_core.token('FunctionId',c1.function_id);
1753 			--wf_core.token('SqlErr',SQLERRM);
1754 			p_err_message := wf_core.translate('WF_WS_CLASS_FUNC_ITER');
1755 			raise program_exit;
1756 		end;
1757 
1758 	end loop;
1759 
1760 	wf_core.token('BaseClassId',p_base_object_id);
1761         wf_core.token('BaseClassName', p_base_object_name);
1762 	if (method_count = 0 ) then
1763 		p_err_code := -1;
1764 		p_err_message := wf_core.translate('WF_WS_NO_BASE_METHODS');
1765 	elsif ( method_count > 0 ) then
1766 		p_err_code := 0;
1767 		p_err_message := wf_core.translate('WF_WS_SUCCESS');
1768 	end if;
1769 
1770 exception
1771 when program_exit then
1772 	null;
1773 when others then
1774 	p_err_code := -1;
1775 	wf_core.token('BaseClassId',p_base_object_id);
1776         wf_core.token('BaseClassName', p_base_object_name);
1777 	wf_core.token('SqlErr',SQLERRM);
1778 	p_err_message := wf_core.translate('WF_WS_CLASS_DERIVED');
1779 end create_object_derived_entry;
1780 
1781 /**
1782 Procedure for creating a Derived Entry for all functions of a base Object Entry
1783 Base entry is in fnd_objects and its derived entry would be made in fnd_irep_classes
1784 **/
1785 procedure create_obj_func_derived_entry
1786 	(
1787 	p_base_object_id in pls_integer,
1788 	p_base_function_id in pls_integer,
1789 	p_entry_type in varchar2,
1790 	l_derived_class_id OUT NOCOPY pls_integer,
1791 	p_err_code OUT NOCOPY pls_integer,
1792 	p_err_message OUT NOCOPY varchar2
1793 	)
1794 
1795 is
1796 
1797 	cursor c_base_object_entry(c_base_object_id in number) is
1798 	select 	*
1799 	from fnd_objects_vl
1800 	where object_id = c_base_object_id;
1801 
1802 	c_base_object_entry_rec c_base_object_entry%ROWTYPE;
1803 
1804 	cursor c_base_function_entry(c_base_function_id in number) is
1805 	select  *
1806 	from fnd_form_functions
1807 	where function_id = c_base_function_id;
1808 
1809 	c_base_function_entry_rec c_base_function_entry%ROWTYPE;
1810 
1811 	i_function_name varchar2(2000) :=null;
1812 	i_port_type varchar2(2000) := null;
1813 	i_operation varchar2(2000) := null;
1814 	i_delimitor pls_integer;
1815 	i_delimitor2 pls_integer;
1816 	i_derived_class_name varchar2(2000) := null;
1817 	i_xmlg_prefix varchar2(2000) := null;
1818         i_root_element varchar2(255) := null;
1819 
1820 --	l_derived_class_id pls_integer;
1821 	in_xml clob := null;
1822 	out_xml clob := null;
1823 
1824 begin
1825 	/**Get the base entry**
1826 	**If its XML Gateway then care about grouping otherwise don't**
1827 	**/
1828 
1829 
1830 	if ( (p_base_object_id is null) or (p_base_function_id is null)) then
1831 		p_err_code := -1;
1832 		p_err_message := wf_core.translate('WF_WS_MISSING_CLASS_FUNC_ID');
1833 		raise program_exit;
1834 	end if;
1835 
1836 
1837 	/*Get the Base Entry object**/
1838 	open c_base_object_entry(p_base_object_id);
1839 	fetch c_base_object_entry into c_base_object_entry_rec;
1840 
1841 	if c_base_object_entry%NOTFOUND then
1842 
1843 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1844 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create.obj.function.derived.entry', 'Base Object ID='||p_base_object_id||' does not exist');
1845 		end if;
1846 
1847 		p_err_code := -1;
1848 		p_err_message := wf_core.translate('WF_WS_BASE_CLASS_NOT_EXIST');
1849 		raise program_exit;
1850 
1851 	elsif c_base_object_entry%FOUND then
1852 
1853 
1854 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1855 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create.obj.function.derived.entry', 'Base object ID='||p_base_object_id||' exists');
1856 		end if;
1857 
1858 		open c_base_function_entry(p_base_function_id);
1859 		fetch c_base_function_entry into c_base_function_entry_rec;
1860 
1861 		if c_base_function_entry%FOUND then
1862 
1863 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1864 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create.obj.function.derived.entry', 'Base Function='||p_base_function_id||' exist');
1865 			end if;
1866 
1867 			if ( c_base_function_entry_rec.irep_class_id <> p_base_object_id ) then
1868 				p_err_code :=-1;
1869 				p_err_message := wf_core.translate('WF_WS_CLASS_FUNC_MISMATCH');
1870 				raise program_exit;
1871 			end if;
1872 
1876 
1873 			if ( c_base_object_entry_rec.irep_scope = 'PUBLIC' AND c_base_function_entry_rec.irep_scope = 'PUBLIC' ) then
1874 
1875 
1877 				if ( c_base_object_entry_rec.irep_object_type = 'INTERFACETABLE' or c_base_object_entry_rec.irep_object_type = 'INTERFACEVIEW') then
1878 
1879 					if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1880 						FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create.obj.function.derived.entry', 'OBJECT Type:INTERFACETABLE/INTERFACEVIEW ');
1881 					end if;
1882 
1883 					i_function_name := c_base_object_entry_rec.irep_name;
1884 
1885 
1886 
1887 					i_port_type := i_function_name;
1888 					i_derived_class_name := i_port_type;
1889 
1890 					i_operation := c_base_function_entry_rec.irep_method_name;
1891 					--dbms_output.put_line('I_Operation='||i_operation||'x');
1892 					--dbms_output.put_line('I_Operation length='||length(i_operation)||'x');
1893 					if ( (i_operation is null ) or (length(i_operation) is NULL ) ) then
1894 						p_err_code := -1;
1895 						p_err_message :=wf_core.translate('WF_WS_MISSING_IREP_METHOD_NAME');
1896 						raise program_exit;
1897 					end if;
1898 
1899 
1900 					create_class_entry_detail
1901 					(
1902 					c_base_object_entry_rec.object_id,
1903 					p_entry_type||':'||i_derived_class_name,
1904 					i_derived_class_name,
1905 					c_base_object_entry_rec.created_by,
1906 					c_base_object_entry_rec.creation_date,
1907 					null,
1908 					p_entry_type,
1909 					c_base_object_entry_rec.irep_product,
1910 					null,
1911 					'N',
1912 					'N',
1913 					c_base_object_entry_rec.irep_compatibility,
1914 					c_base_object_entry_rec.object_id,
1915 					c_base_object_entry_rec.irep_scope,
1916 					c_base_object_entry_rec.irep_lifecycle,
1917 					c_base_object_entry_rec.irep_source_file_product,
1918 					c_base_object_entry_rec.irep_source_file_path,
1919 					c_base_object_entry_rec.irep_source_file_name,
1920 					c_base_object_entry_rec.irep_source_file_version,
1921 					c_base_object_entry_rec.irep_description,
1922 					c_base_object_entry_rec.irep_xml_description,
1923 					c_base_object_entry_rec.irep_standard,
1924 					c_base_object_entry_rec.irep_standard_version,
1925 					c_base_object_entry_rec.irep_standard_spec,
1926 					null,
1927 					null,
1928 					null,
1929                                         null,
1930 					p_entry_type,
1931 					l_derived_class_id,
1932 					p_err_code,
1933 					p_err_message
1934 					);
1935 					/**
1936 					assign_business_entities
1937 					(
1938 					c_base_class_entry_rec.class_id,
1939 					l_derived_class_id,
1940 					p_err_code,
1941 					p_err_message
1942 					);
1943 					**/
1944 
1945 
1946 					/**What should be the value for description and user_function in method tl table**/
1947 					i_operation := upper(substr(i_operation,0,1))||substr(i_operation,2,length(i_operation));
1948 					create_function_entry_detail
1949 					(
1950 					p_entry_type||':'||i_derived_class_name||':'||i_operation,
1951 					c_base_function_entry_rec.application_id,
1952 					c_base_function_entry_rec.form_id,
1953 					c_base_function_entry_rec.parameters,
1954 					c_base_function_entry_rec.creation_date,
1955 					c_base_function_entry_rec.created_by,
1956 					c_base_function_entry_rec.type,
1957 					c_base_function_entry_rec.web_host_name,
1958 					c_base_function_entry_rec.web_agent_name,
1959 					c_base_function_entry_rec.web_html_call,
1960 					c_base_function_entry_rec.web_encrypt_parameters,
1961 					c_base_function_entry_rec.web_secured,
1962 					c_base_function_entry_rec.web_icon,
1963 					c_base_function_entry_rec.object_id,
1964 					c_base_function_entry_rec.region_application_id,
1965 					c_base_function_entry_rec.region_code,
1966 					c_base_function_entry_rec.maintenance_mode_support,
1967 					c_base_function_entry_rec.context_dependence,
1968 					c_base_function_entry_rec.jrad_ref_path,
1969 					i_operation,
1970 					c_base_function_entry_rec.irep_overload_sequence,
1971 					c_base_function_entry_rec.irep_scope,
1972 					c_base_function_entry_rec.irep_lifecycle,
1973 					c_base_function_entry_rec.irep_description,
1974 					c_base_function_entry_rec.irep_compatibility,
1975 					c_base_function_entry_rec.irep_inbound_xml_description,
1976 					c_base_function_entry_rec.irep_outbound_xml_description,
1977 					c_base_function_entry_rec.irep_synchro,
1978 					c_base_function_entry_rec.irep_direction,
1979 					c_base_function_entry_rec.function_name,
1980 					l_derived_class_id,
1981 					p_base_function_id,
1982 					p_err_code,
1983 					p_err_message
1984 					);
1985 
1986 				end if;
1987 			else
1988 				if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1989 					FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create.obj.function.derived.entry', 'ObjectID,FunctionID:'
1990 					||c_base_object_entry_rec.object_id||','||c_base_function_entry_rec.function_id||' Not a public interface/method to be exposed');
1991 				end if;
1992 
1993 				p_err_code := -1;
1994 				p_err_message := wf_core.translate('WF_WS_NOT_PUBLIC');
1995 				raise program_exit;
1996 			end if;
1997 		else
1998 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
1999 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create.obj.function.derived.entry', ' No records found for FunctionID='||c_base_function_entry_rec.function_id);
2000 			end if;
2001 
2002 			p_err_code := -1;
2003 			p_err_message := wf_core.translate('WF_WS_BASE_FUNC_NOT_EXIST');
2004 			raise program_exit;
2005 		end if;
2006 
2007 		close c_base_function_entry;
2008 	end if;
2009 
2010 	close c_base_object_entry;
2011 
2012 	p_err_code := 0;
2013 	--todo create new token
2014 	--wf_core.token('ClassId',p_base_class_id);
2018 when ignore_rec then
2015 	p_err_message :=wf_core.translate('WF_WS_SUCCESS');
2016 
2017 exception
2019 	raise ignore_rec;
2020 when program_exit then
2021 	raise program_exit;
2022 when others then
2023 	p_err_code := -1;
2024 	p_err_message :=wf_core.translate('WF_WS_GENERIC_CLASS_ERROR')||'Error in Creating Derived Entry for Base FUNCTION_ID='||p_base_function_id||SQLERRM;
2025 	raise program_exit;
2026 end create_obj_func_derived_entry;
2027 
2028 
2029 procedure create_obj_function_base_entry
2030 	(
2031 	p_base_object_id in pls_integer,
2032 	p_function_name in varchar2,
2033 	l_function_id OUT NOCOPY pls_integer,
2034 	p_err_code OUT NOCOPY pls_integer,
2035 	p_err_message OUT NOCOPY varchar2
2036 	)
2037 
2038 is
2039 
2040 	cursor c_base_object_entry(c_base_object_id in number) is
2041 	select 	*
2042 	from fnd_objects
2043 	where object_id = c_base_object_id;
2044 
2045 	c_base_object_entry_rec c_base_object_entry%ROWTYPE;
2046 
2047 
2048 	cursor c_irep_function_id is
2049 	select fnd_form_functions_s.nextval
2050 	from dual;
2051 
2052 	--l_function_id number := 0;
2053 
2054 
2055 
2056 begin
2057 
2058 
2059 	if ( p_base_object_id is null) then
2060 		p_err_code := -1;
2061 		p_err_message := wf_core.translate('WF_WS_MISSING_CLASS_FUNC_ID');
2062 		raise program_exit;
2063 	end if;
2064 
2065 
2066 	/*Get the Base Entry class**/
2067 	open c_base_object_entry(p_base_object_id);
2068 	fetch c_base_object_entry into c_base_object_entry_rec;
2069 
2070 	if c_base_object_entry%NOTFOUND then
2071 
2072 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2073 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_object_function_base_entry', 'Base Object ID='||p_base_object_id||' does not exist');
2074 		end if;
2075 
2076 		p_err_code := -1;
2077 		p_err_message := wf_core.translate('WF_WS_BASE_CLASS_NOT_EXIST');
2078 		raise program_exit;
2079 
2080 	elsif c_base_object_entry%FOUND then
2081 
2082 
2083 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2084 			FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_object_function_base_entry', 'Base Object ID='||p_base_object_id||' exists');
2085 		end if;
2086 
2087 
2088 		if ( c_base_object_entry_rec.irep_scope = 'PUBLIC' ) then
2089 
2090 
2091 			if ( c_base_object_entry_rec.irep_object_type = 'INTERFACETABLE' or c_base_object_entry_rec.irep_object_type = 'INTERFACEVIEW') then
2092 
2093 				if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2094 					FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_object_function_base_entry', 'Object Type:INTERFACETABLE/INTERFACEVIEW ');
2095 				end if;
2096 
2097 
2098 				--dbms_output.put_line('Function ='||p_function_name);
2099 				if ( (p_function_name is null ) or (length(p_function_name) is NULL ) ) then
2100 					p_err_code := -1;
2101 					p_err_message :=wf_core.translate('WF_WS_MISSING_IREP_METHOD_NAME');
2102 					raise program_exit;
2103 				end if;
2104 
2105 
2106 
2107 
2108 				open c_irep_function_id;
2109 				fetch c_irep_function_id into l_function_id;
2110 				close c_irep_function_id;
2111 				insert into FND_FORM_FUNCTIONS
2112 				(
2113 				 FUNCTION_ID,
2114 				 FUNCTION_NAME,
2115 				 APPLICATION_ID,
2116 				 FORM_ID,
2117 				 PARAMETERS,
2118 				 CREATION_DATE,
2119 				 CREATED_BY,
2120 				 LAST_UPDATE_DATE,
2121 				 LAST_UPDATED_BY,
2122 				 LAST_UPDATE_LOGIN,
2123 				 TYPE,
2124 				 WEB_HOST_NAME,
2125 				 WEB_AGENT_NAME,
2126 				 WEB_HTML_CALL,
2127 				 WEB_ENCRYPT_PARAMETERS,
2128 				 WEB_SECURED,
2129 				 WEB_ICON,
2130 				 OBJECT_ID,
2131 				 REGION_APPLICATION_ID,
2132 				 REGION_CODE,
2133 				 MAINTENANCE_MODE_SUPPORT,
2134 				 CONTEXT_DEPENDENCE,
2135 				 JRAD_REF_PATH,
2136 				 IREP_METHOD_NAME,
2137 				 IREP_DESCRIPTION,
2138 				 IREP_OVERLOAD_SEQUENCE,
2139 				 IREP_SCOPE,
2140 				 IREP_LIFECYCLE,
2141 				 IREP_COMPATIBILITY,
2142 				 IREP_INBOUND_XML_DESCRIPTION,
2143 				 IREP_OUTBOUND_XML_DESCRIPTION,
2144 				 IREP_SYNCHRO,
2145 				 IREP_DIRECTION,
2146 				 IREP_CLASS_ID,
2147 				 IREP_ASSOC_FUNCTION_NAME
2148 				)
2149 				values
2150 				(
2151 				l_function_id,
2152 				c_base_object_entry_rec.obj_name || ':' || p_function_name,
2153 				null,
2154 				null,
2155 				null,
2156 				sysdate,
2157 				0,
2158 				sysdate,
2159 				0,
2160 				0,
2161 				'INTERFACE',
2162 				null,
2163 				null,
2164 				null,
2165 				null,
2166 				null,
2167 				null,
2168 				null,
2169 				null,
2170 				null,
2171 				'NONE',
2172 				'NONE',
2173 				null,
2174 				p_function_name,
2175 				p_function_name || ' Operation',
2176 				1,
2177 				c_base_object_entry_rec.irep_scope,
2178 				c_base_object_entry_rec.irep_lifecycle,
2179 				c_base_object_entry_rec.irep_compatibility,
2180 				null,
2181 				null,
2182 				null,
2183 				null,
2184 				p_base_object_id,
2185 				null
2186 				);
2187 
2188 				--todo find if functionLanguage entry is mandatory.
2189 
2190 			end if;
2191 		else
2192 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
2193 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'oracle.apps.fnd.wf.ws.create_object_function_base_entry', 'objectID:'||c_base_object_entry_rec.object_id||' Not a public interface to be exposed');
2194 			end if;
2195 
2196 			p_err_code := -1;
2197 			p_err_message := wf_core.translate('WF_WS_NOT_PUBLIC');
2198 			raise program_exit;
2199 		end if;
2200 
2201 
2202 	end if;
2203 
2204 	close c_base_object_entry;
2205 
2206 	p_err_code := 0;
2207 	-- todo create new tokens for successful message.
2208 	--wf_core.token('BaseClassId',p_base_object_id);
2209 	--p_err_message :=wf_core.translate('WF_WS_SUCCESS');
2210 
2211 exception
2212 when ignore_rec then
2213 	raise ignore_rec;
2214 when program_exit then
2215 	raise program_exit;
2216 when others then
2217 	p_err_code := -1;
2218 	p_err_message :=wf_core.translate('WF_WS_GENERIC_object_ERROR')||'Error in Creating Base Entry for Base object_ID='||p_base_object_id||SQLERRM;
2219 	raise program_exit;
2220 end create_obj_function_base_entry;
2221 
2222 end SOA_GENERATE;