DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_KI_INTEGRATIONS_API

Source


1 Package Body HR_KI_INTEGRATIONS_API as
2 /* $Header: hrintapi.pkb 115.1 2004/01/28 23:31:04 vkarandi noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := 'HR_KI_INTEGRATIONS_API';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------< CREATE_INTEGRATION >--------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_integration
13   (p_validate                      in     boolean  default false
14   ,p_language_code                 in     varchar2 default hr_api.userenv_lang
15   ,p_integration_key               in     varchar2
16   ,p_party_type                    in     varchar2 default null
17   ,p_party_name                    in     varchar2 default null
18   ,p_party_site_name               in     varchar2 default null
19   ,p_transaction_type              in     varchar2 default null
20   ,p_transaction_subtype           in     varchar2 default null
21   ,p_standard_code                 in     varchar2 default null
22   ,p_ext_trans_type                in     varchar2 default null
23   ,p_ext_trans_subtype             in     varchar2 default null
24   ,p_trans_direction               in     varchar2 default null
25   ,p_url                           in     varchar2 default null
26   ,p_partner_name                  in     varchar2
27   ,p_service_name                  in     varchar2
28   ,p_ext_application_id            in     number   default null
29   ,p_application_name              in     varchar2 default null
30   ,p_application_type              in     varchar2 default null
31   ,p_application_url               in     varchar2 default null
32   ,p_logout_url                    in     varchar2 default null
33   ,p_user_field                    in     varchar2 default null
34   ,p_password_field                in     varchar2 default null
35   ,p_authentication_needed         in     varchar2 default null
36   ,p_field_name1                   in     varchar2 default null
37   ,p_field_value1                  in     varchar2 default null
38   ,p_field_name2                   in     varchar2 default null
39   ,p_field_value2                  in     varchar2 default null
40   ,p_field_name3                   in     varchar2 default null
41   ,p_field_value3                  in     varchar2 default null
42   ,p_field_name4                   in     varchar2 default null
43   ,p_field_value4                  in     varchar2 default null
44   ,p_field_name5                   in     varchar2 default null
45   ,p_field_value5                  in     varchar2 default null
46   ,p_field_name6                   in     varchar2 default null
47   ,p_field_value6                  in     varchar2 default null
48   ,p_field_name7                   in     varchar2 default null
49   ,p_field_value7                  in     varchar2 default null
50   ,p_field_name8                   in     varchar2 default null
51   ,p_field_value8                  in     varchar2 default null
52   ,p_field_name9                   in     varchar2 default null
53   ,p_field_value9                  in     varchar2 default null
54   ,p_integration_id                out    nocopy   number
55   ,p_object_version_number         out    nocopy   number
56   ) is
57   --
58   -- Declare cursors and local variables
59   --
60   l_proc                varchar2(72) := g_package||'create_integration';
61   l_integration_id      number;
62   l_language_code       varchar2(30);
63   l_object_version_number number;
64 
65 begin
66   hr_utility.set_location('Entering:'|| l_proc, 10);
67   --
68   -- Issue a savepoint
69   --
70   savepoint create_integration;
71   --
72   -- Remember IN OUT parameter IN values
73   --
74   --l_in_out_parameter := p_in_out_parameter;
75   l_language_code       := p_language_code;
76 
77   hr_api.validate_language_code(p_language_code => l_language_code);
78 
79   --
80   -- Call Before Process User Hook
81   --
82   begin
83     hr_ki_integrations_bk1.create_integration_b
84       (
85       p_language_code                 =>     l_language_code
86      ,p_integration_key               =>     p_integration_key
87      ,p_party_type                    =>     p_party_type
88      ,p_party_name                    =>     p_party_name
89      ,p_party_site_name               =>     p_party_site_name
90      ,p_transaction_type              =>     p_transaction_type
91      ,p_transaction_subtype           =>     p_transaction_subtype
92      ,p_standard_code                 =>     p_standard_code
93      ,p_ext_trans_type                =>     p_ext_trans_type
94      ,p_ext_trans_subtype             =>     p_ext_trans_subtype
95      ,p_trans_direction               =>     p_trans_direction
96      ,p_url                           =>     p_url
97      ,p_partner_name                  =>     p_partner_name
98      ,p_service_name                  =>     p_service_name
99      ,p_ext_application_id            =>     p_ext_application_id
100      ,p_application_name              =>     p_application_name
101      ,p_application_type              =>     p_application_type
102      ,p_application_url               =>     p_application_url
103      ,p_logout_url                    =>     p_logout_url
104      ,p_user_field                    =>     p_user_field
105      ,p_password_field                =>     p_password_field
106      ,p_authentication_needed         =>     p_authentication_needed
107      ,p_field_name1                   =>     p_field_name1
108      ,p_field_value1                  =>     p_field_value1
109      ,p_field_name2                   =>     p_field_name2
110      ,p_field_value2                  =>     p_field_value2
111      ,p_field_name3                   =>     p_field_name3
112      ,p_field_value3                  =>     p_field_value3
113      ,p_field_name4                   =>     p_field_name4
114      ,p_field_value4                  =>     p_field_value4
115      ,p_field_name5                   =>     p_field_name5
116      ,p_field_value5                  =>     p_field_value5
117      ,p_field_name6                   =>     p_field_name6
118      ,p_field_value6                  =>     p_field_value6
119      ,p_field_name7                   =>     p_field_name7
120      ,p_field_value7                  =>     p_field_value7
121      ,p_field_name8                   =>     p_field_name8
122      ,p_field_value8                  =>     p_field_value8
123      ,p_field_name9                   =>     p_field_name9
124      ,p_field_value9                  =>     p_field_value9
125       );
126   exception
127     when hr_api.cannot_find_prog_unit then
128       hr_api.cannot_find_prog_unit_error
129         (p_module_name => 'create_integration'
130         ,p_hook_type   => 'BP'
131         );
132   end;
133 
134   --
135   -- Process Logic
136   --
137 
138   hr_int_ins.ins
139      (
140       p_integration_key               =>     p_integration_key
141      ,p_party_type                    =>     p_party_type
142      ,p_party_name                    =>     p_party_name
143      ,p_party_site_name               =>     p_party_site_name
144      ,p_transaction_type              =>     p_transaction_type
145      ,p_transaction_subtype           =>     p_transaction_subtype
146      ,p_standard_code                 =>     p_standard_code
147      ,p_ext_trans_type                =>     p_ext_trans_type
148      ,p_ext_trans_subtype             =>     p_ext_trans_subtype
149      ,p_trans_direction               =>     p_trans_direction
150      ,p_url                           =>     p_url
151      ,p_ext_application_id            =>     p_ext_application_id
152      ,p_application_name              =>     p_application_name
153      ,p_application_type              =>     p_application_type
154      ,p_application_url               =>     p_application_url
155      ,p_logout_url                    =>     p_logout_url
156      ,p_user_field                    =>     p_user_field
157      ,p_password_field                =>     p_password_field
158      ,p_authentication_needed         =>     p_authentication_needed
159      ,p_field_name1                   =>     p_field_name1
160      ,p_field_value1                  =>     p_field_value1
161      ,p_field_name2                   =>     p_field_name2
162      ,p_field_value2                  =>     p_field_value2
163      ,p_field_name3                   =>     p_field_name3
164      ,p_field_value3                  =>     p_field_value3
165      ,p_field_name4                   =>     p_field_name4
166      ,p_field_value4                  =>     p_field_value4
167      ,p_field_name5                   =>     p_field_name5
168      ,p_field_value5                  =>     p_field_value5
169      ,p_field_name6                   =>     p_field_name6
170      ,p_field_value6                  =>     p_field_value6
171      ,p_field_name7                   =>     p_field_name7
172      ,p_field_value7                  =>     p_field_value7
173      ,p_field_name8                   =>     p_field_name8
174      ,p_field_value8                  =>     p_field_value8
175      ,p_field_name9                   =>     p_field_name9
176      ,p_field_value9                  =>     p_field_value9
177      ,p_integration_id                =>     l_integration_id
178      ,p_object_version_number         =>     l_object_version_number
179       );
180 
181 
182 
183   hr_itl_ins.ins_tl(
184        p_language_code            => l_language_code
185       ,p_integration_id           => l_integration_id
186       ,p_partner_name             => p_partner_name
187       ,p_service_name             => p_service_name
188       );
189 
190 
191   --
192   -- Call After Process User Hook
193   --
194   begin
195     hr_ki_integrations_bk1.create_integration_a
196       (
197       p_language_code                 =>     l_language_code
198      ,p_integration_key               =>     p_integration_key
199      ,p_party_type                    =>     p_party_type
200      ,p_party_name                    =>     p_party_name
201      ,p_party_site_name               =>     p_party_site_name
202      ,p_transaction_type              =>     p_transaction_type
203      ,p_transaction_subtype           =>     p_transaction_subtype
204      ,p_standard_code                 =>     p_standard_code
205      ,p_ext_trans_type                =>     p_ext_trans_type
206      ,p_ext_trans_subtype             =>     p_ext_trans_subtype
207      ,p_trans_direction               =>     p_trans_direction
208      ,p_url                           =>     p_url
209      ,p_partner_name                  =>     p_partner_name
210      ,p_service_name                  =>     p_service_name
211      ,p_application_name              =>     p_application_name
212      ,p_application_type              =>     p_application_type
213      ,p_application_url               =>     p_application_url
214      ,p_logout_url                    =>     p_logout_url
215      ,p_user_field                    =>     p_user_field
216      ,p_password_field                =>     p_password_field
217      ,p_authentication_needed         =>     p_authentication_needed
218      ,p_field_name1                   =>     p_field_name1
219      ,p_field_value1                  =>     p_field_value1
220      ,p_field_name2                   =>     p_field_name2
221      ,p_field_value2                  =>     p_field_value2
222      ,p_field_name3                   =>     p_field_name3
223      ,p_field_value3                  =>     p_field_value3
224      ,p_field_name4                   =>     p_field_name4
225      ,p_field_value4                  =>     p_field_value4
226      ,p_field_name5                   =>     p_field_name5
227      ,p_field_value5                  =>     p_field_value5
228      ,p_field_name6                   =>     p_field_name6
229      ,p_field_value6                  =>     p_field_value6
230      ,p_field_name7                   =>     p_field_name7
231      ,p_field_value7                  =>     p_field_value7
232      ,p_field_name8                   =>     p_field_name8
233      ,p_field_value8                  =>     p_field_value8
234      ,p_field_name9                   =>     p_field_name9
235      ,p_field_value9                  =>     p_field_value9
236      ,p_integration_id                =>     l_integration_id
237      ,p_ext_application_id            =>     p_ext_application_id
238      ,p_object_version_number         =>     l_object_version_number
239       );
240   exception
241     when hr_api.cannot_find_prog_unit then
242       hr_api.cannot_find_prog_unit_error
243         (p_module_name => 'create_integration'
244         ,p_hook_type   => 'AP'
245         );
246   end;
247   --
248   -- When in validation only mode raise the Validate_Enabled exception
249   --
250   if p_validate then
251     raise hr_api.validate_enabled;
252   end if;
253   --
254   -- Set all IN OUT and OUT parameters with out values
255   --
256   p_integration_id         := l_integration_id;
257   p_object_version_number  := l_object_version_number;
258 
259   --
260   hr_utility.set_location(' Leaving:'||l_proc, 70);
261 exception
262   when hr_api.validate_enabled then
263     --
264     -- As the Validate_Enabled exception has been raised
265     -- we must rollback to the savepoint
266     --
267     rollback to create_integration;
268     --
269     -- Reset IN OUT parameters and set OUT parameters
270     -- (Any key or derived arguments must be set to null
271     -- when validation only mode is being used.)
272     --
273 
274     p_integration_id         := null;
275     p_object_version_number  := null;
276 
277     hr_utility.set_location(' Leaving:'||l_proc, 80);
278   when others then
279     --
280     -- A validation or unexpected error has occured
281     --
282     rollback to create_integration;
283     --
284     -- Reset IN OUT parameters and set all
285     -- OUT parameters, including warnings, to null
286     --
287 
288     p_integration_id         := null;
289     p_object_version_number  := null;
290 
291     hr_utility.set_location(' Leaving:'||l_proc, 90);
292     raise;
293 end create_integration;
294 
295 
296 -- ----------------------------------------------------------------------------
297 -- |--------------------------< validate_integration >-------------------------|
298 -- ----------------------------------------------------------------------------
299 --
300 procedure validate_integration
301   (p_validate                      in     boolean  default false
302   ,p_integration_id                in     number
303   ,p_object_version_number         in out    nocopy   number
304   ) is
305   --
306   -- Declare cursors and local variables
307   --
308   l_proc                varchar2(72) := g_package||'validate_integration';
309   l_object_version_number number := p_object_version_number;
310 
311   cursor csr_ecx (cur_party_type in varchar2
312                   ,cur_party_name in varchar2
313                   ,cur_party_site_name in varchar2
314                   ,cur_transaction_type in varchar2
315                   ,cur_transaction_subtype in varchar2
316                   ,cur_standard_code in varchar2
317                   ,cur_ext_trans_type in varchar2
318                   ,cur_ext_trans_subtype in varchar2
319                   ,cur_trans_direction in varchar2
320                 )
321 
322   is
323          select null from ecx_tp_headers_v h,ecx_tp_details_v d
324           where h.tp_header_id=d.tp_header_id
325           and h.party_type=cur_party_type
326           and h.party_name=cur_party_name
327           and h.party_site_name=cur_party_site_name
328           and d.transaction_type=cur_transaction_type
329           and d.transaction_subtype=cur_transaction_subtype
330           and d.standard_code=cur_standard_code
331           and d.ext_type=cur_ext_trans_type
332           and d.ext_subtype=cur_ext_trans_subtype
333           and d.transaction_direction=cur_trans_direction;
334   l_key_ecx     varchar2(1) ;
335   cursor csr_name is
336          select
337                  SYNCHED
338                 ,PARTY_TYPE
339                 ,PARTY_NAME
340                 ,PARTY_SITE_NAME
341                 ,TRANSACTION_TYPE
342                 ,TRANSACTION_SUBTYPE
343                 ,STANDARD_CODE
344                 ,EXT_TRANS_TYPE
345                 ,EXT_TRANS_SUBTYPE
346                 ,TRANS_DIRECTION
347                 ,URL
348                 ,EXT_APPLICATION_ID
349                 ,APPLICATION_NAME
350                 ,APPLICATION_TYPE
351                 ,APPLICATION_URL
352                 ,LOGOUT_URL
353                 ,USER_FIELD
354                 ,PASSWORD_FIELD
355                 ,AUTHENTICATION_NEEDED
356                 ,FIELD_NAME1
357                 ,FIELD_VALUE1
358                 ,FIELD_NAME2
359                 ,FIELD_VALUE2
360                 ,FIELD_NAME3
361                 ,FIELD_VALUE3
362                 ,FIELD_NAME4
363                 ,FIELD_VALUE4
364                 ,FIELD_NAME5
365                 ,FIELD_VALUE5
366                 ,FIELD_NAME6
367                 ,FIELD_VALUE6
368                 ,FIELD_NAME7
369                 ,FIELD_VALUE7
370                 ,FIELD_NAME8
371                 ,FIELD_VALUE8
372                 ,FIELD_NAME9
373                 ,FIELD_VALUE9
374 
375            from hr_ki_integrations
376           where  integration_id = p_integration_id
377           and object_version_number = p_object_version_number;
378 
379    l_synched                       varchar2(1);
380    l_party_type                    varchar2(240);
381    l_party_name                    varchar2(360);
382    l_party_site_name               varchar2(904);
383    l_transaction_type              varchar2(100);
384    l_transaction_sub_type          varchar2(100);
385    l_standard_code                 varchar2(30);
386    l_ext_trans_type                varchar2(100);
387    l_ext_trans_sub_type            varchar2(100);
388    l_trans_direction               varchar2(20);
389    l_url                           varchar2(2000);
390    l_ext_application_id            number(15,0);
391    l_app_code                      varchar2(80);
392    l_apptype                       varchar2(80);
393    l_appurl                        varchar2(1000);
394    l_logout_url                    varchar2(1000);
395    l_userfld                       varchar2(80);
396    l_pwdfld                        varchar2(80);
397    l_authused                      varchar2(80);
398    l_fname1                        varchar2(80);
399    l_fval1                         varchar2(1000);
400    l_fname2                        varchar2(80);
401    l_fval2                         varchar2(1000);
402    l_fname3                        varchar2(80);
403    l_fval3                         varchar2(1000);
404    l_fname4                        varchar2(80);
405    l_fval4                         varchar2(1000);
406    l_fname5                        varchar2(80);
407    l_fval5                         varchar2(1000);
408    l_fname6                        varchar2(80);
409    l_fval6                         varchar2(1000);
410    l_fname7                        varchar2(80);
411    l_fval7                         varchar2(1000);
412    l_fname8                        varchar2(80);
413    l_fval8                         varchar2(1000);
414    l_fname9                        varchar2(80);
415    l_fval9                         varchar2(1000);
416 
417    lv_sqlcode NUMBER;
418    lv_sqlerrm VARCHAR2(240);
419 
420 begin
421   hr_utility.set_location('Entering:'|| l_proc, 10);
422   --
423   -- Issue a savepoint
424   --
425   savepoint validate_integration;
426   --
427   -- Remember IN OUT parameter IN values
428   --
429   --l_in_out_parameter := p_in_out_parameter;
430 
431 
432   --
433   -- Call Before Process User Hook
434   --
435   begin
436     hr_ki_integrations_bk4.validate_integration_b
437       (
438       p_integration_id                 =>     p_integration_id
439      ,p_object_version_number          =>     p_object_version_number
440       );
441   exception
442     when hr_api.cannot_find_prog_unit then
443       hr_api.cannot_find_prog_unit_error
444         (p_module_name => 'validate_integration'
445         ,p_hook_type   => 'BP'
446         );
447   end;
448 
449   --
450   -- Process Logic
451   --
452   hr_utility.set_location('Start:'|| l_proc, 20);
453   OPEN csr_name;
454   FETCH csr_name INTO l_synched,l_party_type,l_party_name,
455         l_party_site_name,l_transaction_type,l_transaction_sub_type,
456         l_standard_code,l_ext_trans_type,l_ext_trans_sub_type,
457         l_trans_direction,l_url,l_ext_application_id,l_app_code,
458         l_apptype,l_appurl,l_logout_url,l_userfld,l_pwdfld,l_authused,
459         l_fname1,l_fval1,l_fname2,l_fval2,l_fname3,l_fval3,l_fname4,l_fval4,
460         l_fname5,l_fval5,l_fname6,l_fval6,l_fname7,l_fval7,l_fname8,
461         l_fval8,l_fname9,l_fval9;
462   if (csr_name%notfound) then
463     CLOSE csr_name;
464      fnd_message.set_name('PER','PER_449991_INT_API_IOID_INVAL');
465      fnd_message.raise_error;
466   end if;
467   CLOSE csr_name;
468 
469   hr_utility.set_location('Check for p_synched:'|| l_proc, 30);
470   If l_synched='N' then
471        --Check if it is SSO with ext-application-id null
472        if (l_ext_application_id is null and l_app_code is not null
473         and l_apptype is not null and l_appurl is not null
474         and l_logout_url is not null and l_userfld is not null and
475         l_pwdfld  is not null and l_authused is not null) then
476 
477         hr_utility.set_location('Registering in SSO:'|| l_proc, 40);
478 
479         --Call register to create entry in SSO
480         begin
481 
482          hr_eap_ins.register(
483              p_app_code       =>  l_app_code
484             ,p_apptype        =>  l_apptype
485             ,p_appurl         =>  l_appurl
486             ,p_logout_url     =>  l_logout_url
487             ,p_userfld        =>  l_userfld
488             ,p_pwdfld         =>  l_pwdfld
489             ,p_authused       =>  l_authused
490             ,p_fname1         =>  l_fname1
491             ,p_fval1          =>  l_fval1
492             ,p_fname2         =>  l_fname2
493             ,p_fval2          =>  l_fval2
494             ,p_fname3         =>  l_fname3
495             ,p_fval3          =>  l_fval3
496             ,p_fname4         =>  l_fname4
497             ,p_fval4          =>  l_fval4
498             ,p_fname5         =>  l_fname5
499             ,p_fval5          =>  l_fval5
500             ,p_fname6         =>  l_fname6
501             ,p_fval6          =>  l_fval6
502             ,p_fname7         =>  l_fname7
503             ,p_fval7          =>  l_fval7
504             ,p_fname8         =>  l_fname8
505             ,p_fval8          =>  l_fval8
506             ,p_fname9         =>  l_fname9
507             ,p_fval9          =>  l_fval9
508             ,p_ki_app_id      =>  l_ext_application_id
509          );
510         exception
511         when others then
512           lv_sqlcode := SQLCODE;
513           lv_sqlerrm := SQLERRM;
514              IF (lv_sqlcode = -6550 and
515              instr(lv_sqlerrm,'WWSSO_PSTORE_EX.PSTORE_ADD_APPLICATION') > 0) THEN
516                  fnd_message.set_name('PER','PER_449993_INT_API_SSO_GRANT');
517                  fnd_message.raise_error;
518              else
519                  fnd_message.set_name('PER','PER_449994_INT_API_SSO_EX');
520                  fnd_message.raise_error;
521 
522             end if;
523         end;
524         --update integration table with synched set to Y
525         --and newly generated ext_application_id
526 
527         hr_utility.set_location('Updating integration:'|| l_proc, 50);
528           hr_int_upd.upd
529              (
530               p_synched                       =>     'Y'
531              ,p_ext_application_id            =>     l_ext_application_id
532              ,p_integration_id                =>     p_integration_id
533              ,p_object_version_number         =>     p_object_version_number
534              );
535 
536         --if ext_application_id is not null then synched should Y
537         --update_integration will be updating first SSO and then
538         --integration with SYNCHED set to Y
539 
540         elsif (
541         l_app_code is null
542         or l_apptype is null or l_appurl is null
543         or l_logout_url is null or l_userfld is null or
544         l_pwdfld  is null or l_authused is null
545 
546         ) then
547          --Throw Error
548          --
549 
550                  fnd_message.set_name('PER','PER_449989_INT_API_SSO_INVAL');
551                  fnd_message.raise_error;
552 
553         --This is case when SSO application is already created
554         --and SSO data is updated through loaders then synched will be N
555         --Call update_integration_api to synch integration table and sso schema
556         elsif(
557         l_ext_application_id is not null
558         and l_app_code is not null
559         and l_apptype is not null and l_appurl is not null
560         and l_logout_url is not null and l_userfld is not null and
561         l_pwdfld is not null and l_authused is not null
562         ) then
563 
564         HR_KI_INTEGRATIONS_API.update_integration
565         (
566          p_source_type                   => 'SSO'
567         ,p_target_type                   => 'SSO'
568         ,p_integration_id                =>  p_integration_id
569         ,p_application_name              =>  l_app_code
570         ,p_application_type              =>  l_apptype
571         ,p_application_url               =>  l_appurl
572         ,p_logout_url                    =>  l_logout_url
573         ,p_user_field                    =>  l_userfld
574         ,p_password_field                =>  l_pwdfld
575         ,p_authentication_needed         =>  l_authused
576         ,p_field_name1                   =>  l_fname1
577         ,p_field_value1                  =>  l_fval1
578         ,p_field_name2                   =>  l_fname2
579         ,p_field_value2                  =>  l_fval2
580         ,p_field_name3                   =>  l_fname3
581         ,p_field_value3                  =>  l_fval3
582         ,p_field_name4                   =>  l_fname4
583         ,p_field_value4                  =>  l_fval4
584         ,p_field_name5                   =>  l_fname5
585         ,p_field_value5                  =>  l_fval5
586         ,p_field_name6                   =>  l_fname6
587         ,p_field_value6                  =>  l_fval6
588         ,p_field_name7                   =>  l_fname7
589         ,p_field_value7                  =>  l_fval7
590         ,p_field_name8                   =>  l_fname8
591         ,p_field_value8                  =>  l_fval8
592         ,p_field_name9                   =>  l_fname9
593         ,p_field_value9                  =>  l_fval9
594         ,p_object_version_number         =>  p_object_version_number
595         );
596         --if it is ECX integration then validate against ECX schema
597 
598         elsif(l_party_type is not null and l_party_name is not null
599         and l_party_site_name is not null and l_transaction_type is not null
600         and l_transaction_sub_type is not null and l_standard_code is not null
601         and l_ext_trans_type is not null and l_ext_trans_sub_type is not null
602         and l_trans_direction is not null
603         ) then
604 
605             hr_utility.set_location('Validate against ECX:'|| l_proc, 60);
606 
607              open csr_ecx(l_party_type,l_party_name,l_party_site_name,
608              l_transaction_type,l_transaction_sub_type,l_standard_code,
609              l_ext_trans_type,l_ext_trans_sub_type,l_trans_direction
610              );
611              fetch csr_ecx into l_key_ecx;
612              if (csr_ecx%notfound)
613              then
614                close csr_ecx;
615                fnd_message.set_name('PER','PER_449992_INT_API_ECXDT_ABS');
616                fnd_message.raise_error;
617              else
618              --update integration table with synched set to Y
619 
620                 close csr_ecx;
621 
622                 hr_utility.set_location('ECX Update integrations:'|| l_proc, 70);
623 
624                 hr_int_upd.upd
625                 (
626                 p_synched                       =>     'Y'
627                ,p_integration_id                =>     p_integration_id
628                ,p_object_version_number         =>     p_object_version_number
629                 );
630              end if;
631 
632 
633         end if;
634 
635   end if;
636   hr_utility.set_location('Before after user hook:'|| l_proc, 80);
637 
638   --
639   -- Call After Process User Hook
640   --
641   begin
642     hr_ki_integrations_bk4.validate_integration_a
643       (
644       p_integration_id                =>     p_integration_id
645      ,p_ext_application_id            =>     l_ext_application_id
646      ,p_object_version_number         =>     p_object_version_number
647       );
648   exception
649     when hr_api.cannot_find_prog_unit then
650       hr_api.cannot_find_prog_unit_error
651         (p_module_name => 'validate_integration'
652         ,p_hook_type   => 'AP'
653         );
654   end;
655   --
656   -- When in validation only mode raise the Validate_Enabled exception
657   --
658   if p_validate then
659     raise hr_api.validate_enabled;
660   end if;
661   --
662   -- Set all IN OUT and OUT parameters with out values
663   --
664   -- p_object_version_number  := l_object_version_number;
665   --
666   hr_utility.set_location(' Leaving:'||l_proc, 90);
667 exception
668   when hr_api.validate_enabled then
669     --
670     -- As the Validate_Enabled exception has been raised
671     -- we must rollback to the savepoint
672     --
673     rollback to validate_integration;
674     --
675     -- Reset IN OUT parameters and set OUT parameters
676     -- (Any key or derived arguments must be set to null
677     -- when validation only mode is being used.)
678     --
679 
680     p_object_version_number  := l_object_version_number;
681 
682     hr_utility.set_location(' Leaving:'||l_proc, 100);
683   when others then
684     --
685     -- A validation or unexpected error has occured
686     --
687     rollback to validate_integration;
688     --
689     -- Reset IN OUT parameters and set all
690     -- OUT parameters, including warnings, to null
691     --
692 
693     p_object_version_number  := l_object_version_number;
694 
695     hr_utility.set_location(' Leaving:'||l_proc, 110);
696     raise;
697 end validate_integration;
698 --
699 --
700 -- ----------------------------------------------------------------------------
701 -- |--------------------------< UPDATE_INTEGRATION >--------------------------|
702 -- ----------------------------------------------------------------------------
703 
704 procedure UPDATE_INTEGRATION
705   (p_validate                      in     boolean  default false
706   ,p_language_code                 in     varchar2 default hr_api.userenv_lang
707   ,p_integration_id                in     number
708   ,p_source_type                   in     varchar2
709   ,p_target_type                   in     varchar2
710   ,p_party_type                    in     varchar2 default hr_api.g_varchar2
711   ,p_party_name                    in     varchar2 default hr_api.g_varchar2
712   ,p_party_site_name               in     varchar2 default hr_api.g_varchar2
713   ,p_transaction_type              in     varchar2 default hr_api.g_varchar2
714   ,p_transaction_subtype           in     varchar2 default hr_api.g_varchar2
715   ,p_standard_code                 in     varchar2 default hr_api.g_varchar2
716   ,p_ext_trans_type                in     varchar2 default hr_api.g_varchar2
717   ,p_ext_trans_subtype             in     varchar2 default hr_api.g_varchar2
718   ,p_trans_direction               in     varchar2 default hr_api.g_varchar2
719   ,p_url                           in     varchar2 default hr_api.g_varchar2
720   ,p_partner_name                  in     varchar2 default hr_api.g_varchar2
721   ,p_service_name                  in     varchar2 default hr_api.g_varchar2
722   ,p_application_name              in     varchar2 default hr_api.g_varchar2
723   ,p_application_type              in     varchar2 default hr_api.g_varchar2
724   ,p_application_url               in     varchar2 default hr_api.g_varchar2
725   ,p_logout_url                    in     varchar2 default hr_api.g_varchar2
726   ,p_user_field                    in     varchar2 default hr_api.g_varchar2
727   ,p_password_field                in     varchar2 default hr_api.g_varchar2
728   ,p_authentication_needed         in     varchar2 default hr_api.g_varchar2
729   ,p_field_name1                   in     varchar2 default hr_api.g_varchar2
730   ,p_field_value1                  in     varchar2 default hr_api.g_varchar2
731   ,p_field_name2                   in     varchar2 default hr_api.g_varchar2
732   ,p_field_value2                  in     varchar2 default hr_api.g_varchar2
733   ,p_field_name3                   in     varchar2 default hr_api.g_varchar2
734   ,p_field_value3                  in     varchar2 default hr_api.g_varchar2
735   ,p_field_name4                   in     varchar2 default hr_api.g_varchar2
736   ,p_field_value4                  in     varchar2 default hr_api.g_varchar2
737   ,p_field_name5                   in     varchar2 default hr_api.g_varchar2
738   ,p_field_value5                  in     varchar2 default hr_api.g_varchar2
739   ,p_field_name6                   in     varchar2 default hr_api.g_varchar2
740   ,p_field_value6                  in     varchar2 default hr_api.g_varchar2
741   ,p_field_name7                   in     varchar2 default hr_api.g_varchar2
742   ,p_field_value7                  in     varchar2 default hr_api.g_varchar2
743   ,p_field_name8                   in     varchar2 default hr_api.g_varchar2
744   ,p_field_value8                  in     varchar2 default hr_api.g_varchar2
745   ,p_field_name9                   in     varchar2 default hr_api.g_varchar2
746   ,p_field_value9                  in     varchar2 default hr_api.g_varchar2
747   ,p_object_version_number         in out nocopy   number
748 
749   ) is
750   --
751   -- Declare cursors and local variables
752   --
753   l_proc                varchar2(72) := g_package||'UPDATE_INTEGRATION';
754   l_language_code       varchar2(30);
755   l_object_version_number number := p_object_version_number;
756   lv_sqlcode NUMBER;
757   lv_sqlerrm VARCHAR2(240);
758 
759 
760   cursor csr_extid is
761      select inte.ext_application_id,ext.external_application_id
762      from
763      hr_ki_integrations inte,
764      hr_ki_ext_applications ext
765      where inte.integration_id=p_integration_id
766      and  inte.ext_application_id=ext.ext_application_id;
767 
768   cursor csr_getsso_info is
769      select  APPLICATION_NAME,APPLICATION_TYPE,APPLICATION_URL
770      ,LOGOUT_URL,USER_FIELD,PASSWORD_FIELD,AUTHENTICATION_NEEDED,
771      FIELD_NAME1,FIELD_VALUE1,FIELD_NAME2,FIELD_VALUE2,FIELD_NAME3,
772      FIELD_VALUE3,FIELD_NAME4,FIELD_VALUE4,FIELD_NAME5,FIELD_VALUE5,
773      FIELD_NAME6,FIELD_VALUE6,FIELD_NAME7,FIELD_VALUE7,FIELD_NAME8,
774      FIELD_VALUE8,FIELD_NAME9 ,FIELD_VALUE9
775      from
776      hr_ki_integrations
777      where integration_id=p_integration_id;
778 
779 
780   l_extid varchar2(80);
781   l_error number(15);
782   l_ext_application_id number(15) := null;
783   l_temp_ext_application_id number(15) := null;
784   l_synched varchar2(1);
785 
786   l_app_code   varchar2(80)   := p_application_name;
787   l_apptype    varchar2(80)   := p_application_type;
788   l_appurl     varchar2(1000) := p_application_url;
789   l_logout_url varchar2(1000) := p_logout_url;
790   l_userfld    varchar2(80)   := p_user_field;
791   l_pwdfld     varchar2(80)   := p_password_field;
792   l_authused   varchar2(80)   := p_authentication_needed;
793   l_fname1     varchar2(80)   := p_field_name1;
794   l_fval1      varchar2(100)  := p_field_value1;
795   l_fname2     varchar2(80)   := p_field_name2;
796   l_fval2      varchar2(100)  := p_field_value2;
797   l_fname3     varchar2(80)   := p_field_name3;
798   l_fval3      varchar2(100)  := p_field_value3;
799   l_fname4     varchar2(80)   := p_field_name4;
800   l_fval4      varchar2(100)  := p_field_value4;
801   l_fname5     varchar2(80)   := p_field_name5;
802   l_fval5      varchar2(100)  := p_field_value5;
803   l_fname6     varchar2(80)   := p_field_name6;
804   l_fval6      varchar2(100)  := p_field_value6;
805   l_fname7     varchar2(80)   := p_field_name7;
806   l_fval7      varchar2(100)  := p_field_value7;
807   l_fname8     varchar2(80)   := p_field_name8;
808   l_fval8      varchar2(100)  := p_field_value8;
809   l_fname9     varchar2(80)   := p_field_name9;
810   l_fval9      varchar2(100)  := p_field_value9;
811 
812   l_url        varchar2(2000) := p_url;
813 
814   l_party_type           varchar2(240) := p_party_type;
815   l_party_name           varchar2(360) := p_party_name;
816   l_party_site_name      varchar2(904) := p_party_site_name;
817   l_transaction_type     varchar2(100) := p_transaction_type;
818   l_transaction_sub_type varchar2(100) := p_transaction_subtype;
819   l_standard_code        varchar2(30)  := p_standard_code;
820   l_ext_trans_type       varchar2(100) := p_ext_trans_type;
821   l_ext_trans_sub_type   varchar2(100) := p_ext_trans_subtype;
822   l_trans_direction      varchar2(20)  := p_trans_direction;
823 
824 begin
825   hr_utility.set_location('Entering:'|| l_proc, 10);
826   --
827   -- Issue a savepoint
828   --
829   savepoint UPDATE_INTEGRATION;
830   --
831   -- Remember IN OUT parameter IN values
832   --
833   --l_in_out_parameter := p_in_out_parameter;
834   l_language_code:=p_language_code;
835 
836   hr_api.validate_language_code(p_language_code => l_language_code);
837 
838   --
839   -- Call Before Process User Hook
840   --
841   begin
842     hr_ki_integrations_bk2.UPDATE_INTEGRATION_b
843       (
844       p_language_code                 =>     l_language_code
845      ,p_source_type                   =>     p_source_type
846      ,p_target_type                   =>     p_target_type
847      ,p_party_type                    =>     p_party_type
848      ,p_party_name                    =>     p_party_name
849      ,p_party_site_name               =>     p_party_site_name
850      ,p_transaction_type              =>     p_transaction_type
851      ,p_transaction_subtype           =>     p_transaction_subtype
852      ,p_standard_code                 =>     p_standard_code
853      ,p_ext_trans_type                =>     p_ext_trans_type
854      ,p_ext_trans_subtype             =>     p_ext_trans_subtype
855      ,p_trans_direction               =>     p_trans_direction
856      ,p_url                           =>     p_url
857      ,p_partner_name                  =>     p_partner_name
858      ,p_service_name                  =>     p_service_name
859      ,p_application_name              =>     p_application_name
860      ,p_application_type              =>     p_application_type
861      ,p_application_url               =>     p_application_url
862      ,p_logout_url                    =>     p_logout_url
863      ,p_user_field                    =>     p_user_field
864      ,p_password_field                =>     p_password_field
865      ,p_authentication_needed         =>     p_authentication_needed
866      ,p_field_name1                   =>     p_field_name1
867      ,p_field_value1                  =>     p_field_value1
868      ,p_field_name2                   =>     p_field_name2
869      ,p_field_value2                  =>     p_field_value2
870      ,p_field_name3                   =>     p_field_name3
871      ,p_field_value3                  =>     p_field_value3
872      ,p_field_name4                   =>     p_field_name4
873      ,p_field_value4                  =>     p_field_value4
874      ,p_field_name5                   =>     p_field_name5
875      ,p_field_value5                  =>     p_field_value5
876      ,p_field_name6                   =>     p_field_name6
877      ,p_field_value6                  =>     p_field_value6
878      ,p_field_name7                   =>     p_field_name7
879      ,p_field_value7                  =>     p_field_value7
880      ,p_field_name8                   =>     p_field_name8
881      ,p_field_value8                  =>     p_field_value8
882      ,p_field_name9                   =>     p_field_name9
883      ,p_field_value9                  =>     p_field_value9
884      ,p_integration_id                =>     p_integration_id
885      ,p_object_version_number         =>     p_object_version_number
886       );
887   exception
888     when hr_api.cannot_find_prog_unit then
889       hr_api.cannot_find_prog_unit_error
890         (p_module_name => 'UPDATE_INTEGRATION'
891         ,p_hook_type   => 'BP'
892         );
893   end;
894   --
895   -- Process Logic
896   --
897   if ((p_source_type is null or p_source_type <> 'SSO' and
898   p_source_type <> 'URL' and p_source_type <> 'ECX')
899   or (p_target_type is null or p_target_type <> 'SSO'
900   and p_target_type <> 'URL' and p_target_type <> 'ECX')
901   ) then
902       fnd_message.set_name('PER','PER_449988_INT_API_STTT_INVL');
903       fnd_message.raise_error;
904   end if;
905   if (p_source_type = 'SSO') then
906     --make sure that ext_application_id is valid
907     --and it exists for the integration_id passed in
908     --hr_ki_integrations and hr_ki_ext_applications table
909     open csr_extid;
910     fetch csr_extid into l_ext_application_id,l_extid;
911     if (csr_extid%notfound) then
912       close csr_extid;
913       fnd_message.set_name('PER','PER_449990_INT_API_EXID_INVL');
914       fnd_message.raise_error;
915     end if;
916     close csr_extid;
917   end if;
918 
919   if (p_target_type = 'SSO') then
920 
921   --Target type will be SSO in 2 cases ,
922   --(1)For SSO to SSO:check if user enters null
923   --(2)and for (URL or ECX) to SSO he must enter mandatory SSO parameters
924 
925     if(p_source_type = 'SSO') then
926                 if (p_application_name    is null
927                      or p_application_type    is null
928                      or p_application_url     is null
929                      or p_logout_url is null
930                      or p_user_field    is null
931                      or p_password_field     is null
932                      or p_authentication_needed   is null )
933                      then
934                   fnd_message.set_name('PER','PER_0000_INT_API_SSO_INVAL');
935                   fnd_message.raise_error;
936             end if;
937 
938             --user is trying to update some of the SSO columns,he may not pass
939             --the columns which he does not want to update,get these columns from
940             --database otherwise we will  be passing g_varchar2 values to
941             --hr_sso_utl.PSTORE_MODIFY_APP_INFO procedure
942 
943 
944                  open csr_getsso_info;
945                  fetch csr_getsso_info into l_app_code,l_apptype,l_appurl,
946                  l_logout_url,l_userfld,l_pwdfld,l_authused,
947                  l_fname1,l_fval1,l_fname2,l_fval2,l_fname3,l_fval3,l_fname4,
948                  l_fval4,l_fname5,l_fval5,l_fname6,l_fval6,l_fname7,l_fval7,
949                  l_fname8,l_fval8,l_fname9,l_fval9;
950                  close csr_getsso_info;
951 
952                  if(p_application_name <> hr_api.g_varchar2) then l_app_code := p_application_name;end if;
953                  if(p_application_type <> hr_api.g_varchar2) then l_apptype := p_application_type;end if;
954                  if(p_application_url <> hr_api.g_varchar2) then l_appurl := p_application_url;end if;
955                  if(p_logout_url <> hr_api.g_varchar2) then l_logout_url := p_logout_url;end if;
956                  if(p_user_field <> hr_api.g_varchar2) then l_userfld := p_user_field;end if;
957                  if(p_password_field <> hr_api.g_varchar2) then l_pwdfld := p_password_field;end if;
958                  if(p_authentication_needed <> hr_api.g_varchar2) then l_authused := p_authentication_needed;end if;
959                  if(p_field_name1 <> hr_api.g_varchar2) then l_fname1 := p_field_name1;end if;
960                  if(p_field_value1 <> hr_api.g_varchar2) then l_fval1:=p_field_value1;end if;
961                  if(p_field_name2 <> hr_api.g_varchar2) then l_fname2:=p_field_name2;end if;
962                  if(p_field_value2 <> hr_api.g_varchar2) then l_fval2:=p_field_value2;end if;
963                  if(p_field_name3 <> hr_api.g_varchar2) then l_fname3:=p_field_name3;end if;
964                  if(p_field_value3 <> hr_api.g_varchar2) then l_fval3:=p_field_value3;end if;
965                  if(p_field_name4 <> hr_api.g_varchar2) then l_fname4:=p_field_name4;end if;
966                  if(p_field_value4 <> hr_api.g_varchar2) then l_fval4:=p_field_value4;end if;
967                  if(p_field_name5 <> hr_api.g_varchar2) then l_fname5:=p_field_name5;end if;
968                  if(p_field_value5 <> hr_api.g_varchar2) then l_fval5:=p_field_value5;end if;
969                  if(p_field_name6 <> hr_api.g_varchar2) then l_fname6:=p_field_name6;end if;
970                  if(p_field_value6 <> hr_api.g_varchar2) then l_fval6:=p_field_value6;end if;
971                  if(p_field_name7 <> hr_api.g_varchar2) then l_fname7:=p_field_name7;end if;
972                  if(p_field_value7 <> hr_api.g_varchar2) then l_fval7:=p_field_value7;end if;
973                  if(p_field_name8 <> hr_api.g_varchar2) then l_fname8:=p_field_name8;end if;
974                  if(p_field_value8 <> hr_api.g_varchar2) then l_fval8:=p_field_value8;end if;
975                  if(p_field_name9 <> hr_api.g_varchar2) then l_fname9:=p_field_name9;end if;
976                  if(p_field_value9 <> hr_api.g_varchar2) then l_fval9:=p_field_value9;end if;
977 
978     else
979             if (p_application_name    is null or p_application_name =hr_api.g_varchar2
980                  or p_application_type    is null or p_application_type =hr_api.g_varchar2
981                  or p_application_url     is null or p_application_url =hr_api.g_varchar2
982                  or p_logout_url is null or p_logout_url =hr_api.g_varchar2
983                  or p_user_field    is null or p_user_field =hr_api.g_varchar2
984                  or p_password_field     is null or p_password_field =hr_api.g_varchar2
985                  or p_authentication_needed   is null or p_authentication_needed =hr_api.g_varchar2
986                  ) then
987               fnd_message.set_name('PER','PER_0000_INT_API_SSO_INVAL');
988               fnd_message.raise_error;
989             end if;
990     end if;
991   end if;
992   if (p_source_type = p_target_type and p_source_type = 'SSO')then
993     hr_eap_upd.update_sso_details(
994                  p_ext_application_id =>  l_ext_application_id
995                 ,p_app_code           =>  l_app_code
996                 ,p_apptype            =>  l_apptype
997                 ,p_appurl             =>  l_appurl
998                 ,p_logout_url         =>  l_logout_url
999                 ,p_userfld            =>  l_userfld
1000                 ,p_pwdfld             =>  l_pwdfld
1001                 ,p_authused           =>  l_authused
1002                 ,p_fname1             =>  l_fname1
1003                 ,p_fval1              =>  l_fval1
1004                 ,p_fname2             =>  l_fname2
1005                 ,p_fval2              =>  l_fval2
1006                 ,p_fname3             =>  l_fname3
1007                 ,p_fval3              =>  l_fval3
1008                 ,p_fname4             =>  l_fname4
1009                 ,p_fval4              =>  l_fval4
1010                 ,p_fname5             =>  l_fname5
1011                 ,p_fval5              =>  l_fval5
1012                 ,p_fname6             =>  l_fname6
1013                 ,p_fval6              =>  l_fval6
1014                 ,p_fname7             =>  l_fname7
1015                 ,p_fval7              =>  l_fval7
1016                 ,p_fname8             =>  l_fname8
1017                 ,p_fval8              =>  l_fval8
1018                 ,p_fname9             =>  l_fname9
1019                 ,p_fval9              =>  l_fval9);
1020 
1021   elsif (p_source_type = 'SSO') then
1022 
1023     --SSO to URL or SSO to ECX type
1024 
1025     --delete the application from SSO and then
1026     -- from hr_ki_ext_applications
1027 
1028     hr_eap_del.delete_sso_details(p_sso_id => l_extid);
1029 
1030 
1031   elsif (p_target_type = 'SSO') then
1032 
1033   --set all the default SSO values to null
1034   --otherwise they will be updated by hr_api.g_varchar2
1035     if (l_fname1 =hr_api.g_varchar2) then l_fname1:=null; end if;
1036     if (l_fval1  =hr_api.g_varchar2) then l_fval1 :=null; end if;
1037     if (l_fname2 =hr_api.g_varchar2) then l_fname2:=null; end if;
1038     if (l_fval2  =hr_api.g_varchar2) then l_fval2 :=null; end if;
1039     if (l_fname3 =hr_api.g_varchar2) then l_fname3:=null; end if;
1040     if (l_fval3  =hr_api.g_varchar2) then l_fval3 :=null; end if;
1041     if (l_fname4 =hr_api.g_varchar2) then l_fname4:=null; end if;
1042     if (l_fval4  =hr_api.g_varchar2) then l_fval4 :=null; end if;
1043     if (l_fname5 =hr_api.g_varchar2) then l_fname5:=null; end if;
1044     if (l_fval5  =hr_api.g_varchar2) then l_fval5 :=null; end if;
1045     if (l_fname6 =hr_api.g_varchar2) then l_fname6:=null; end if;
1046     if (l_fval6  =hr_api.g_varchar2) then l_fval6 :=null; end if;
1047     if (l_fname7 =hr_api.g_varchar2) then l_fname7:=null; end if;
1048     if (l_fval7  =hr_api.g_varchar2) then l_fval7 :=null; end if;
1049     if (l_fname8 =hr_api.g_varchar2) then l_fname8:=null; end if;
1050     if (l_fval8  =hr_api.g_varchar2) then l_fval8 :=null; end if;
1051     if (l_fname9 =hr_api.g_varchar2) then l_fname9:=null; end if;
1052     if (l_fval9  =hr_api.g_varchar2) then l_fval9 :=null; end if;
1053     begin
1054     hr_eap_ins.register(
1055                   p_app_code       =>  p_application_name
1056                  ,p_apptype        =>  p_application_type
1057                  ,p_appurl         =>  p_application_url
1058                  ,p_logout_url     =>  p_logout_url
1059                  ,p_userfld        =>  p_user_field
1060                  ,p_pwdfld         =>  p_password_field
1061                  ,p_authused       =>  p_authentication_needed
1062                  ,p_fname1         =>  l_fname1
1063                  ,p_fval1          =>  l_fval1
1064                  ,p_fname2         =>  l_fname2
1065                  ,p_fval2          =>  l_fval2
1066                  ,p_fname3         =>  l_fname3
1067                  ,p_fval3          =>  l_fval3
1068                  ,p_fname4         =>  l_fname4
1069                  ,p_fval4          =>  l_fval4
1070                  ,p_fname5         =>  l_fname5
1071                  ,p_fval5          =>  l_fval5
1072                  ,p_fname6         =>  l_fname6
1073                  ,p_fval6          =>  l_fval6
1074                  ,p_fname7         =>  l_fname7
1075                  ,p_fval7          =>  l_fval7
1076                  ,p_fname8         =>  l_fname8
1077                  ,p_fval8          =>  l_fval8
1078                  ,p_fname9         =>  l_fname9
1079                  ,p_fval9          =>  l_fval9
1080                  ,p_ki_app_id      =>  l_temp_ext_application_id);
1081 
1082     l_ext_application_id := l_temp_ext_application_id;
1083         exception
1084         when others then
1085           lv_sqlcode := SQLCODE;
1086           lv_sqlerrm := SQLERRM;
1087              IF (lv_sqlcode = -6550 and
1088              instr(lv_sqlerrm,'WWSSO_PSTORE_EX.PSTORE_ADD_APPLICATION') > 0) THEN
1089                  fnd_message.set_name('PER','PER_0000_INT_API_SSO_GRANT');
1090                  fnd_message.raise_error;
1091              else
1092                  fnd_message.set_name('PER','PER_0000_INT_API_SSO_EX');
1093                  fnd_message.raise_error;
1094 
1095             end if;
1096         end;
1097 
1098   end if;
1099 
1100   --Set all the other type of integration parameters to null
1101   --For ECX (URL and SSO null)
1102   --For URL (ECX and SSO null)
1103   --For SSO (URL and ECX null)
1104   if (p_target_type <> 'URL') then
1105     l_url := null;
1106   end if;
1107   if(p_target_type <> 'ECX')then
1108     l_party_type           := null;
1109     l_party_name           := null;
1110     l_party_site_name      := null;
1111     l_transaction_type     := null;
1112     l_transaction_sub_type := null;
1113     l_standard_code        := null;
1114     l_ext_trans_type       := null;
1115     l_ext_trans_sub_type   := null;
1116     l_trans_direction      := null;
1117   end if;
1118   if(p_target_type <> 'SSO')then
1119     l_ext_application_id := null;
1120     l_app_code   := null;
1121     l_apptype    := null;
1122     l_appurl     := null;
1123     l_logout_url := null;
1124     l_userfld    := null;
1125     l_pwdfld     := null;
1126     l_authused   := null;
1127     l_fname1     := null;
1128     l_fval1      := null;
1129     l_fname2     := null;
1130     l_fval2      := null;
1131     l_fname3     := null;
1132     l_fval3      := null;
1133     l_fname4     := null;
1134     l_fval4      := null;
1135     l_fname5     := null;
1136     l_fval5      := null;
1137     l_fname6     := null;
1138     l_fval6      := null;
1139     l_fname7     := null;
1140     l_fval7      := null;
1141     l_fname8     := null;
1142     l_fval8      := null;
1143     l_fname9     := null;
1144     l_fval9      := null;
1145   end if;
1146 
1147 --Set the l_synched parameter.
1148 
1149   if (p_target_type = 'ECX') then
1150     l_synched := 'N';
1151   else
1152     l_synched := 'Y';
1153   end if;
1154 --
1155 -- update the integration table
1156 --
1157 
1158   hr_int_upd.upd
1159      (
1160       p_integration_id                =>     p_integration_id
1161      ,p_ext_application_id            =>     l_ext_application_id
1162      ,p_synched                       =>     l_synched
1163      ,p_party_type                    =>     l_party_type
1164      ,p_party_name                    =>     l_party_name
1165      ,p_party_site_name               =>     l_party_site_name
1166      ,p_transaction_type              =>     l_transaction_type
1167      ,p_transaction_subtype           =>     l_transaction_sub_type
1168      ,p_standard_code                 =>     l_standard_code
1169      ,p_ext_trans_type                =>     l_ext_trans_type
1170      ,p_ext_trans_subtype             =>     l_ext_trans_sub_type
1171      ,p_trans_direction               =>     l_trans_direction
1172 
1173      ,p_url                           =>     l_url
1174 
1175      ,p_application_name              =>     l_app_code
1176      ,p_application_type              =>     l_apptype
1177      ,p_application_url               =>     l_appurl
1178      ,p_logout_url                    =>     l_logout_url
1179      ,p_user_field                    =>     l_userfld
1180      ,p_password_field                =>     l_pwdfld
1181      ,p_authentication_needed         =>     l_authused
1182 
1183      ,p_field_name1                   =>     l_fname1
1184      ,p_field_value1                  =>     l_fval1
1185      ,p_field_name2                   =>     l_fname2
1186      ,p_field_value2                  =>     l_fval2
1187      ,p_field_name3                   =>     l_fname3
1188      ,p_field_value3                  =>     l_fval3
1189      ,p_field_name4                   =>     l_fname4
1190      ,p_field_value4                  =>     l_fval4
1191      ,p_field_name5                   =>     l_fname5
1192      ,p_field_value5                  =>     l_fval5
1193      ,p_field_name6                   =>     l_fname6
1194      ,p_field_value6                  =>     l_fval6
1195      ,p_field_name7                   =>     l_fname7
1196      ,p_field_value7                  =>     l_fval7
1197      ,p_field_name8                   =>     l_fname8
1198      ,p_field_value8                  =>     l_fval8
1199      ,p_field_name9                   =>     l_fname9
1200      ,p_field_value9                  =>     l_fval9
1201 
1202      ,p_object_version_number         =>     p_object_version_number
1203       );
1204 --
1205 -- update the integration_tl table
1206 --
1207   hr_itl_upd.upd_tl(
1208        p_language_code           =>  l_language_code
1209       ,p_integration_id          =>  p_integration_id
1210       ,p_partner_name            =>  p_partner_name
1211       ,p_service_name            =>  p_service_name
1212       );
1213   --
1214   -- Call After Process User Hook
1215   --
1216   begin
1217     hr_ki_integrations_bk2.update_integration_a
1218       (
1219       p_language_code                 =>     l_language_code
1220      ,p_source_type                   =>     p_source_type
1221      ,p_target_type                   =>     p_target_type
1222      ,p_party_type                    =>     p_party_type
1223      ,p_party_name                    =>     p_party_name
1224      ,p_party_site_name               =>     p_party_site_name
1225      ,p_transaction_type              =>     p_transaction_type
1226      ,p_transaction_subtype           =>     p_transaction_subtype
1227      ,p_standard_code                 =>     p_standard_code
1228      ,p_ext_trans_type                =>     p_ext_trans_type
1229      ,p_ext_trans_subtype             =>     p_ext_trans_subtype
1230      ,p_trans_direction               =>     p_trans_direction
1231      ,p_url                           =>     p_url
1232      ,p_partner_name                  =>     p_partner_name
1233      ,p_service_name                  =>     p_service_name
1234      ,p_application_name              =>     p_application_name
1235      ,p_application_type              =>     p_application_type
1236      ,p_application_url               =>     p_application_url
1237      ,p_logout_url                    =>     p_logout_url
1238      ,p_user_field                    =>     p_user_field
1239      ,p_password_field                =>     p_password_field
1240      ,p_authentication_needed         =>     p_authentication_needed
1241      ,p_field_name1                   =>     p_field_name1
1242      ,p_field_value1                  =>     p_field_value1
1243      ,p_field_name2                   =>     p_field_name2
1244      ,p_field_value2                  =>     p_field_value2
1245      ,p_field_name3                   =>     p_field_name3
1246      ,p_field_value3                  =>     p_field_value3
1247      ,p_field_name4                   =>     p_field_name4
1248      ,p_field_value4                  =>     p_field_value4
1249      ,p_field_name5                   =>     p_field_name5
1250      ,p_field_value5                  =>     p_field_value5
1251      ,p_field_name6                   =>     p_field_name6
1252      ,p_field_value6                  =>     p_field_value6
1253      ,p_field_name7                   =>     p_field_name7
1254      ,p_field_value7                  =>     p_field_value7
1255      ,p_field_name8                   =>     p_field_name8
1256      ,p_field_value8                  =>     p_field_value8
1257      ,p_field_name9                   =>     p_field_name9
1258      ,p_field_value9                  =>     p_field_value9
1259      ,p_integration_id                =>     p_integration_id
1260      ,p_ext_application_id            =>     l_ext_application_id
1261      ,p_object_version_number         =>     p_object_version_number
1262       );
1263   exception
1264     when hr_api.cannot_find_prog_unit then
1265       hr_api.cannot_find_prog_unit_error
1266         (p_module_name => 'UPDATE_INTEGRATION'
1267         ,p_hook_type   => 'AP'
1268         );
1269   end;
1270   --
1271   -- When in validation only mode raise the Validate_Enabled exception
1272   --
1273   if p_validate then
1274     raise hr_api.validate_enabled;
1275   end if;
1276   --
1277   -- Set all IN OUT and OUT parameters with out values
1278   --
1279 
1280   --  p_object_version_number  := p_object_version_number;
1281 
1282 
1283   --
1284   hr_utility.set_location(' Leaving:'||l_proc, 70);
1285 exception
1286   when hr_api.validate_enabled then
1287     --
1288     -- As the Validate_Enabled exception has been raised
1289     -- we must rollback to the savepoint
1290     --
1291     rollback to UPDATE_INTEGRATION;
1292     --
1293     -- Reset IN OUT parameters and set OUT parameters
1294     -- (Any key or derived arguments must be set to null
1295     -- when validation only mode is being used.)
1296     --
1297 
1298     p_object_version_number  := l_object_version_number;
1299 
1300     hr_utility.set_location(' Leaving:'||l_proc, 80);
1301   when others then
1302     --
1303     -- A validation or unexpected error has occured
1304     --
1305     rollback to UPDATE_INTEGRATION;
1306     --
1307     -- Reset IN OUT parameters and set all
1308     -- OUT parameters, including warnings, to null
1309     --
1310 
1311     p_object_version_number  := l_object_version_number;
1312 
1313     hr_utility.set_location(' Leaving:'||l_proc, 90);
1314     raise;
1315 end UPDATE_INTEGRATION;
1316 --
1317 --
1318 -- ----------------------------------------------------------------------------
1319 -- |--------------------------< DELETE_INTEGRATION >--------------------------|
1320 -- ----------------------------------------------------------------------------
1321 --
1322 procedure delete_integration
1323   (
1324    P_VALIDATE                 in boolean         default false
1325   ,P_SSO_ENABLED              in boolean         default false
1326   ,P_INTEGRATION_ID           in number
1327   ,P_OBJECT_VERSION_NUMBER    in number
1328   ) is
1329   --
1330   -- Declare cursors and local variables
1331   --
1332   l_proc                varchar2(72) := g_package||'delete_integration';
1333   cursor csr_extid is
1334      select ext.external_application_id,ext.ext_application_id from
1335       hr_ki_integrations inte,
1336       hr_ki_ext_applications ext
1337       where inte.integration_id=p_integration_id
1338       and  inte.ext_application_id=ext.ext_application_id;
1339 
1340   l_extid varchar2(80);
1341   l_error number(15);
1342   l_eap_id number(15);
1343 
1344 begin
1345   hr_utility.set_location('Entering:'|| l_proc, 10);
1346   --
1347   -- Issue a savepoint
1348   --
1349   savepoint delete_integration;
1350   --
1351   -- Remember IN OUT parameter IN values
1352   --
1353 
1354   -- Call Before Process User Hook
1355   --
1356   begin
1357     hr_ki_integrations_bk3.delete_integration_b
1358       (
1359        p_sso_enabled            => p_sso_enabled
1360       ,p_integration_id         => p_integration_id
1361       ,p_object_version_number  => p_object_version_number
1362 
1363       );
1364   exception
1365     when hr_api.cannot_find_prog_unit then
1366       hr_api.cannot_find_prog_unit_error
1367         (p_module_name => 'delete_integration'
1368         ,p_hook_type   => 'BP'
1369         );
1370   end;
1371 
1372   --
1373   -- Process Logic
1374   --
1375 
1376   if (p_sso_enabled) then
1377      --delete the sso application first
1378       open csr_extid;
1379       fetch csr_extid into l_extid,l_eap_id;
1380       if (csr_extid%notfound) then
1381          close csr_extid;
1382          fnd_message.set_name('PER','PER_0000_INT_API_EXID_INVL');
1383          fnd_message.raise_error;
1384       end if;
1385       close csr_extid;
1386 
1387     --delete the application from SSO and then
1388     -- from hr_ki_ext_applications
1389 
1390     hr_eap_del.delete_sso_details(p_sso_id => l_extid);
1391 
1392   end if;
1393 
1394 
1395  --delete record from TL table
1396  hr_int_shd.lck
1397       (
1398       p_integration_id          => p_integration_id
1399      ,p_object_version_number   => p_object_version_number
1400      );
1401 
1402  hr_itl_del.del_tl(
1403       p_integration_id          => p_integration_id
1404       );
1405 
1406 
1407  hr_int_del.del
1408      (
1409       p_integration_id          => p_integration_id
1410      ,p_object_version_number   => p_object_version_number
1411       );
1412   --
1413   -- Call After Process User Hook
1414   --
1415   begin
1416     hr_ki_integrations_bk3.delete_integration_a
1417       (
1418        p_sso_enabled            => p_sso_enabled
1419       ,p_integration_id         => p_integration_id
1420       ,p_object_version_number  => p_object_version_number
1421       );
1422   exception
1423     when hr_api.cannot_find_prog_unit then
1424       hr_api.cannot_find_prog_unit_error
1425         (p_module_name => 'delete_integration'
1426         ,p_hook_type   => 'AP'
1427         );
1428   end;
1429   --
1430   -- When in validation only mode raise the Validate_Enabled exception
1431   --
1432   if p_validate then
1433     raise hr_api.validate_enabled;
1434   end if;
1435   --
1436   -- Set all IN OUT and OUT parameters with out values
1437   --
1438 
1439   --
1440   hr_utility.set_location(' Leaving:'||l_proc, 70);
1441 exception
1442   when hr_api.validate_enabled then
1443     --
1444     -- As the Validate_Enabled exception has been raised
1445     -- we must rollback to the savepoint
1446     --
1447     rollback to delete_integration;
1448     --
1449     -- Reset IN OUT parameters and set OUT parameters
1450     -- (Any key or derived arguments must be set to null
1451     -- when validation only mode is being used.)
1452     --
1453 
1454     hr_utility.set_location(' Leaving:'||l_proc, 80);
1455   when others then
1456     --
1457     -- A validation or unexpected error has occured
1458     --
1459     rollback to delete_integration;
1460     --
1461     -- Reset IN OUT parameters and set all
1462     -- OUT parameters, including warnings, to null
1463     --
1464     hr_utility.set_location(' Leaving:'||l_proc, 90);
1465     raise;
1466 end delete_integration;
1467 end HR_KI_INTEGRATIONS_API;