DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_WPM_IMPORT_LIB_OBJ_API

Source


1 PACKAGE BODY HR_WPM_IMPORT_LIB_OBJ_API as
2 /* $Header: perioapi.pkb 120.8 2006/05/02 23:51:23 sturlapa noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := 'HR_WPM_IMPORT_LIB_OBJ_API.';
7 g_debug    boolean      := hr_utility.debug_enabled;
8 --
9 -- ----------------------------------------------------------------------------
10 -- |-----------------------< import_library_objective >-----------------------|
11 -- ----------------------------------------------------------------------------
12 -- {Start Of Comments}
13 --
14 -- Description:
15 --
16 --
17 -- Prerequisites:
18 --
19 --
20 -- In Parameters:
21 --   Name                           Reqd Type     Description
22 --
23 --
24 -- Post Success:
25 --
26 --
27 --   Name                           Type     Description
28 --
29 -- Post Failure:
30 --
31 --
32 -- Access Status:
33 --   Public.
34 --
35 -- {End Of Comments}
36 --
37 procedure IMPORT_LIBRARY_OBJECTIVES
38   (
39    p_objective_name	           in	varchar2
40   ,p_valid_from		           in	date	    	default null
41   ,p_valid_to	                   in	date	    	default null
42   ,p_target_date	           in	date	    	default null
43   ,p_next_review_date	           in	date	    	default null
44   ,p_group_code	         	   in	varchar2  	default null
45   ,p_priority_code		   in	varchar2  	default null
46   ,p_appraise_flag	           in	varchar2  	default 'Y'
47   ,p_weighting_percent	           in	number          default null
48   ,p_measurement_style_code	   in	varchar2        default 'N_M'
49   ,p_measure_name	           in	varchar2        default null
50   ,p_measure_comments		   in	varchar2	default null
51   ,p_target_value                  in   number          default null
52   ,p_uom_code			   in	varchar2	default null
53   ,p_measure_type_code		   in	varchar2	default null
54   ,p_eligibility_type_code	   in	varchar2        default 'N_P'
55   ,p_eligibility_profile_code	   in	number          default null
56   ,p_details			   in	varchar2	default null
57   ,p_success_criteria		   in	varchar2	default null
58   ,p_comments			   in	varchar2	default null
59   ,p_attribute_category		   in	varchar2	default null
60   ,p_attribute1			   in	varchar2	default null
61   ,p_attribute2			   in	varchar2	default null
62   ,p_attribute3			   in	varchar2	default null
63   ,p_attribute4			   in	varchar2	default null
64   ,p_attribute5			   in	varchar2	default null
65   ,p_attribute6			   in	varchar2	default null
66   ,p_attribute7			   in	varchar2	default null
67   ,p_attribute8			   in	varchar2	default null
68   ,p_attribute9			   in	varchar2	default null
69   ,p_attribute10		   in	varchar2	default null
70   ,p_attribute11		   in	varchar2	default null
71   ,p_attribute12		   in	varchar2	default null
72   ,p_attribute13		   in	varchar2	default null
73   ,p_attribute14		   in	varchar2	default null
74   ,p_attribute15		   in	varchar2	default null
75   ,p_attribute16		   in	varchar2	default null
76   ,p_attribute17		   in	varchar2	default null
77   ,p_attribute18		   in	varchar2	default null
78   ,p_attribute19	 	   in	varchar2	default null
79   ,p_attribute20		   in	varchar2	default null
80   ,p_attribute21		   in	varchar2	default null
81   ,p_attribute22		   in	varchar2	default null
82   ,p_attribute23		   in	varchar2	default null
83   ,p_attribute24		   in	varchar2	default null
84   ,p_attribute25		   in	varchar2	default null
85   ,p_attribute26		   in	varchar2	default null
86   ,p_attribute27		   in	varchar2	default null
87   ,p_attribute28		   in	varchar2	default null
88   ,p_attribute29		   in	varchar2	default null
89   ,p_attribute30		   in	varchar2	default null
90   ,p_return_message        out nocopy varchar2
91   ) IS
92   l_proc varchar2(50):= 'IMPORT_LIBRARY_OBJECTIVES';
93 
94   l_duplicate_name_warning boolean;
95   l_weighting_over_100_warning boolean;
96   l_weighting_appraisal_warning boolean;
97 
98   l_table_name varchar2(30):='PER_OBJECTIVES_LIBRARY';
99   l_column_name varchar2(30):='OBJECTIVE_ID';
100 
101   l_validate boolean;
102   l_effective_date date;
103   l_objective_id number;
104   l_elig_obj_id number;
105   l_elig_obj_elig_prfl_id number;
106   l_bg_id number;
107 
108   l_eligibility_type_code varchar2(10);
109   l_measurement_style_code varchar2(10);
110   l_appraise_flag varchar2(2);
111 
112   l_object_version_number number;
113   l_start_date date;
114   l_end_date date;
115 
116   p_return_status  varchar2(400);
117   is_profile_exists varchar2(1);
118   l_elig_prfl_bg_id number(30);
119 
120   cursor  bg_cur(cur_p_org_id number) is select BUSINESS_GROUP_ID into l_bg_id from hr_organization_units where ORGANIZATION_ID=cur_p_org_id;
121 
122   cursor csr_name(cur_p_eligy_prfl_id number,cur_p_effective_date date) is
123     select 'Y',BUSINESS_GROUP_ID
124     from   ben_eligy_prfl_f
125     where  eligy_prfl_id = cur_p_eligy_prfl_id
126     and    cur_p_effective_date <= nvl(effective_end_date,to_date('31-12-4712','DD-MM-YYYY'))
127     and    cur_p_effective_date >= effective_start_date
128     and    stat_cd='A' ;
129 
130   begin
131     savepoint import_library_objective_api;
132 
133     l_effective_date:=trunc(sysdate);
134     l_validate:=false;
135 
136 
137 
138     --setting the eligibility type code
139     if(p_eligibility_type_code IS Null  Or nvl(length(trim(p_eligibility_type_code)),-1)=-1)then
140             l_eligibility_type_code:='N_P';
141     else
142             l_eligibility_type_code:=TRIM(p_eligibility_type_code);
143     end if;
144 
145     --setting the appraisal flag
146     if(p_appraise_flag IS Null Or nvl(length(trim(p_appraise_flag)),-1)=-1)then
147             l_appraise_flag:='N';
148     else
149             l_appraise_flag:=TRIM(p_appraise_flag);
150     end if;
151 
152     --setting the mesurement style code
153     if(p_measurement_style_code IS Null Or nvl(length(trim(p_measurement_style_code)),-1)=-1 )then
154         l_measurement_style_code:='N_M';
155     else
156         l_measurement_style_code:=TRIM(p_measurement_style_code);
157     end if;
158 
159     --checkining the mesurement style code
160     if(l_measurement_style_code = 'N_M' And (
161 						nvl(length(trim(p_measure_name)),-1)<>-1 Or
162 						nvl(length(trim(p_target_value)),-1)<>-1 Or
163 						nvl(length(trim(p_uom_code)),-1)<>-1 Or
164 						nvl(length(trim(p_measure_type_code)),-1)<>-1 Or
165 						nvl(length(trim(p_measure_comments)),-1)<>-1 ))
166     then
167           fnd_message.set_name('PER', 'HR_51746_WPM_IMP_NO_MTYPE');
168           fnd_message.raise_error;
169     end if;
170 
171     if(l_measurement_style_code ='QUALIT_M') then
172 
173 	 if nvl(length(trim(p_measure_name)),-1) = -1 then
174     	   fnd_message.set_name('PER', 'HR_51744_WPM_IMP_QUAL_TYPE');
175            fnd_message.raise_error;
176     	 end if;
177 
178  	 if( nvl(length(trim(p_target_value)),-1) <> -1 Or
179 	     nvl(length(trim(p_uom_code)),-1) <> -1 Or
180 	     nvl(length(trim(p_measure_type_code)),-1) <> -1 ) then
181     	   fnd_message.set_name('PER', 'HR_51747_WPM_IMP_INVAL_QUAL');
182            fnd_message.raise_error;
183     	 end if;
184 
185     end if;
186 
187    if(l_measurement_style_code ='QUANT_M') then
188         if(nvl(length(trim(p_measure_name)),-1) = -1 Or nvl(length(trim(p_target_value)),-1) = -1  Or
189 	   nvl(length(trim(p_uom_code)),-1) = -1  Or nvl(length(trim(p_measure_type_code)),-1) = -1 ) then
190        	   fnd_message.set_name('PER', 'HR_51745_WPM_IMP_QUAN_TYPE');
191            fnd_message.raise_error;
192        end if;
193    end if;
194 
195    if(l_eligibility_type_code='N_P' And nvl(length(trim(p_eligibility_profile_code)),-1)<>-1 ) then
196        fnd_message.set_name('PER', 'HR_51743_WPM_IMP_SEL_ELIG_TYPE');
197        fnd_message.raise_error;
198    end if;
199 
200    if(l_eligibility_type_code='EXIST_P' And nvl(length(trim(p_eligibility_profile_code)),-1)=-1) then
201         fnd_message.set_name('PER', 'HR_51742_WPM_IMP_SEL_ELIG_NAME');
202         fnd_message.raise_error;
203    end if;
204 
205 
206 
207     hr_objective_library_api.create_library_objective
208       (p_validate                     => l_validate
209       ,p_effective_date               => l_effective_date
210       ,p_objective_name               => p_objective_name
211       ,p_valid_from                   => p_valid_from
212       ,p_valid_to                     => p_valid_to
213       ,p_target_date                  => p_target_date
214       ,p_next_review_date             => p_next_review_date
215       ,p_group_code                   => p_group_code
216       ,p_priority_code                => p_priority_code
217       ,p_appraise_flag                => l_appraise_flag
218       ,p_weighting_percent            => p_weighting_percent
219       ,p_measurement_style_code       => l_measurement_style_code
220       ,p_measure_name                 => p_measure_name
221       ,p_target_value                 => p_target_value
222       ,p_uom_code                     => p_uom_code
223       ,p_measure_type_code            => p_measure_type_code
224       ,p_measure_comments             => p_measure_comments
225       ,p_eligibility_type_code        => l_eligibility_type_code
226       ,p_details                      => p_details
227       ,p_success_criteria             => p_success_criteria
228       ,p_comments                     => p_comments
229       ,p_attribute_category           => p_attribute_category
230       ,p_attribute1                   => p_attribute1
231       ,p_attribute2                   => p_attribute2
232       ,p_attribute3                   => p_attribute3
233       ,p_attribute4                   => p_attribute4
234       ,p_attribute5                   => p_attribute5
235       ,p_attribute6                   => p_attribute6
236       ,p_attribute7                   => p_attribute7
237       ,p_attribute8                   => p_attribute8
238       ,p_attribute9                   => p_attribute9
239       ,p_attribute10                  => p_attribute10
240       ,p_attribute11                  => p_attribute11
241       ,p_attribute12                  => p_attribute12
242       ,p_attribute13                  => p_attribute13
243       ,p_attribute14                  => p_attribute14
244       ,p_attribute15                  => p_attribute15
245       ,p_attribute16                  => p_attribute16
246       ,p_attribute17                  => p_attribute17
247       ,p_attribute18                  => p_attribute18
248       ,p_attribute19                  => p_attribute19
249       ,p_attribute20                  => p_attribute20
250       ,p_attribute21                  => p_attribute21
251       ,p_attribute22                  => p_attribute22
252       ,p_attribute23                  => p_attribute23
253       ,p_attribute24                  => p_attribute24
254       ,p_attribute25                  => p_attribute25
255       ,p_attribute26                  => p_attribute26
256       ,p_attribute27                  => p_attribute27
257       ,p_attribute28                  => p_attribute28
258       ,p_attribute29                  => p_attribute29
259       ,p_attribute30                  => p_attribute30
260       ,p_objective_id		      => l_objective_id
261       ,p_object_version_number	      => l_object_version_number
262       ,p_duplicate_name_warning       => l_duplicate_name_warning
263       ,p_weighting_over_100_warning   => l_weighting_over_100_warning
264       ,p_weighting_appraisal_warning  => l_weighting_appraisal_warning
265       );
266     --
267     -- Convert API warning boolean parameter values to specific
268     -- messages and add them to Multiple Message List
269     --
270 
271     if l_weighting_over_100_warning then
272       -- fnd_message.set_name('PER', 'HR_50198_WPM_WEIGHT_WARN');
273         null;
274     end if;
275 
276     if l_weighting_appraisal_warning then
277        --fnd_message.set_name('PER', 'HR_50223_WPM_APPRAISE_WARN');
278          null;
279     end if;
280 
281    if(l_eligibility_type_code='EXIST_P') then
282 
283           -- it will fetch based on security group and security groups
284           -- also enabled
285        	  l_bg_id :=hr_general.get_business_group_id;
286           -- we are ensuring that no way we are not getting
287           -- the business group id of the person so
288           -- try to initializaint the HRsecurity so that
289           -- it will fetch the bgid of the person
290           --if(l_bg_id is null) then
291              -- HR_Signon.Initialize_HR_Security;
292              -- l_bg_id :=hr_general.get_business_group_id;
293          -- end if;
294 
295           if(l_bg_id is null) then
296              open bg_cur(fnd_global.org_id);
297                  fetch bg_cur into l_bg_id;
298              close bg_cur;
299           end if;
300 
301           --checking for eligibility profile name existance.
302           if(p_eligibility_profile_code is not null) then
303              open csr_name(p_eligibility_profile_code,l_effective_date);
304                fetch csr_name into is_profile_exists,l_elig_prfl_bg_id;
305                if(csr_name%NOTFOUND)then
306                     close csr_name;
307                     fnd_message.set_name('PER', 'HR_51794_WPM_STALE_DATA');
308                     fnd_message.raise_error;
309                end if;
310                close csr_name;
311           end if;
312 
313     	  hr_objective_library_api.create_eligy_object
314           (
315 	       	   p_elig_obj_id                    => l_elig_obj_id
316     		  ,p_business_group_id              => l_bg_id
317 	       	  ,p_table_name                     => l_table_name
318     		  ,p_column_name                    => l_column_name
319 	          ,p_column_value                   => l_objective_id
320 	       	  ,p_effective_date                 => l_effective_date
321       		  ,p_effective_start_date           => l_start_date
322  	          ,p_effective_end_date             => l_end_date
323  	      	  ,p_object_version_number          => l_object_version_number
324     	  );
325 
326 
327   	  hr_objective_library_api.create_elig_obj_elig_prfl
328           (
329 		    p_business_group_id              => l_elig_prfl_bg_id
330 		   ,p_elig_obj_id                    => l_elig_obj_id
331 		   ,p_elig_prfl_id                   => p_eligibility_profile_code
332 		   ,p_effective_date                 => l_effective_date
333    		   ,p_effective_start_date           => l_start_date
334  		   ,p_effective_end_date             => l_end_date
335  		   ,p_object_version_number          => l_object_version_number
336 		   ,p_elig_obj_elig_prfl_id          => l_elig_obj_elig_prfl_id
337           );
338     end if;
339     commit;
340     -- Convert API non-warning boolean parameter values
341     --
342     --
343     -- Derive the API return status value based on whether
344     -- messages of any type exist in the Multiple Message List.
345     -- Also disable Multiple Message Detection.
346     --
347     hr_utility.set_location(' Leaving:' || l_proc,20);
348     --
349   exception
350 
351 
352    when others then
353       --
354       -- When Multiple Message Detection is enabled catch
355       -- any Application specific or other unexpected
356       -- exceptions.  Adding appropriate details to the
357       -- Multiple Message List.  Otherwise re-raise the
358       -- error.
359       --
360       rollback to import_library_objective_api;
361       fnd_message.raise_error;
362       hr_utility.set_location(' Leaving:' || l_proc,50);
363 
364 end import_library_objectives;
365 
366 end HR_WPM_IMPORT_LIB_OBJ_API;