83: --
84: begin
85: --
86: l_business_group_id:=fnd_global.per_business_group_id ;
87: hr_utility.set_location('id'||l_operating_unit_id,1000);
88: hr_utility.set_location('name'||l_organization_name,1000);
89: hr_utility.set_location('OID'||l_organization_id,1000);
90: hr_utility.set_location('date'||l_date_from,1000);
91: hr_utility.set_location('flag'||l_internal_external_flag,1000);
84: begin
85: --
86: l_business_group_id:=fnd_global.per_business_group_id ;
87: hr_utility.set_location('id'||l_operating_unit_id,1000);
88: hr_utility.set_location('name'||l_organization_name,1000);
89: hr_utility.set_location('OID'||l_organization_id,1000);
90: hr_utility.set_location('date'||l_date_from,1000);
91: hr_utility.set_location('flag'||l_internal_external_flag,1000);
92: hr_utility.set_location('Entering '||l_proc,10);
85: --
86: l_business_group_id:=fnd_global.per_business_group_id ;
87: hr_utility.set_location('id'||l_operating_unit_id,1000);
88: hr_utility.set_location('name'||l_organization_name,1000);
89: hr_utility.set_location('OID'||l_organization_id,1000);
90: hr_utility.set_location('date'||l_date_from,1000);
91: hr_utility.set_location('flag'||l_internal_external_flag,1000);
92: hr_utility.set_location('Entering '||l_proc,10);
93: --
86: l_business_group_id:=fnd_global.per_business_group_id ;
87: hr_utility.set_location('id'||l_operating_unit_id,1000);
88: hr_utility.set_location('name'||l_organization_name,1000);
89: hr_utility.set_location('OID'||l_organization_id,1000);
90: hr_utility.set_location('date'||l_date_from,1000);
91: hr_utility.set_location('flag'||l_internal_external_flag,1000);
92: hr_utility.set_location('Entering '||l_proc,10);
93: --
94: -- Validation of incoming values.
87: hr_utility.set_location('id'||l_operating_unit_id,1000);
88: hr_utility.set_location('name'||l_organization_name,1000);
89: hr_utility.set_location('OID'||l_organization_id,1000);
90: hr_utility.set_location('date'||l_date_from,1000);
91: hr_utility.set_location('flag'||l_internal_external_flag,1000);
92: hr_utility.set_location('Entering '||l_proc,10);
93: --
94: -- Validation of incoming values.
95: if (l_organization_name is null ) then
88: hr_utility.set_location('name'||l_organization_name,1000);
89: hr_utility.set_location('OID'||l_organization_id,1000);
90: hr_utility.set_location('date'||l_date_from,1000);
91: hr_utility.set_location('flag'||l_internal_external_flag,1000);
92: hr_utility.set_location('Entering '||l_proc,10);
93: --
94: -- Validation of incoming values.
95: if (l_organization_name is null ) then
96: hr_utility.set_location ('Error!!' || l_organization_name, 1001);
92: hr_utility.set_location('Entering '||l_proc,10);
93: --
94: -- Validation of incoming values.
95: if (l_organization_name is null ) then
96: hr_utility.set_location ('Error!!' || l_organization_name, 1001);
97: Hr_utility.set_message(800,'HR_ORG_NAME_INVALID');
98: Hr_utility.raise_error;
99: end if ;
100: if ( l_organization_id is null) then
93: --
94: -- Validation of incoming values.
95: if (l_organization_name is null ) then
96: hr_utility.set_location ('Error!!' || l_organization_name, 1001);
97: Hr_utility.set_message(800,'HR_ORG_NAME_INVALID');
98: Hr_utility.raise_error;
99: end if ;
100: if ( l_organization_id is null) then
101: open is_valid_name ;
94: -- Validation of incoming values.
95: if (l_organization_name is null ) then
96: hr_utility.set_location ('Error!!' || l_organization_name, 1001);
97: Hr_utility.set_message(800,'HR_ORG_NAME_INVALID');
98: Hr_utility.raise_error;
99: end if ;
100: if ( l_organization_id is null) then
101: open is_valid_name ;
102: fetch is_valid_name into l_name_check ;
105: from hr_all_organization_units
106: where business_group_id = l_business_group_id
107: and name = l_organization_name ;
108: /***********
109: hr_utility.set_location ('Error!!' || l_organization_name, 1002);
110: Hr_utility.set_message(800,'HR_289773_MULTI_ORG_DUPLICATE');
111: Hr_utility.raise_error;
112: */
113: else -- Organization does not exist.New org to be created
106: where business_group_id = l_business_group_id
107: and name = l_organization_name ;
108: /***********
109: hr_utility.set_location ('Error!!' || l_organization_name, 1002);
110: Hr_utility.set_message(800,'HR_289773_MULTI_ORG_DUPLICATE');
111: Hr_utility.raise_error;
112: */
113: else -- Organization does not exist.New org to be created
114: null;
107: and name = l_organization_name ;
108: /***********
109: hr_utility.set_location ('Error!!' || l_organization_name, 1002);
110: Hr_utility.set_message(800,'HR_289773_MULTI_ORG_DUPLICATE');
111: Hr_utility.raise_error;
112: */
113: else -- Organization does not exist.New org to be created
114: null;
115: end if;
114: null;
115: end if;
116: end if;
117: if (l_date_from is null) then
118: hr_utility.set_location ('Error!!' || l_organization_name, 1003);
119: Hr_utility.set_message(800,'HR_START_DATE_INVALID');
120: Hr_utility.raise_error;
121: end if;
122: if ((p_internal_external_flag is null) or (p_internal_external_flag not in ('INT', 'EXT'))) then
115: end if;
116: end if;
117: if (l_date_from is null) then
118: hr_utility.set_location ('Error!!' || l_organization_name, 1003);
119: Hr_utility.set_message(800,'HR_START_DATE_INVALID');
120: Hr_utility.raise_error;
121: end if;
122: if ((p_internal_external_flag is null) or (p_internal_external_flag not in ('INT', 'EXT'))) then
123: hr_utility.set_location ('Error!!' , 1004);
116: end if;
117: if (l_date_from is null) then
118: hr_utility.set_location ('Error!!' || l_organization_name, 1003);
119: Hr_utility.set_message(800,'HR_START_DATE_INVALID');
120: Hr_utility.raise_error;
121: end if;
122: if ((p_internal_external_flag is null) or (p_internal_external_flag not in ('INT', 'EXT'))) then
123: hr_utility.set_location ('Error!!' , 1004);
124: Hr_utility.set_message(800,'HR_INT_EXT_INVALID');
119: Hr_utility.set_message(800,'HR_START_DATE_INVALID');
120: Hr_utility.raise_error;
121: end if;
122: if ((p_internal_external_flag is null) or (p_internal_external_flag not in ('INT', 'EXT'))) then
123: hr_utility.set_location ('Error!!' , 1004);
124: Hr_utility.set_message(800,'HR_INT_EXT_INVALID');
125: Hr_utility.raise_error;
126: end if;
127:
120: Hr_utility.raise_error;
121: end if;
122: if ((p_internal_external_flag is null) or (p_internal_external_flag not in ('INT', 'EXT'))) then
123: hr_utility.set_location ('Error!!' , 1004);
124: Hr_utility.set_message(800,'HR_INT_EXT_INVALID');
125: Hr_utility.raise_error;
126: end if;
127:
128: if (l_date_to is not null) then
121: end if;
122: if ((p_internal_external_flag is null) or (p_internal_external_flag not in ('INT', 'EXT'))) then
123: hr_utility.set_location ('Error!!' , 1004);
124: Hr_utility.set_message(800,'HR_INT_EXT_INVALID');
125: Hr_utility.raise_error;
126: end if;
127:
128: if (l_date_to is not null) then
129: if (l_date_to < l_date_from) then
126: end if;
127:
128: if (l_date_to is not null) then
129: if (l_date_to < l_date_from) then
130: hr_utility.set_location ('Error!!' , 1005);
131: Hr_utility.set_message(800,'HR_END_DATE_INVALID');
132: Hr_utility.raise_error;
133: end if;
134: end if;
127:
128: if (l_date_to is not null) then
129: if (l_date_to < l_date_from) then
130: hr_utility.set_location ('Error!!' , 1005);
131: Hr_utility.set_message(800,'HR_END_DATE_INVALID');
132: Hr_utility.raise_error;
133: end if;
134: end if;
135:
128: if (l_date_to is not null) then
129: if (l_date_to < l_date_from) then
130: hr_utility.set_location ('Error!!' , 1005);
131: Hr_utility.set_message(800,'HR_END_DATE_INVALID');
132: Hr_utility.raise_error;
133: end if;
134: end if;
135:
136: if ( p_operating_unit is not null) then
136: if ( p_operating_unit is not null) then
137: open is_valid_ou_id;
138: fetch is_valid_ou_id into l_ou_check ;
139: if (is_valid_ou_id%NOTFOUND) then
140: hr_utility.set_location ('Error!!' , 1006);
141: Hr_utility.set_message(800,'HR_OU_INVALID');
142: Hr_utility.raise_error;
143: end if;
144: end if;
137: open is_valid_ou_id;
138: fetch is_valid_ou_id into l_ou_check ;
139: if (is_valid_ou_id%NOTFOUND) then
140: hr_utility.set_location ('Error!!' , 1006);
141: Hr_utility.set_message(800,'HR_OU_INVALID');
142: Hr_utility.raise_error;
143: end if;
144: end if;
145: -- Validation ends
138: fetch is_valid_ou_id into l_ou_check ;
139: if (is_valid_ou_id%NOTFOUND) then
140: hr_utility.set_location ('Error!!' , 1006);
141: Hr_utility.set_message(800,'HR_OU_INVALID');
142: Hr_utility.raise_error;
143: end if;
144: end if;
145: -- Validation ends
146: hr_utility.set_location(l_proc,20);
142: Hr_utility.raise_error;
143: end if;
144: end if;
145: -- Validation ends
146: hr_utility.set_location(l_proc,20);
147:
148: --check if hr organization exists
149: if (l_organization_id is not null) then
150:
152:
153: open get_internal_external_flag;
154: fetch get_internal_external_flag into l_int_ext_check;
155: if (get_internal_external_flag%notfound) then
156: Hr_utility.set_message(800,'HR_449749_INT_EXT_ERROR');
157: Hr_utility.raise_error;
158: end if;
159: open check_ou_exists;
160: fetch check_ou_exists into l_org_information_id,l_org_info_type_code,l_object_version_number_inf
153: open get_internal_external_flag;
154: fetch get_internal_external_flag into l_int_ext_check;
155: if (get_internal_external_flag%notfound) then
156: Hr_utility.set_message(800,'HR_449749_INT_EXT_ERROR');
157: Hr_utility.raise_error;
158: end if;
159: open check_ou_exists;
160: fetch check_ou_exists into l_org_information_id,l_org_info_type_code,l_object_version_number_inf
161: ,l_object_version_number_org;
170: ,p_object_version_number=>l_object_version_number_inf
171: );
172: exception
173: when others then
174: Hr_utility.set_message(800,'HR_449738_UNABLE_TO_UPD_HRORG');
175: Hr_utility.raise_error;
176: end;
177:
178: elsif(l_operating_unit_id is not null) then
171: );
172: exception
173: when others then
174: Hr_utility.set_message(800,'HR_449738_UNABLE_TO_UPD_HRORG');
175: Hr_utility.raise_error;
176: end;
177:
178: elsif(l_operating_unit_id is not null) then
179: begin
185: ,p_org_information_id =>l_org_information_id
186: ,p_object_version_number =>l_object_version_number);
187: exception
188: when others then
189: Hr_utility.set_message(800,'HR_449738_UNABLE_TO_UPD_HRORG');
190: Hr_utility.raise_error;
191: end;
192: end if;
193:
186: ,p_object_version_number =>l_object_version_number);
187: exception
188: when others then
189: Hr_utility.set_message(800,'HR_449738_UNABLE_TO_UPD_HRORG');
190: Hr_utility.raise_error;
191: end;
192: end if;
193:
194: -----verify if other parameters modified or not
194: -----verify if other parameters modified or not
195: begin
196: open get_object_version_number;
197: fetch get_object_version_number into l_object_version_number_org;
198: hr_utility.set_location(l_object_version_number_org,99);
199: --Update row in HR_ALL_ORGANIZATION_UNITS Table
200: if get_object_version_number%found then
201: hr_organization_api.update_organization(
202: p_effective_date =>sysdate
210: );
211: end if;
212: exception
213: when others then
214: Hr_utility.set_message(800,'HR_449738_UNABLE_TO_UPD_HRORG');
215: Hr_utility.raise_error;
216: end;
217: close get_internal_external_flag;
218: close get_object_version_number;
211: end if;
212: exception
213: when others then
214: Hr_utility.set_message(800,'HR_449738_UNABLE_TO_UPD_HRORG');
215: Hr_utility.raise_error;
216: end;
217: close get_internal_external_flag;
218: close get_object_version_number;
219: close check_ou_exists;
221:
222: --
223: else
224: --Create an Hr organization
225: hr_utility.set_location(l_proc,30);
226: begin
227: hr_organization_api.create_hr_organization(
228: p_effective_date =>sysdate
229: ,p_business_group_id =>l_business_group_id
239: ,p_duplicate_org_warning =>l_duplicate_org_warning);
240: --
241: exception
242: when others then
243: Hr_utility.set_message(800,'HR_449737_UNABLE_TO_CREATE');
244: Hr_utility.raise_error;
245: end;
246:
247: if(l_operating_unit_id is not null) then
240: --
241: exception
242: when others then
243: Hr_utility.set_message(800,'HR_449737_UNABLE_TO_CREATE');
244: Hr_utility.raise_error;
245: end;
246:
247: if(l_operating_unit_id is not null) then
248: begin
255: ,p_object_version_number =>l_object_version_number
256: );
257: exception
258: when others then
259: Hr_utility.set_message(800,'HR_449737_UNABLE_TO_CREATE');
260: Hr_utility.raise_error;
261: end;
262: end if;
263: end if;
256: );
257: exception
258: when others then
259: Hr_utility.set_message(800,'HR_449737_UNABLE_TO_CREATE');
260: Hr_utility.raise_error;
261: end;
262: end if;
263: end if;
264: p_organization_id := l_organization_id ;
264: p_organization_id := l_organization_id ;
265: commit; -- bug 5722328
266: --
267: --
268: hr_utility.set_location('Leaving '||l_proc,40);
269: --
270: end HR_ORG_OPERATING_UNIT_UPLOAD;
271: end HR_ORGANIZATION_INTERNAL;