[Home] [Help]
PACKAGE BODY: APPS.IGS_AD_IMP_008
Source
1 PACKAGE BODY IGS_AD_IMP_008 AS
2 /* $Header: IGSAD86B.pls 120.8 2006/06/23 05:50:39 gmaheswa ship $ */
3 /* Change History
4 Who when What
5
6 ssaleem 13-OCT-2003 Bug : 3130316
7 Logging is modified to include logging mechanism
8 asbala 07-OCT-2003 Bug 3130316. Import Process Source Category Rule processing changes,
9 lookup caching related changes, and cursor parameterization.
10 vrathi 25-jun-2003 Bug No:3019813
11 Added check to set error code and status if the person already exists in HR
12 asbala 18-JUN-2003 Bug No: 3007112
13 Included code to update igs_ad_reladdr_int.status after successful import
14 npalanis 6-JAN-2003 Bug : 2734697
15 code added to commit after import of every
16 100 records .New variable l_processed_records added
17 rrengara 16-DEC-2002 Bug 2693734, 2696082, 2694051, 2692214 fixes
18 gmuralid 26-NOV-2002 BUG 2466674 -- V2API uptake
19 Changed reference of HZ_CONTACT_POINT_PUB
20 TO HZ_CONTACT_POINT_V2PUB for create
21 and update of contact points
22
23 gmuralid 27-NOV-2002 BUG 2676422 -- commented created_by_module := 'IGS' in update
24 call of contact point
25 pkpatel 23-DEC-2002 Bug No: 2722027
26 Moved the code of Person special needs to IGSAD89B.pls
27 gmaheswa 10-NOV-2003 Bug 3223043 HZ.K Impact changes
28 pkpatel 11-DEC-2003 Bug 3311720 (Added the Date validations in Relation Address processing)
29 gmaheswa 15-DEC-2003 Bug 3316838 Removed code related to date overlap under same employer or employer party number.
30 asbala 10-MAR-2004 Bug 3484532 (Removed the check for person already exists in HR. All check will happen from TCA)
31 asbala 15-APR-2004 3349171: Incorrect usage of fnd_lookup_values view
32 akadam.in 21-SEP-2004 Academic History LOV Build
33 skpandey 21-OCT-2004 Bug: 4691121
34 Description: Sync the changes made in version 115.124 from 115.123 which was mistakenly overridden by 115.125 version
35 pkpatel 17-Jan-2006 Bug 4937960 (R12: SWS Performance repository violation deliverables)
36 gmaheswa 27-Jan-2006 Bug: 4938278: crt_rel_adr: Call IGS_PE_WF_GEN. ADDR_BULK_SYNCHRONIZATION to raise bulk
37 || address change notification after process address records of all relationships.
38 || gmaheswa 22-Jun-06 Bug 5189180: modified CREATE_ADDRESS,Update_address to log error code E073, if address created with warning.
39 */
40
41 PROCEDURE Prc_Pe_Relns (
42 p_batch_id IN NUMBER,
43 p_source_type_id IN NUMBER )
44 AS
45 l_prog_label VARCHAR2(100);
46 l_label VARCHAR2(100);
47 l_debug_str VARCHAR2(2000);
48 l_enable_log VARCHAR2(1);
49 l_request_id NUMBER;
50 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
51
52 CURSOR per_rel(cp_interface_run_id igs_ad_interface_all.interface_run_id%TYPE) IS
53 SELECT mi.*,i.person_id
54 FROM igs_ad_relations_int_all mi, igs_ad_interface_all i
55 WHERE mi.interface_run_id = cp_interface_run_id
56 AND mi.interface_id = i.interface_id
57 AND i.interface_run_id = cp_interface_run_id
58 AND mi.status = '2';
59
60 --cursor added to check if the src cat for relations details are included for import (tray)
61 CURSOR c_category_included(p_cat_name IGS_AD_SOURCE_CAT.CATEGORY_NAME%TYPE, p_src_typ_id IGS_AD_SOURCE_CAT.SOURCE_TYPE_ID%TYPE) IS
62 SELECT include_ind
63 FROM igs_ad_source_cat
64 WHERE CATEGORY_NAME = p_cat_name
65 AND SOURCE_TYPE_ID = p_src_typ_id;
66
67 -- Cursor to check whether the relationship exists for the person
68 CURSOR c_rel_count (cp_person_id igs_ad_interface_all.person_id%TYPE,
69 cp_rel_person_id igs_ad_relations_int_all.rel_person_id%TYPE,
70 cp_relationship_type igs_ad_relations_int_all.relationship_type%TYPE,
71 cp_relationship_code igs_ad_relations_int_all.relationship_code%TYPE) IS
72 SELECT count(*)
73 FROM HZ_RELATIONSHIPS
74 WHERE subject_id = cp_person_Id
75 AND object_id = cp_rel_person_id
76 AND RELATIONSHIP_TYPE = cp_relationship_type
77 AND RELATIONSHIP_CODE = cp_relationship_code
78 AND ( SYSDATE BETWEEN START_DATE AND END_DATE )
79 AND STATUS = 'A';
80
81 c_category_included_rec c_category_included%ROWTYPE; --tray
82
83 l_rel_person_exists VARCHAR2(1);
84 l_rel_count NUMBER(3);
85 l_rule VARCHAR2(1);
86 l_status VARCHAR2(10);
87 l_error_code VARCHAR2(10);
88 l_processed_records NUMBER(5);
89
90 CURSOR c_match(p_request_id NUMBER) IS
91 SELECT argument3
92 FROM FND_CONCURRENT_REQUESTS
93 WHERE request_id = p_request_id;
94
95 l_match_set_id igs_pe_match_sets.match_set_id%TYPE;
96 p_rel_dup_rec Igs_Pe_Identify_Dups.r_record_dup_rel;
97
98 -- crt_rel Local Procedure for Prc_Pe_Relns
99
100 PROCEDURE crt_rel(P_Relations_Rec IN per_rel%ROWTYPE, p_src_type_id IN NUMBER) AS
101 /*
102 || Created By : nsinha
103 || Created On : 22-JUN-2001
104 || Purpose : This procedure process the Application
105 || Known limitations, enhancements or remarks :
106 || Change History :
107 || Who When What
108 || skpandey 21-SEP-2005 Bug: 3663505
109 || Description: Added ATTRIBUTES 21 TO 24 TO STORE ADDITIONAL INFORMATION
110 || pkpatel 15-APR-2002 Bug no.1834307 : Modified the Relationship_Type_C cursor to validate both Relationship_code and relationship_type
111 || asbala 12-nov-03 3227107: address changes - signature of igs_pe_person_addr_pkg.insert_row and update_row changed
112 || asbala 15-APR-2004 3349171: Incorrect usage of fnd_lookup_values view
113 || (reverse chronological order - newest change first)
114 */
115
116 --1. Validate the RELATIONSHIP_TYPE and RELATIONSHIP_CODE -- ssawhney PE CCR 2203778
117 -- OSS will not allow creation of relations between org and person through import process at this moment.
118
119 CURSOR Relationship_Type_C(cp_lookup_type fnd_lookup_values.lookup_type%TYPE,
120 cp_subject_type hz_relationship_types.subject_type%TYPE,
121 cp_object_type hz_relationship_types.object_type%TYPE,
122 cp_appl_id fnd_lookup_values.view_application_id%TYPE,
123 cp_relationship_code P_Relations_Rec.Relationship_code%TYPE,
124 cp_relationship_type P_Relations_Rec.Relationship_type%TYPE,
125 cp_security_group_id fnd_lookup_values.security_group_id%TYPE) IS
126 SELECT COUNT(1)
127 FROM FND_LOOKUP_VALUES lk, hz_relationship_types hz
128 WHERE hz.forward_rel_code= cp_relationship_code AND
129 hz.relationship_type = cp_relationship_type AND
130 lk.LOOKUP_TYPE = cp_lookup_type AND
131 lk.lookup_code = hz.forward_rel_code AND
132 hz.subject_type = cp_subject_type AND
133 hz.object_type= cp_object_type AND
134 hz.STATUS='A' AND
135 lk.ENABLED_FLAG='Y' AND
136 lk.VIEW_APPLICATION_ID = cp_appl_id AND
137 lk.language = USERENV('LANG') AND
138 lk.security_group_id = cp_security_group_id;
139
140 CURSOR Rel_person_exists_cur(p_rel_person_id IGS_AD_RELATIONS_INT.REL_PERSON_ID%TYPE) IS
141 SELECT 'Y'
142 FROM HZ_PARTIES
143 WHERE party_id = p_rel_person_id ;
144
145 person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE;
146
147
148 l_rel_person_exists VARCHAR2(1);
149 l_Count NUMBER;
150 l_Status IGS_AD_RELATIONS_INT.STATUS%TYPE;
151 l_return_status IGS_AD_RELATIONS_INT.STATUS%TYPE;
152 l_msg_count NUMBER ;
153 l_last_update_date DATE;
154 l_msg_data VARCHAR2(2000);
155 l_party_id NUMBER;
156 l_person_id igs_pe_person.person_id%TYPE;
157 l_party_number igs_pe_person.person_number%TYPE;
158 l_person_number igs_pe_person.person_number%TYPE;
159 l_profile_id NUMBER;
160 x_rowid VARCHAR2(25);
161 l_rowid VARCHAR2(25);
162 l_party_relationship_id NUMBER;
163 l_TYPE_INSTANCE_ID NUMBER;
164 lv_acc_no VARCHAR2(1);
165 l_generate_party_number VARCHAR2(1);
166 l_object_version_number NUMBER;
167 l_err_cd VARCHAR2(30);
168 p_match_found VARCHAR2(1);
169 l_object_verson_number NUMBER(30);
170 l_message_name VARCHAR2(30);
171 l_app VARCHAR2(50);
172
173 BEGIN
174 l_rel_person_exists := 'N';
175 l_Status := '3';
176 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
177 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_relns.begin_crt_rel';
178 l_debug_str := 'Interface Relations Id: '||p_relations_rec.interface_relations_id;
179 fnd_log.string_with_context( fnd_log.level_procedure,
180 l_label,
181 l_debug_str, NULL,
182 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
183 END IF;
184
185 -- RELATIONSHIP_CODE should be NOT NULL
186 -- ssawhney 2203778 HZ F relationship model changes
187 IF P_Relations_Rec.RELATIONSHIP_CODE IS NULL THEN
188 IF l_enable_log = 'Y' THEN
189 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E171','IGS_AD_RELATIONS_INT_ALL');
190 END IF;
191
192 UPDATE IGS_AD_RELATIONS_INT_ALL
193 SET ERROR_CODE = 'E171',
194 STATUS = l_Status
195 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
196 RETURN;
197 END IF;
198
199 -- Validate the RELATIONSHIP_TYPE
200 OPEN Relationship_Type_C('PARTY_RELATIONS_TYPE','PERSON','PERSON',222,
201 P_Relations_Rec.RELATIONSHIP_CODE,p_relations_rec.RELATIONSHIP_TYPE,0);
202 FETCH Relationship_Type_C INTO l_Count;
203 IF l_Count = 0 THEN
204 IF l_enable_log = 'Y' THEN
205 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E239','IGS_AD_RELATIONS_INT_ALL');
206 END IF;
207 UPDATE IGS_AD_RELATIONS_INT_ALL
208 SET ERROR_CODE = 'E239',
209 STATUS = l_Status
210 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
211
212 CLOSE Relationship_Type_C;
213 RETURN;
214 END IF;
215 IF Relationship_Type_C%ISOPEN THEN
216 CLOSE Relationship_Type_C;
217 END IF;
218
219 l_count:= 0;
220 -- Validate Oth_Relationship_Type
221 IF P_Relations_Rec.Oth_Relationship_Type IS NOT NULL THEN
222 IF NOT(igs_pe_pers_imp_001.validate_lookup_type_code('PARTY_RELATIONS_TYPE',P_Relations_Rec.oth_relationship_type,222)) THEN
223 IF l_enable_log = 'Y' THEN
224 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E240','IGS_AD_RELATIONS_INT_ALL');
225 END IF;
226 UPDATE igs_ad_relations_int_all
227 SET ERROR_CODE = 'E240',
228 STATUS = l_Status
229 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
230 RETURN;
231 END IF;
232 END IF;
233
234 -- If the Rel Person ID passed is valid only the relation is created and Person is not created
235 -- Cursor to check whether the Rel Person ID passed is a valid Party ID in HZ_PARTIES
236 OPEN Rel_person_exists_cur(NVL(p_relations_rec.rel_person_id,0));
237 FETCH Rel_person_exists_cur INTO l_rel_person_exists;
238 CLOSE Rel_person_exists_cur;
239 IF l_rel_person_exists <> 'Y' or l_rel_person_exists IS NULL THEN
240 -- To check profile value HZ_GENERATE_PARTY_NUMBER, and depending on it,
241 -- if or not to pass the person_number is decided.(Tray, Bug#1849225,02-07-2001)
242 l_generate_party_number := fnd_profile.value('HZ_GENERATE_PARTY_NUMBER');
243 IF (l_generate_party_number = 'N') THEN
244 IF (P_Relations_Rec.person_number IS NULL) THEN
245 UPDATE igs_ad_relations_int_all
246 SET STATUS = '3',ERROR_CODE = 'E204'
247 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.INTERFACE_RELATIONS_ID;
248 -- Call Log detail
249 IF l_enable_log = 'Y' THEN
250 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E204','IGS_AD_RELATIONS_INT_ALL');
251 FND_MESSAGE.SET_NAME('IGS','IGS_AD_REL_FAIL_PER_NO');
252 FND_FILE.PUT_LINE(FND_FILE.LOG,FND_MESSAGE.GET);
253 END IF;
254 RETURN;
255 ELSE
256 l_person_number := P_Relations_Rec.person_number;
257 END IF;
258 END IF;
259
260 -- Validate the title
261 IF P_Relations_Rec.pre_name_adjunct IS NOT NULL THEN
262 IF NOT (igs_pe_pers_imp_001.validate_lookup_type_code('CONTACT_TITLE',P_Relations_Rec.pre_name_adjunct,222)) THEN
263 IF l_enable_log = 'Y' THEN
264 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E201','IGS_AD_RELATIONS_INT_ALL');
265 END IF;
266 UPDATE igs_ad_relations_int_all
267 SET ERROR_CODE = 'E201',
268 STATUS = l_Status
269 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
270 RETURN;
271 END IF;
272 END IF;
273 -- Validate Sex.
274 IF P_Relations_Rec.sex IS NOT NULL THEN
275 IF NOT (igs_pe_pers_imp_001.validate_lookup_type_code('HZ_GENDER',P_Relations_Rec.sex,222)) THEN
276 IF l_enable_log = 'Y' THEN
277 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E202','IGS_AD_RELATIONS_INT_ALL');
278 END IF;
279 UPDATE igs_ad_relations_int_all
280 SET ERROR_CODE = 'E202',
281 STATUS = l_Status
282 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
283 RETURN;
284 END IF;
285 END IF;
286
287 -- Validate birth_dt, deceased_dt.
288 IF ((P_Relations_Rec.birth_dt IS NOT NULL) AND (P_Relations_Rec.birth_dt > SYSDATE)) THEN
289 l_err_cd := 'E203';
290 IF l_enable_log = 'Y' THEN
291 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E203','IGS_AD_RELATIONS_INT_ALL');
292 END IF;
293 UPDATE igs_ad_relations_int_all
294 SET ERROR_CODE = l_err_cd,
295 STATUS = l_Status
296 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
297 RETURN;
298 ELSIF ( (NVL(P_Relations_Rec.deceased,'N') = 'Y') AND (P_Relations_Rec.deceased_date > SYSDATE)) THEN
299 l_err_cd := 'E451';
300 IF l_enable_log = 'Y' THEN
301 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E451','IGS_AD_RELATIONS_INT_ALL');
302 END IF;
303 UPDATE igs_ad_relations_int_all
304 SET ERROR_CODE = l_err_cd,
305 STATUS = l_Status
306 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
307 RETURN;
308 END IF;
309
310 p_rel_dup_rec.interface_id := p_relations_rec.interface_id;
311 p_rel_dup_rec.interface_relations_id := p_relations_rec.interface_relations_id;
312 p_rel_dup_rec.surname := p_relations_rec.surname;
313 p_rel_dup_rec.first_name := p_relations_rec.given_names;
314 p_rel_dup_rec.gender := p_relations_rec.sex;
315 p_rel_dup_rec.birth_date := p_relations_rec.birth_dt;
316 p_rel_dup_rec.batch_id := p_batch_id;
317 p_rel_dup_rec.match_set_id := l_match_set_id;
318
319 Igs_Pe_Identify_Dups.Find_dup_rel_per(
320 P_REL_DUP_REC => p_rel_dup_rec,
321 P_MATCH_FOUND => p_match_found
322 );
323 IF p_match_found = 'N' THEN
324 IGS_PE_PERSON_PKG.INSERT_ROW(
325 X_MSG_COUNT => l_msg_count,
326 X_MSG_DATA => l_msg_data,
327 X_RETURN_STATUS => l_return_status,
328 X_ROWID => l_rowid,
329 X_PERSON_ID => l_person_id,
330 X_PERSON_NUMBER => l_person_number,
331 X_SURNAME => p_relations_rec.surname,
332 X_MIDDLE_NAME => NULL,
333 X_GIVEN_NAMES => p_relations_rec.given_names,
334 X_SEX => p_relations_rec.sex,
335 X_TITLE => p_relations_rec.title,
336 X_STAFF_MEMBER_IND => NULL,
337 X_DECEASED_IND => P_Relations_Rec.deceased,
338 X_SUFFIX => NULL,
339 X_PRE_NAME_ADJUNCT => p_relations_rec.pre_name_adjunct,
340 X_ARCHIVE_EXCLUSION_IND => 'N',
341 X_ARCHIVE_DT => NULL,
342 X_PURGE_EXCLUSION_IND => 'N',
343 X_PURGE_DT => NULL,
344 X_DECEASED_DATE => p_relations_rec.deceased_date,
345 X_PROOF_OF_INS => 'N',
346 X_PROOF_OF_IMMU => 'N',
347 X_BIRTH_DT =>p_relations_rec.birth_dt,
348 X_SALUTATION => NULL,
349 X_ORACLE_USERNAME => NULL,
350 X_PREFERRED_GIVEN_NAME => P_Relations_Rec.preferred_given_name,
351 X_EMAIL_ADDR => NULL,
352 X_LEVEL_OF_QUAL_ID => NULL,
353 X_MILITARY_SERVICE_REG =>'N',
354 X_VETERAN => 'VETERAN_NOT', -- ssawhney now a lookup code 2203778
355 X_HZ_PARTIES_OVN => l_object_version_number,
356 X_ATTRIBUTE_CATEGORY => NULL,
357 X_ATTRIBUTE1 => NULL,
358 X_ATTRIBUTE2 => NULL,
359 X_ATTRIBUTE3 => NULL,
360 X_ATTRIBUTE4 => NULL,
361 X_ATTRIBUTE5 => NULL,
362 X_ATTRIBUTE6 => NULL,
363 X_ATTRIBUTE7 => NULL,
364 X_ATTRIBUTE8 => NULL,
365 X_ATTRIBUTE9 => NULL,
366 X_ATTRIBUTE10 => NULL,
367 X_ATTRIBUTE11 => NULL,
368 X_ATTRIBUTE12 => NULL,
369 X_ATTRIBUTE13 => NULL,
370 X_ATTRIBUTE14 => NULL,
371 X_ATTRIBUTE15 => NULL,
372 X_ATTRIBUTE16 => NULL,
373 X_ATTRIBUTE17 => NULL,
374 X_ATTRIBUTE18 => NULL,
375 X_ATTRIBUTE19 => NULL,
376 X_ATTRIBUTE20 => NULL,
377 X_PERSON_ID_TYPE => NULL,
378 X_API_PERSON_ID => NULL,
379 X_MODE => 'R',
380 X_ATTRIBUTE21 => NULL,
381 X_ATTRIBUTE22 => NULL,
382 X_ATTRIBUTE23 => NULL,
383 X_ATTRIBUTE24 => NULL
384 );
385
386
387 IF l_return_status IN ('E','U') THEN
388 IF l_enable_log = 'Y' THEN
389 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E452','IGS_AD_RELATIONS_INT_ALL');
390 END IF;
391 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
392 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel.exception '||'E452';
393 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
394 fnd_message.set_token('INTERFACE_ID',P_Relations_Rec.Interface_Relations_Id);
395 fnd_message.set_token('ERROR_CD','E452');
396 l_debug_str := fnd_message.get || ' ' || l_msg_data;
397 fnd_log.string_with_context( fnd_log.level_exception,
398 l_label,
399 l_debug_str, NULL,
400 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
401 );
402 END IF;
403 UPDATE igs_ad_relations_int_all
404 SET ERROR_CODE = 'E452',
405 status = l_status
406 WHERE interface_relations_id = P_Relations_Rec.Interface_Relations_Id;
407 RETURN;
408 END IF;
409
410 --10. Create the relationship for this person
411 -- ssawhney 2203778 using IGS wrapper now.
412 ELSIF p_match_found = 'Y' THEN
413 l_status := '3';
414 IF l_enable_log = 'Y' THEN
415 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E289','IGS_AD_RELATIONS_INT_ALL');
416 END IF;
417 UPDATE igs_ad_relations_int_all
418 SET ERROR_CODE = 'E289',
419 STATUS = l_Status
420 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
421 RETURN;
422 END IF;
423 ELSE --l_rel_person_exists <> 'Y'
424 l_person_id := p_relations_rec.rel_person_id;
425 END IF;
426
427 BEGIN
428 SAVEPOINT before_creatupdate;
429 igs_pe_relationships_pkg.CREATUPDATE_PARTY_RELATIONSHIP(
430 p_action => 'INSERT',
431 p_subject_id => P_Relations_Rec.Person_Id,
432 p_object_id => l_person_id ,
433 p_party_relationship_type => P_Relations_Rec.RELATIONSHIP_TYPE,
434 p_relationship_code => P_Relations_Rec.RELATIONSHIP_CODE,
435 p_comments => null,
436 p_start_date => sysdate,
437 p_end_date => null,
438 p_last_update_date => l_last_update_date ,
439 p_return_status => l_return_status ,
440 p_msg_count => l_msg_count, -- this is coded wrong, it should have been a number
441 p_msg_data => l_msg_data,
442 p_party_relationship_id => l_party_relationship_id,
443 p_party_id => l_party_id,
444 p_party_number => l_party_number,
445 p_object_version_number => l_object_verson_number) ;
446
447 IF l_return_status IN ('E','U') THEN
448 IF l_enable_log = 'Y' THEN
449 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E172','IGS_AD_RELATIONS_INT_ALL');
450 END IF;
451
452 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
453 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel.exception '||'E172';
454 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
455 fnd_message.set_token('INTERFACE_ID',P_Relations_Rec.Interface_Relations_Id);
456 fnd_message.set_token('ERROR_CD','E172');
457 l_debug_str := fnd_message.get || ' ' || l_msg_data;
458 fnd_log.string_with_context( fnd_log.level_exception,
459 l_label,
460 l_debug_str, NULL,
461 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
462 );
463 END IF;
464 UPDATE igs_ad_relations_int_all
465 SET ERROR_CODE = 'E172',
466 STATUS = '3'
467 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
468 RETURN;
469 ELSE
470 UPDATE igs_ad_relations_int_all
471 SET rel_person_id = l_person_id,
472 status = '1',
473 ERROR_CODE = NULL
474 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
475 END IF;
476
477 EXCEPTION
478 WHEN OTHERS THEN
479 ROLLBACK TO before_creatupdate;
480 FND_MESSAGE.PARSE_ENCODED(FND_MESSAGE.GET_ENCODED, l_app, l_message_name);
481 IF l_message_name = ('IGS_PE_PERS_ID_PRD_OVRLP') THEN
482 IF l_enable_log = 'Y' THEN
483 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E290','IGS_AD_RELATIONS_INT_ALL');
484 END IF;
485 UPDATE igs_ad_relations_int_all
486 SET ERROR_CODE = 'E290',
487 STATUS = '3'
488 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
489 RETURN;
490 ELSE
491 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
492 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel.exception.others';
493 l_debug_str := 'Unhandled Exception for interface Relatuons ID:'||P_Relations_Rec.Interface_Relations_Id||' ' || l_msg_data;
494 fnd_log.string_with_context( fnd_log.level_exception,
495 l_label,
496 l_debug_str, NULL,
497 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
498 );
499 END IF;
500 RETURN;
501 END IF;
502 END ;
503
504 --9. If the person and relationship creation is successful then
505 --Added to check if include_ind is 'Y'/'N' for the source_category for importing details of the relation created (tray),
506 --if yes make a call to process the category in question , (tray)
507
508 OPEN c_category_included('RELATIONS_CONTACTS',p_src_type_id);
509 FETCH c_category_included INTO c_category_included_rec;
510 CLOSE c_category_included;
511 IF c_category_included_rec.include_ind = 'Y' THEN
512 -- ssomani, passing the person id of the relation created above 15 March 2001
513 prc_rel_con_dtl(P_Relations_Rec.interface_relations_id, l_person_id , p_source_type_id);
514 END IF;
515
516 OPEN c_category_included('RELATIONS_ADDRESS',p_src_type_id);
517 FETCH c_category_included INTO c_category_included_rec;
518 CLOSE c_category_included;
519 IF c_category_included_rec.include_ind = 'Y' THEN
520 Crt_Rel_adr(P_Relations_Rec.interface_relations_id, l_person_id,p_source_type_Id);
521 END IF;
522
523 OPEN c_category_included('RELATIONS_ACAD_HISTORY',p_src_type_id);
524 FETCH c_category_included INTO c_category_included_rec;
525 CLOSE c_category_included;
526 IF c_category_included_rec.include_ind = 'Y' THEN
527 -- ssomani, passing the person id of the relation created above 15 March 2001
528 crt_rel_acad_his(P_Relations_Rec.interface_relations_id, l_PERSON_ID,p_source_type_Id);
529 END IF;
530
531 OPEN c_category_included('RELATIONS_EMPLOYMENT_DETAILS',p_src_type_id);
532 FETCH c_category_included INTO c_category_included_rec;
533 CLOSE c_category_included;
534 IF c_category_included_rec.include_ind = 'Y' THEN
535 Prc_Relns_Emp_Dtls(P_Relations_Rec.interface_relations_id, l_PERSON_ID,p_source_type_id);
536 END IF;
537
538 -----------------------------------
539 EXCEPTION
540 WHEN OTHERS THEN
541 l_msg_data := SQLERRM;
542 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
543 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel.exception '|| 'E518';
544 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
545 fnd_message.set_token('INTERFACE_ID',p_relations_rec.interface_relations_id);
546 fnd_message.set_token('ERROR_CD','E518');
547 l_debug_str := fnd_message.get || ' ' || SQLERRM;
548 fnd_log.string_with_context( fnd_log.level_exception,
549 l_label,
550 l_debug_str, NULL,
551 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
552 );
553 END IF;
554
555 IF l_enable_log = 'Y' THEN
556 igs_ad_imp_001.logerrormessage(P_Relations_Rec.Interface_Relations_Id,'E518','IGS_AD_RELATIONS_INT_ALL');
557 END IF;
558
559 UPDATE igs_ad_relations_int_all
560 SET ERROR_CODE = 'E518',
561 STATUS = l_Status
562 WHERE INTERFACE_RELATIONS_ID = P_Relations_Rec.Interface_Relations_Id;
563 END crt_rel;
564 -- End Local Procedure crt_rel
565
566 -- Main Procedure starts here Prc_Pe_Rel
567 BEGIN
568 l_processed_records := 0;
569 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
570 l_prog_label := 'igs.plsql.igs_ad_imp_008.prc_pe_relns';
571 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_relns.';
572 l_enable_log := igs_ad_imp_001.g_enable_log;
573 l_request_id := fnd_global.conc_request_id;
574 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
575 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_relns.begin';
576 l_debug_str := 'igs_ad_imp_008.prc_pe_rel';
577 fnd_log.string_with_context( fnd_log.level_procedure,
578 l_label,
579 l_debug_str, NULL,
580 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
581 );
582 END IF;
583
584 /* OPEN c_match(l_request_id);
585 FETCH c_match INTO l_match_set_id;
586 CLOSE c_match;
587 */
588
589 l_match_set_id := Igs_Pe_Identify_Dups.g_match_set_id; -- bug 3671344
590
591 FOR relations_rec IN per_rel(l_interface_run_id) LOOP
592 l_processed_records := l_processed_records + 1 ;
593 relations_rec.RELATIONSHIP_CODE := UPPER(relations_rec.RELATIONSHIP_CODE);
594 relations_rec.RELATIONSHIP_TYPE := UPPER(relations_rec.RELATIONSHIP_TYPE);
595 relations_rec.pre_name_adjunct := UPPER(relations_rec.pre_name_adjunct);
596 relations_rec.OTH_RELATIONSHIP_TYPE := UPPER(relations_rec.OTH_RELATIONSHIP_TYPE);
597 relations_rec.sex := UPPER(relations_rec.sex);
598 BEGIN
599 -- Check to see that the rel_person ID passed is valid
600 IF relations_rec.rel_person_id IS NULL OR
601 relations_rec.relationship_code IS NULL THEN
602 RAISE NO_DATA_FOUND;
603 END IF;
604 -- Check whether the relationship exist for the person
605 OPEN c_rel_count(relations_rec.person_Id,relations_rec.rel_person_id,
606 relations_rec.relationship_type,relations_rec.relationship_code);
607 FETCH c_rel_count INTO l_rel_count;
608 CLOSE c_rel_count;
609 IF l_rel_count = 0 THEN
610 RAISE NO_DATA_FOUND;
611 END IF;
612 -- If Relation exists update interface table and proceed to the next record
613 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
614 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_relns.relation_exist';
615 l_debug_str := 'Igs_Ad_Imp_008.Prc_Pe_Relns ' ||'Interface_Relations_Id : ' ||
616 IGS_GE_NUMBER.TO_CANN(Relations_Rec.Interface_Relations_Id) ||'Status : 1' || 'Relationship Exists';
617 fnd_log.string_with_context( fnd_log.level_procedure,
618 l_label,
619 l_debug_str, NULL,
620 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
621 );
622 END IF;
623
624 UPDATE igs_ad_relations_int_all
625 SET status = '1',
626 error_code = NULL
627 WHERE interface_relations_id = relations_rec.interface_relations_id;
628 OPEN c_category_included('RELATIONS_CONTACTS',p_source_type_id);
629 FETCH c_category_included INTO c_category_included_rec;
630 CLOSE c_category_included;
631 IF c_category_included_rec.include_ind = 'Y' THEN
632 -- ssomani, passing the person id of the relation created above 15 March 2001
633 prc_rel_con_dtl(Relations_Rec.interface_relations_id, relations_rec.Rel_Person_Id, p_source_type_id);
634 END IF;
635 OPEN c_category_included('RELATIONS_ADDRESS',p_source_type_id);
636 FETCH c_category_included INTO c_category_included_rec;
637 CLOSE c_category_included;
638
639 IF c_category_included_rec.include_ind = 'Y' THEN
640 crt_rel_adr (relations_rec.interface_relations_id, relations_rec.Rel_Person_Id, p_source_type_id);
641 END IF;
642
643 OPEN c_category_included('RELATIONS_ACAD_HISTORY',p_source_type_id);
644 FETCH c_category_included INTO c_category_included_rec;
645 CLOSE c_category_included;
646 IF c_category_included_rec.include_ind = 'Y' THEN
647 -- ssomani, passing the person id of the relation created above 15 March 2001
648 crt_rel_acad_his(Relations_Rec.interface_relations_id, relations_rec.Rel_Person_Id, p_source_type_Id);
649 END IF;
650
651 OPEN c_category_included('RELATIONS_EMPLOYMENT_DETAILS',p_source_type_id);
652 FETCH c_category_included INTO c_category_included_rec;
653 CLOSE c_category_included;
654 IF c_category_included_rec.include_ind = 'Y' THEN
655 Prc_Relns_Emp_Dtls(Relations_Rec.interface_relations_id, relations_rec.Rel_Person_Id, p_source_type_id);
656 END IF;
657
658 EXCEPTION
659 WHEN NO_DATA_FOUND THEN
660 crt_rel(P_Relations_Rec => relations_rec,
661 p_src_type_id=> p_source_type_id); --tray , parameter added p_src_type_id=> p_source_type_id
662 WHEN OTHERS THEN
663 -- this can happen from the crt_rel_adr also, hence its better to keep when others
664 -- and when no data found separate
665 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
666 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_relns.exception';
667 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
668 fnd_message.set_token('INTERFACE_ID',relations_rec.interface_relations_id);
669 fnd_message.set_token('ERROR_CD','E518');
670 l_debug_str := fnd_message.get || ' ' || SQLERRM;
671 fnd_log.string_with_context( fnd_log.level_exception,
672 l_label,
673 l_debug_str, NULL,
674 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
675 );
676 END IF;
677
678 IF l_enable_log = 'Y' THEN
679 igs_ad_imp_001.logerrormessage(Relations_Rec.Interface_Relations_Id,'E518','IGS_AD_RELATIONS_INT_ALL');
680 END IF;
681 UPDATE igs_ad_relations_int_all
682 SET status = '3', error_code = 'E518'
683 WHERE interface_relations_id = relations_rec.interface_relations_id;
684 END;
685 IF l_processed_records = 100 THEN
686 COMMIT;
687 l_processed_records := 0;
688 END IF;
689 END LOOP;
690 END Prc_Pe_Relns;
691
692 PROCEDURE crt_rel_adr (P_Interface_Relations_Id NUMBER,
693 P_Rel_Person_Id NUMBER,
694 p_source_type_id NUMBER) AS
695
696 l_prog_label VARCHAR2(100);
697 l_label VARCHAR2(100);
698 l_debug_str VARCHAR2(2000);
699 l_enable_log VARCHAR2(1);
700 l_request_id NUMBER;
701 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
702 l_party_site_ovn hz_party_sites.object_version_number%TYPE;
703 l_location_ovn hz_locations.object_version_number%TYPE;
704 l_addr_process BOOLEAN := FALSE;
705
706
707 --1. Pick up all the records from the table IGS_AD_RELADDR_INT
708 CURSOR reladdr_rec_c( cp_Interface_Relations_Id NUMBER ) IS
709 SELECT *
710 FROM igs_ad_reladdr_int_all
711 WHERE status = '2'
712 AND interface_relations_id = cp_interface_relations_id;
713
714 --3. Validate to see if this address already exist for this person.
715 CURSOR addr_c(p_addr_line_1 igs_ad_reladdr_int.addr_line_1%TYPE,
716 p_addr_line_2 igs_ad_reladdr_int.addr_line_2%TYPE,
717 p_addr_line_3 igs_ad_reladdr_int.addr_line_3%TYPE,
718 p_addr_line_4 igs_ad_reladdr_int.addr_line_4%TYPE,
719 p_country igs_ad_reladdr_int.country%TYPE,
720 p_county igs_ad_reladdr_int.county%TYPE,
721 p_province igs_ad_reladdr_int.province%TYPE,
722 p_city igs_ad_reladdr_int.city%TYPE,
723 p_state igs_ad_reladdr_int.state%TYPE,
724 p_party_id NUMBER
725 ) IS
726 SELECT *
727 FROM IGS_PE_ADDR_V
728 WHERE UPPER(addr_line_1) = UPPER(p_addr_line_1)
729 AND UPPER(nvl(addr_line_2,'NulL')) = UPPER(nvl(p_addr_line_2,'NulL'))
730 AND UPPER(nvl(addr_line_3,'NulL')) = UPPER(nvl(p_addr_line_3,'NulL'))
731 AND UPPER(nvl(addr_line_4,'NulL')) = UPPER(nvl(p_addr_line_4,'NulL'))
732 AND country_cd = p_country
733 AND UPPER(nvl(county,'NulL')) = UPPER(nvl(p_county,'NulL'))
734 AND UPPER(nvl(province,'NulL')) = UPPER(nvl(p_province,'NulL'))
735 AND UPPER(nvl(city,'NulL')) = UPPER(nvl(p_city,'NulL'))
736 AND UPPER(nvl(state,'NulL')) = UPPER(nvl(p_state,'NulL'))
737 AND person_id = P_Rel_Person_Id;
738
739 addr_rec addr_c%ROWTYPE;
740
741
742 --Check to see if for this address these two site usages exist.
743 CURSOR site_c (p_party_site_id igs_pe_addr_v.party_site_id%TYPE,
744 p_site_use_code igs_ad_reladdr_int.site_use_code_1%TYPE ) IS
745 SELECT site_use_type,party_site_use_id,last_update_date
746 FROM HZ_PARTY_SITE_USES
747 WHERE PARTY_SITE_ID = p_party_site_id
748 AND site_use_type = p_site_use_code;
749
750
751
752 --Create a party_site.
753 p_api_version NUMBER(15);
754 site_c_rec site_c%ROWTYPE;
755 l_party_site_id HZ_PARTY_SITES.PARTY_SITE_ID%TYPE;
756 l_party_site_number VARCHAR2(2000);
757 l_party_site_use_id HZ_PARTY_SITE_USES.PARTY_SITE_USE_ID%TYPE;
758 l_site1 igs_ad_reladdr_int.site_use_code_1%TYPE;
759 l_site2 igs_ad_reladdr_int.site_use_code_2%TYPE;
760 l_return_status IGS_AD_RELATIONS_INT.STATUS%TYPE;
761 l_msg_count NUMBER;
762 l_msg_data VARCHAR2(2000);
763 l_Count NUMBER;
764 l_Status IGS_AD_RELATIONS_INT.STATUS%TYPE;
765 l_Error_Code IGS_AD_RELATIONS_INT.Error_Code%TYPE;
766 l_rule igs_ad_source_cat.discrepancy_rule_cd%TYPE;
767 l_last_update_date DATE;
768 l_site_use_last_update_date DATE;
769 l_profile_last_update_date DATE;
770 l_row_id VARCHAR2(30);
771 l_location_id HZ_LOCATIONS.LOCATION_ID%TYPE;
772 l_territory_short_name FND_TERRITORIES_VL.TERRITORY_SHORT_NAME%TYPE;
773 l_Check VARCHAR2(30);
774 l_object_version_number NUMBER;
775
776 PROCEDURE Update_Addr(addr_rec addr_c%ROWTYPE , reladdr_rec reladdr_rec_c%ROWTYPE , p_rel_person_id NUMBER) AS
777 --Check to see if for this address these two site usages exist.
778 CURSOR site_c (p_party_site_id igs_pe_addr_v.party_site_id%TYPE,
779 p_site_use_code igs_ad_reladdr_int.site_use_code_1%TYPE ) IS
780 SELECT site_use_type,party_site_use_id,last_update_date
781 FROM hz_party_site_uses
782 WHERE party_site_id = p_party_site_id AND
783 site_use_type = p_site_use_code;
784 l_flag_check_status VARCHAR2(1);
785 site_c_rec site_c%ROWTYPE;
786 l_location_id HZ_LOCATIONS.LOCATION_ID%TYPE;
787 l_party_site_id HZ_PARTY_SITES.PARTY_SITE_ID%TYPE;
788 l_party_site_use_id HZ_PARTY_SITE_USES.PARTY_SITE_USE_ID%TYPE;
789 l_row_id VARCHAR2(30);
790 l_Status IGS_AD_RELATIONS_INT.STATUS%TYPE;
791 l_Error_Code IGS_AD_RELATIONS_INT.Error_Code%TYPE;
792 l_return_status IGS_AD_RELATIONS_INT.STATUS%TYPE;
793 l_msg_data VARCHAR2(2000);
794 l_last_update_date DATE;
795 l_site_use_last_update_date DATE;
796 l_profile_last_update_date DATE;
797 l_addr_warning VARCHAR2(1) := 'N';
798 BEGIN
799 l_flag_check_status := 'Y';
800 l_Status := '3';
801 l_Error_Code := 'E008';
802 l_site_use_last_update_date := NULL;
803 l_profile_last_update_date := NULL;
804
805 l_location_id := addr_rec.location_id;
806 l_party_site_id := addr_rec.party_site_id;
807 -- cursor to fetch l_last_update_date from hz_locations for a given location_id
808 l_location_ovn := addr_rec.location_ovn;
809 l_party_site_ovn := addr_rec.party_site_ovn;
810
811 IGS_PE_PERSON_ADDR_PKG.UPDATE_ROW(
812 p_action => NULL,
813 p_rowid => l_row_id,
814 p_location_id => l_location_id ,
815 p_start_dt => nvl(reladdr_rec.start_dt,addr_rec.start_dt) ,
816 p_end_dt => nvl(reladdr_rec.end_dt,addr_rec.end_dt) ,
817 p_country => nvl(reladdr_rec.country,addr_rec.country),
818 p_address_style => addr_rec.address_style,
819 p_addr_line_1 => nvl(reladdr_rec.addr_line_1,addr_rec.addr_line_1),
820 p_addr_line_2 => nvl(reladdr_rec.addr_line_2,addr_rec.addr_line_2),
821 p_addr_line_3 => nvl(reladdr_rec.addr_line_3,addr_rec.addr_line_3),
822 p_addr_line_4 => nvl(reladdr_rec.addr_line_4,addr_rec.addr_line_4),
823 p_date_last_verified => addr_rec.date_last_verified,
824 p_correspondence => nvl(reladdr_rec.correspondence,addr_rec.correspondence),
825 p_city => nvl(reladdr_rec.city,addr_rec.city),
826 p_state => nvl(reladdr_rec.state,addr_rec.state),
827 p_province => nvl(reladdr_rec.province,addr_rec.province),
828 p_county => nvl(reladdr_rec.county,addr_rec.county),
829 p_postal_code => nvl(reladdr_rec.postal_code,addr_rec.postal_code),
830 p_address_lines_phonetic => addr_rec.address_lines_phonetic,
831 p_delivery_point_code => addr_rec.delivery_point_code,
832 p_other_details_1 => nvl(reladdr_rec.other_details_1,addr_rec.other_details_1),
833 p_other_details_2 => nvl(reladdr_rec.other_details_2,addr_rec.other_details_2),
834 p_other_details_3 => nvl(reladdr_rec.other_details_3,addr_rec.other_details_3),
835 l_return_status => l_return_status ,
836 l_msg_data => l_msg_data ,
837 p_party_id => P_Rel_Person_Id,
838 p_party_site_id => l_party_site_id,
839 p_party_type => NULL,
840 p_last_update_date => l_last_update_date,
841 p_party_site_ovn => l_party_site_ovn,
842 p_location_ovn => l_location_ovn,
843 p_status => addr_rec.status
844 );
845
846 IF l_return_status IN ('E','U') THEN
847 l_flag_check_status := 'N';
848 IF l_enable_log = 'Y' THEN
849 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E014','IGS_AD_RELADDR_INT_ALL');
850 END IF;
851 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
852 IF (l_request_id IS NULL) THEN
853 l_request_id := fnd_global.conc_request_id;
854 END IF;
855 l_label := 'igs.plsql.igs_ad_imp_008.update_addr.exception '||'E014';
856
857 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
858 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
859 fnd_message.set_token('ERROR_CD','E014');
860 l_debug_str := fnd_message.get || ' ' || l_msg_data;
861 fnd_log.string_with_context( fnd_log.level_exception,
862 l_label,
863 l_debug_str, NULL,
864 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
865 );
866 END IF;
867
868 UPDATE Igs_Ad_RelAddr_Int_all
869 SET Error_Code = 'E014',
870 Status = '3'
871 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
872 ELSIF l_return_status = 'W' THEN
873 l_addr_warning := 'Y';
874 IF l_enable_log = 'Y' THEN
875 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E073','IGS_AD_RELADDR_INT_ALL');
876 END IF;
877 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
878 IF (l_request_id IS NULL) THEN
879 l_request_id := fnd_global.conc_request_id;
880 END IF;
881 l_label := 'igs.plsql.igs_ad_imp_008.update_addr.warning '||'E073';
882
883 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
884 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
885 fnd_message.set_token('ERROR_CD','E073');
886 l_debug_str := fnd_message.get || ' ' || l_msg_data;
887 fnd_log.string_with_context( fnd_log.level_exception,
888 l_label,
889 l_debug_str, NULL,
890 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
891 );
892 END IF;
893
894 UPDATE Igs_Ad_RelAddr_Int_all
895 SET Error_Code = 'E073',
896 Status = '4'
897 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
898 END IF;
899 IF (reladdr_rec.site_use_code_1 IS NOT NULL) AND l_flag_check_status = 'Y' THEN
900 --Check to see if for this address the site usage exist.
901 OPEN site_c(addr_rec.party_site_id, reladdr_rec.site_use_code_1);
902 FETCH site_c INTO site_c_rec;
903 l_party_site_id := addr_rec.party_site_id;
904 IF site_c%NOTFOUND THEN
905 l_party_site_use_id := NULL;
906 l_object_version_number := NULL;
907 -- call to create party site uses for site use code 1
908 IGS_PE_PARTY_SITE_USE_PKG.HZ_PARTY_SITE_USES_AK(
909 p_action => 'INSERT',
910 p_rowid => l_row_id,
911 p_party_site_use_id => l_party_site_use_id,
912 p_party_site_id => l_party_site_id,
913 p_site_use_type => reladdr_rec.site_use_code_1,
914 p_status => 'A',
915 p_return_status => l_return_status,
916 p_msg_data => l_msg_data,
917 p_last_update_date => l_last_update_date,
918 p_site_use_last_update_date => l_site_use_last_update_date,
919 P_profile_last_update_date => l_profile_last_update_date,
920 p_hz_party_site_use_ovn => l_object_version_number
921 );
922
923 IF l_return_status IN ('E','U') THEN
924 l_flag_check_status := 'N';
925 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
926 IF (l_request_id IS NULL) THEN
927 l_request_id := fnd_global.conc_request_id;
928 END IF;
929 l_label := 'igs.plsql.igs_ad_imp_008.update_addr.exception1 '||'E244';
930 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
931 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
932 fnd_message.set_token('ERROR_CD','E244');
933 l_debug_str := fnd_message.get || ' ' || l_msg_data;
934 fnd_log.string_with_context( fnd_log.level_exception,
935 l_label,
936 l_debug_str, NULL,
937 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
938 );
939 END IF;
940 IF l_enable_log = 'Y' THEN
941 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E244','IGS_AD_RELADDR_INT_ALL');
942 END IF;
943 UPDATE Igs_Ad_RelAddr_Int_all
944 SET Error_Code = 'E244',
945 Status = '3'
946 WHERE INTERFACE_RELADDR_ID = reladdr_rec.INTERFACE_RELADDR_ID;
947 END IF;
948 END IF;
949 CLOSE site_c;
950 END IF;
951
952 IF (reladdr_rec.site_use_code_2 IS NOT NULL) AND l_flag_check_status = 'Y' THEN
953 --Check to see if for this address these two site usages exist.
954 OPEN site_c(addr_rec.party_site_id, reladdr_rec.site_use_code_2);
955 FETCH site_c INTO site_c_rec;
956 l_party_site_id := addr_rec.party_site_id;
957 IF site_c%NOTFOUND THEN
958 l_party_site_use_id := NULL;
959 l_object_version_number := NULL;
960 -- call to create party site uses for site use code 2
961 IGS_PE_PARTY_SITE_USE_PKG.HZ_PARTY_SITE_USES_AK(
962 p_action => 'INSERT',
963 p_rowid => l_row_id,
964 p_party_site_use_id => l_party_site_use_id,
965 p_party_site_id => l_party_site_id,
966 p_site_use_type => reladdr_rec.site_use_code_2,
967 p_status => 'A',
968 p_return_status => l_return_status,
969 p_msg_data => l_msg_data,
970 p_last_update_date => l_last_update_date,
971 p_site_use_last_update_date => l_site_use_last_update_date,
972 P_profile_last_update_date => l_profile_last_update_date,
973 p_hz_party_site_use_ovn => l_object_version_number
974 );
975 IF l_return_status IN('E','U') THEN
976 l_flag_check_status := 'N';
977
978 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
979 IF (l_request_id IS NULL) THEN
980 l_request_id := fnd_global.conc_request_id;
981 END IF;
982 l_label := 'igs.plsql.igs_ad_imp_008.update_addr.exception2 '||'E244';
983 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
984 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
985 fnd_message.set_token('ERROR_CD','E244');
986 l_debug_str := fnd_message.get || ' ' || l_msg_data;
987 fnd_log.string_with_context( fnd_log.level_exception,
988 l_label,
989 l_debug_str, NULL,
990 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
991 );
992 END IF;
993 IF l_enable_log = 'Y' THEN
994 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E244','IGS_AD_RELADDR_INT_ALL');
995 END IF;
996 UPDATE Igs_Ad_RelAddr_Int_all
997 SET Error_Code = 'E244',
998 Status = l_Status
999 WHERE INTERFACE_RELADDR_ID = reladdr_rec.INTERFACE_RELADDR_ID;
1000 END IF;
1001 END IF;
1002 CLOSE site_c;
1003 END IF;
1004
1005 IF l_flag_check_status = 'Y' AND l_addr_warning = 'N' THEN
1006 UPDATE igs_ad_reladdr_int_all
1007 SET error_code = NULL,
1008 match_ind = '18',
1009 status = '1'
1010 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1011
1012 -- Address Record processed successfully
1013 l_addr_process := TRUE;
1014 END IF;
1015
1016 EXCEPTION
1017 WHEN OTHERS THEN
1018 l_msg_data := SQLERRM;
1019 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
1020 IF (l_request_id IS NULL) THEN
1021 l_request_id := fnd_global.conc_request_id;
1022 END IF;
1023 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.update_addr_exception'||'E014';
1024 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
1025 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
1026 fnd_message.set_token('ERROR_CD','E014');
1027 l_debug_str := fnd_message.get || ' ' || SQLERRM;
1028 fnd_log.string_with_context( fnd_log.level_exception,
1029 l_label,
1030 l_debug_str, NULL,
1031 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1032 );
1033 END IF;
1034 IF l_enable_log = 'Y' THEN
1035 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E014','IGS_AD_RELADDR_INT_ALL');
1036 END IF;
1037
1038 UPDATE Igs_Ad_RelAddr_Int_all
1039 SET Error_Code = 'E014',
1040 Status = '3'
1041 WHERE Interface_Reladdr_Id = reladdr_rec.Interface_Reladdr_Id;
1042 END Update_Addr;
1043 -- End Local Procedure Update_Addr
1044 -- Start Local Procedure to validate address
1045 PROCEDURE Validate_reladdr(reladdr_rec IN reladdr_rec_c%ROWTYPE , p_rel_person_id IN NUMBER , l_Check OUT NOCOPY VARCHAR2 ) AS
1046 CURSOR terr_name_cur(p_territory_code FND_TERRITORIES_VL.TERRITORY_CODE%TYPE) IS
1047 SELECT territory_short_name
1048 FROM fnd_territories_vl
1049 WHERE territory_code = p_territory_code;
1050
1051 CURSOR birth_date_cur(cp_person_id igs_pe_person_base_v.person_id%TYPE) IS
1052 SELECT birth_date
1053 FROM igs_pe_person_base_v
1054 WHERE person_id = cp_person_id;
1055
1056 l_Status igs_ad_relations_int.status%TYPE;
1057 l_Error_Code igs_ad_relations_int.error_code%TYPE;
1058 l_birth_date DATE;
1059 BEGIN
1060 l_Status := '3';
1061 IF (reladdr_rec.site_use_code_1 IS NOT NULL) THEN
1062 IF NOT (igs_pe_pers_imp_001.validate_lookup_type_code('PARTY_SITE_USE_CODE',reladdr_rec.site_use_code_1,222)) THEN
1063 IF l_enable_log = 'Y' THEN
1064 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E211','IGS_AD_RELADDR_INT_ALL');
1065 END IF;
1066
1067 UPDATE igs_ad_reladdr_int_all
1068 SET error_code = 'E211', status = '3'
1069 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1070
1071 l_check := 'TRUE';
1072 RETURN;
1073 END IF;
1074 END IF;
1075
1076 IF (reladdr_rec.site_use_code_2 IS NOT NULL) THEN
1077 IF NOT (igs_pe_pers_imp_001.validate_lookup_type_code('PARTY_SITE_USE_CODE',reladdr_rec.site_use_code_2,222)) THEN
1078 IF l_enable_log = 'Y' THEN
1079 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E211','IGS_AD_RELADDR_INT_ALL');
1080 END IF;
1081 UPDATE igs_ad_reladdr_int_all
1082 SET error_code = 'E211', status = '3'
1083 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1084 l_Check:='TRUE';
1085 RETURN;
1086 END IF;
1087 END IF;
1088 -- Also site_use_code_1 should not be the same as site_use_code_2.
1089 IF (reladdr_rec.site_use_code_1 IS NOT NULL AND reladdr_rec.site_use_code_2 IS NOT NULL) THEN
1090 IF reladdr_rec.site_use_code_1 = reladdr_rec.site_use_code_2 THEN
1091 IF l_enable_log = 'Y' THEN
1092 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E449','IGS_AD_RELADDR_INT_ALL');
1093 END IF;
1094
1095 UPDATE igs_ad_reladdr_int_all
1096 SET error_code = 'E449', status = '3'
1097 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1098
1099 l_Check:='TRUE';
1100 RETURN;
1101 END IF;
1102 END IF;
1103
1104 -- Get Territory short name from territory code
1105 OPEN terr_name_cur(reladdr_rec.country);
1106 FETCH terr_name_cur INTO l_territory_short_name ;
1107 IF terr_name_cur%NOTFOUND THEN
1108 IF l_enable_log = 'Y' THEN
1109 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E209','IGS_AD_RELADDR_INT_ALL');
1110 END IF;
1111
1112 UPDATE igs_ad_reladdr_int_all
1113 SET error_code = 'E209', status = '3'
1114 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1115 l_check := 'TRUE';
1116 CLOSE terr_name_cur;
1117 RETURN;
1118 END IF;
1119 CLOSE terr_name_cur;
1120
1121 IF reladdr_rec.correspondence IS NOT NULL THEN
1122 IF reladdr_rec.correspondence NOT IN ('Y','N') THEN
1123 IF l_enable_log = 'Y' THEN
1124 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E213','IGS_AD_RELADDR_INT_ALL');
1125 END IF;
1126
1127 UPDATE igs_ad_reladdr_int_all
1128 SET error_code = 'E213', status = '3'
1129 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1130
1131 l_Check:='TRUE';
1132 RETURN;
1133 END IF;
1134 END IF;
1135
1136 IF reladdr_rec.start_dt IS NULL AND reladdr_rec.end_dt IS NOT NULL THEN
1137 IF l_enable_log = 'Y' THEN
1138 igs_ad_imp_001.logerrormessage( reladdr_rec.interface_reladdr_id,'E407','IGS_AD_RELADDR_INT_ALL');
1139 END IF;
1140
1141 UPDATE igs_ad_reladdr_int_all
1142 SET error_code = 'E407', status = '3'
1143 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1144 l_Check:='TRUE';
1145 RETURN;
1146 END IF;
1147
1148 IF reladdr_rec.start_dt IS NOT NULL AND reladdr_rec.end_dt IS NOT NULL THEN
1149 IF reladdr_rec.start_dt > reladdr_rec.end_dt THEN
1150 IF l_enable_log = 'Y' THEN
1151 igs_ad_imp_001.logerrormessage( reladdr_rec.interface_reladdr_id,'E406','IGS_AD_RELADDR_INT_ALL');
1152 END IF;
1153
1154 UPDATE igs_ad_reladdr_int_all
1155 SET error_code = 'E406', status = '3'
1156 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1157
1158 l_Check:='TRUE';
1159 RETURN;
1160 END IF;
1161 END IF;
1162
1163 OPEN birth_date_cur(p_rel_person_id);
1164 FETCH birth_date_cur INTO l_birth_date;
1165 CLOSE birth_date_cur;
1166
1167 -- start date must be greater than birth date
1168 IF l_birth_date IS NOT NULL THEN
1169 IF reladdr_rec.start_dt < l_birth_date THEN
1170 IF l_enable_log = 'Y' THEN
1171 igs_ad_imp_001.logerrormessage( reladdr_rec.interface_reladdr_id,'E222','IGS_AD_RELADDR_INT_ALL');
1172 END IF;
1173 UPDATE igs_ad_reladdr_int_all
1174 SET error_code = 'E222', status = '3'
1175 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1176 l_check := 'TRUE';
1177 RETURN;
1178 END IF;
1179 END IF;
1180
1181 l_Check:='FALSE';
1182
1183 END validate_reladdr;
1184 -- end of local procedure validate address
1185
1186 BEGIN
1187 p_api_version := 1.0;
1188 l_Status := '3';
1189 l_Check := 'FALSE';
1190 l_Error_Code := 'E008';
1191 l_prog_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr';
1192 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.';
1193 l_enable_log := igs_ad_imp_001.g_enable_log;
1194 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
1195
1196 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
1197 IF (l_request_id IS NULL) THEN
1198 l_request_id := fnd_global.conc_request_id;
1199 END IF;
1200
1201 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.begin';
1202 l_debug_str := 'Igs_Ad_Imp_008.crt_rel_adr.begin';
1203
1204 fnd_log.string_with_context( fnd_log.level_procedure,
1205 l_label,
1206 l_debug_str, NULL,
1207 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1208 );
1209 END IF;
1210
1211 l_rule := Igs_Ad_Imp_001.Find_Source_Cat_Rule(p_source_type_id,'RELATIONS_ADDRESS');
1212 --1. If rule is E or I, then if the match_ind is not null, the combination is invalid
1213 IF l_rule IN ('E','I') THEN
1214 UPDATE Igs_Ad_RelAddr_Int_all
1215 SET status = '3',
1216 ERROR_CODE = 'E695' -- Error code depicting incorrect combination
1217 WHERE match_ind IS NOT NULL
1218 AND status = '2'
1219 AND interface_relations_id = p_interface_relations_id;
1220 END IF;
1221
1222 --2. If rule is E and duplicate exists, update match_ind to 19 and status to 1
1223 IF l_rule = 'E' THEN
1224 UPDATE Igs_Ad_RelAddr_Int_all mi
1225 SET status = '1',
1226 match_ind = '19'
1227 WHERE mi.interface_relations_id = p_interface_relations_id
1228 AND mi.status = '2'
1229 AND EXISTS ( SELECT 1
1230 FROM hz_locations pe, hz_party_sites ps
1231 WHERE ps.party_id = P_Rel_Person_Id
1232 AND ps.location_id = pe.location_id
1233 AND UPPER(pe.address1) = UPPER(mi.addr_line_1)
1234 AND UPPER(NVL(pe.address2,'NulL')) = UPPER(NVL(mi.addr_line_2,'NulL'))
1235 AND UPPER(NVL(pe.address3,'NulL')) = UPPER(NVL(mi.addr_line_3,'NulL'))
1236 AND UPPER(NVL(pe.address4,'NulL')) = UPPER(NVL(mi.addr_line_4,'NulL'))
1237 AND pe.country = UPPER(mi.country)
1238 AND UPPER(NVL(pe.county,'NulL')) = UPPER(NVL(mi.county,'NulL'))
1239 AND UPPER(NVL(mi.province,'NulL')) = UPPER(NVL(pe.province,'NulL'))
1240 AND UPPER(NVL(mi.city,'NulL')) = UPPER(NVL(pe.city,'NulL'))
1241 AND UPPER(NVL(mi.state,'NulL')) = UPPER(NVL(pe.state,'NulL'))
1242 );
1243 END IF;
1244
1245 --3. If rule is R and there match_ind is 18,19,22 or 23 then the records must have been
1246 -- processed in prior runs and didn't get updated .. update to status 1
1247 IF l_rule = 'R' THEN
1248 UPDATE Igs_Ad_RelAddr_Int_all
1249 SET status = '1'
1250 WHERE interface_relations_id = p_interface_relations_id
1251 AND match_ind IN ('18','19','22','23')
1252 AND status = '2';
1253 END IF;
1254
1255 --4. If rule is R and match_ind is neither 21 nor 25 then error
1256 IF l_rule = 'R' THEN
1257 UPDATE Igs_Ad_RelAddr_Int_all
1258 SET status = '3',
1259 ERROR_CODE = 'E695'
1260 WHERE interface_relations_id = p_interface_relations_id
1261 AND status = 2
1262 AND (match_ind IS NOT NULL AND match_ind NOT IN ('21','25'));
1263 END IF;
1264
1265 --5. If rule is R, set duplicated records with no discrepancy to status 1 and match_ind 23
1266 IF l_rule = 'R' THEN
1267 UPDATE Igs_Ad_RelAddr_Int_all mi
1268 SET status = '1',
1269 match_ind = '23'
1270 WHERE mi.interface_relations_id = p_interface_relations_id
1271 AND mi.match_ind IS NULL
1272 AND mi.status = '2'
1273 AND EXISTS ( SELECT 1
1274 FROM igs_pe_addr_v pe
1275 WHERE UPPER(mi.addr_line_1) = UPPER(pe.addr_line_1)
1276 AND NVL(UPPER(mi.addr_line_2),'NulL') = NVL(UPPER(pe.addr_line_2),'NulL')
1277 AND NVL(UPPER(mi.addr_line_3),'NulL') = NVL(UPPER(pe.addr_line_3),'NulL')
1278 AND NVL(UPPER(mi.addr_line_4),'NulL') = NVL(UPPER(pe.addr_line_4),'NulL')
1279 AND UPPER(mi.country) = UPPER(pe.country_cd)
1280 AND NVL(UPPER(mi.county),'NulL') = NVL(UPPER(pe.county),'NulL')
1281 AND NVL(UPPER(mi.province),'NulL') = NVL(UPPER(pe.province),'NulL')
1282 AND NVL(UPPER(mi.city),'NulL') = NVL(UPPER(pe.city),'NulL')
1283 AND NVL(UPPER(mi.state),'NulL') = NVL(UPPER(pe.state),'NulL')
1284 AND NVL(TRUNC(mi.start_dt),IGS_GE_DATE.igsdate('4712/12/31')) = NVL(TRUNC(pe.start_dt),IGS_GE_DATE.igsdate('4712/12/31'))
1285 AND NVL(TRUNC(mi.end_dt),IGS_GE_DATE.igsdate('4712/12/31')) = NVL(TRUNC(pe.end_dt),IGS_GE_DATE.igsdate('4712/12/31'))
1286 AND NVL(UPPER(mi.correspondence),'N') = NVL(UPPER(pe.correspondence),'N')
1287 AND NVL(UPPER(mi.postal_code),'NulL') = NVL(UPPER(pe.postal_code),'NulL')
1288 AND NVL(UPPER(mi.other_details_1),'NulL') = NVL(UPPER(pe.other_details_1),'NulL')
1289 AND NVL(UPPER(mi.other_details_2),'NulL') = NVL(UPPER(pe.other_details_2),'NulL')
1290 AND NVL(UPPER(mi.other_details_3),'NulL') = NVL(UPPER(pe.other_details_3),'NulL')
1291 AND pe.person_id = P_Rel_Person_Id
1292 );
1293 END IF;
1294
1295 --6. If rule is R records still exist, they are duplicates and have discrepancy .. update status=3,match_ind=20
1296 IF l_rule = 'R' THEN
1297 UPDATE Igs_Ad_RelAddr_Int_all mi
1298 SET status = '3',
1299 match_ind = '20'
1300 WHERE mi.interface_relations_id = p_interface_relations_id
1301 AND mi.match_ind IS NULL
1302 AND mi.status = '2'
1303 AND EXISTS (SELECT 1
1304 FROM hz_locations pe, hz_party_sites ps
1305 WHERE ps.party_id = P_Rel_Person_Id
1306 AND ps.location_id = pe.location_id
1307 AND UPPER(pe.address1) = UPPER(mi.addr_line_1)
1308 AND UPPER(NVL(pe.address2,'NulL')) = UPPER(NVL(mi.addr_line_2,'NulL'))
1309 AND UPPER(NVL(pe.address3,'NulL')) = UPPER(NVL(mi.addr_line_3,'NulL'))
1310 AND UPPER(NVL(pe.address4,'NulL')) = UPPER(NVL(mi.addr_line_4,'NulL'))
1311 AND pe.country = UPPER(mi.country)
1312 AND UPPER(NVL(pe.county,'NulL')) = UPPER(NVL(mi.county,'NulL'))
1313 AND UPPER(NVL(mi.province,'NulL')) = UPPER(NVL(pe.province,'NulL'))
1314 AND UPPER(NVL(mi.city,'NulL')) = UPPER(NVL(pe.city,'NulL'))
1315 AND UPPER(NVL(mi.state,'NulL')) = UPPER(NVL(pe.state,'NulL'))
1316 );
1317 END IF;
1318
1319 FOR reladdr_rec IN reladdr_rec_c(p_Interface_Relations_Id) LOOP
1320 reladdr_rec.site_use_code_1 := UPPER(reladdr_rec.site_use_code_1);
1321 reladdr_rec.site_use_code_2 := UPPER(reladdr_rec.site_use_code_2);
1322 reladdr_rec.country := UPPER(reladdr_rec.country);
1323 l_check := 'FALSE';
1324 Validate_reladdr (reladdr_rec , p_rel_person_id , l_Check );
1325
1326 IF l_Check = 'FALSE' THEN
1327 --3. Validate to see if this address already exist for this person.
1328 OPEN addr_c(reladdr_rec.addr_line_1,
1329 reladdr_rec.addr_line_2,
1330 reladdr_rec.addr_line_3,
1331 reladdr_rec.addr_line_4,
1332 reladdr_rec.country,
1333 reladdr_rec.county,
1334 reladdr_rec.province,
1335 reladdr_rec.city,
1336 reladdr_rec.state,
1337 P_Rel_Person_Id
1338 );
1339 FETCH addr_c INTO addr_rec;
1340
1341 IF addr_c%FOUND THEN
1342 --4. IF the address already exist for this person THEN
1343 l_last_update_date := addr_rec.last_update_date;
1344 IF l_rule = 'I' THEN
1345 Update_Addr(addr_rec , reladdr_rec , p_rel_person_id);
1346 ELSIF l_rule = 'R' THEN
1347 IF reladdr_rec.match_ind = '21' THEN
1348 Update_Addr(addr_rec , reladdr_rec , p_rel_person_id);
1349 END IF; -- match_ind=21
1350 END IF; -- rule =R
1351 ELSE -- no duplicate addr_c%FOUND
1352 DECLARE
1353 l_flag_check_status VARCHAR2(1) := 'Y';
1354 l_addr_warning VARCHAR2(1) := 'N';
1355 BEGIN
1356 --Create the person address.
1357 IGS_PE_PERSON_ADDR_PKG.INSERT_ROW (
1358 p_action => NULL,
1359 p_rowid => l_row_id,
1360 p_location_id => l_location_id,
1361 p_start_dt => reladdr_rec.start_dt,
1362 p_end_dt => reladdr_rec.end_dt,
1363 p_country => reladdr_rec.country,
1364 p_address_style => NULL,
1365 p_addr_line_1 => reladdr_rec.addr_line_1,
1366 p_addr_line_2 => reladdr_rec.addr_line_2,
1367 p_addr_line_3 => reladdr_rec.addr_line_3,
1368 p_addr_line_4 => reladdr_rec.addr_line_4,
1369 p_date_last_verified => NULL,
1370 p_correspondence => NVL(reladdr_rec.correspondence,'N'),
1371 p_city => reladdr_rec.city,
1372 p_state => reladdr_rec.state,
1373 p_province => reladdr_rec.province,
1374 p_county => reladdr_rec.county,
1375 p_postal_code => reladdr_rec.postal_code,
1376 p_address_lines_phonetic => NULL,
1377 p_delivery_point_code => NULL,
1378 p_other_details_1 => reladdr_rec.other_details_1,
1379 p_other_details_2 => reladdr_rec.other_details_2,
1380 p_other_details_3 => reladdr_rec.other_details_3,
1381 l_return_status => l_return_status,
1382 l_msg_data => l_msg_data,
1383 p_party_id => p_rel_person_id,
1384 p_party_site_id => l_party_site_id,
1385 p_party_type => NULL,
1386 p_last_update_date => l_last_update_date,
1387 p_party_site_ovn => l_party_site_ovn,
1388 p_location_ovn => l_location_ovn,
1389 p_status => 'A'
1390 );
1391
1392
1393 IF l_return_status IN ('E','U') THEN
1394 l_flag_check_status := 'N';
1395 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
1396 IF (l_request_id IS NULL) THEN
1397 l_request_id := fnd_global.conc_request_id;
1398 END IF;
1399 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.exception1 '||'E322';
1400 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
1401 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
1402 fnd_message.set_token('ERROR_CD','E322');
1403 l_debug_str := fnd_message.get || ' ' || l_msg_data;
1404 fnd_log.string_with_context( fnd_log.level_exception,
1405 l_label,
1406 l_debug_str, NULL,
1407 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1408 );
1409 END IF;
1410
1411 IF l_enable_log = 'Y' THEN
1412 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E322','IGS_AD_RELADDR_INT_ALL');
1413 END IF;
1414 UPDATE Igs_Ad_RelAddr_Int_all
1415 SET Error_Code = 'E322',
1416 Status = '3'
1417 WHERE INTERFACE_RELADDR_ID = reladdr_rec.INTERFACE_RELADDR_ID;
1418 ELSIF l_return_status = 'W' THEN
1419 l_addr_warning := 'Y';
1420 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
1421 IF (l_request_id IS NULL) THEN
1422 l_request_id := fnd_global.conc_request_id;
1423 END IF;
1424 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.warning '||'E073';
1425 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
1426 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
1427 fnd_message.set_token('ERROR_CD','E073');
1428 l_debug_str := fnd_message.get || ' ' || l_msg_data;
1429 fnd_log.string_with_context( fnd_log.level_exception,
1430 l_label,
1431 l_debug_str, NULL,
1432 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1433 );
1434 END IF;
1435
1436 IF l_enable_log = 'Y' THEN
1437 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E073','IGS_AD_RELADDR_INT_ALL');
1438 END IF;
1439 UPDATE Igs_Ad_RelAddr_Int_all
1440 SET Error_Code = 'E073',
1441 Status = '4'
1442 WHERE INTERFACE_RELADDR_ID = reladdr_rec.INTERFACE_RELADDR_ID;
1443
1444 END IF;
1445
1446 -- code to create part site use if site use code1 is not null
1447 IF (reladdr_rec.site_use_code_1 IS NOT NULL) AND l_flag_check_status = 'Y' THEN
1448 l_party_site_use_id := NULL;
1449 l_object_version_number := NULL;
1450 IGS_PE_PARTY_SITE_USE_PKG.HZ_PARTY_SITE_USES_AK(
1451 p_action => 'INSERT',
1452 p_rowid => l_row_id,
1453 p_party_site_use_id => l_party_site_use_id,
1454 p_party_site_id => l_party_site_id,
1455 p_site_use_type => reladdr_rec.site_use_code_1,
1456 p_status => 'A',
1457 p_return_status => l_return_status,
1458 p_msg_data => l_msg_data,
1459 p_last_update_date => l_last_update_date,
1460 p_site_use_last_update_date => l_site_use_last_update_date,
1461 P_profile_last_update_date => l_profile_last_update_date,
1462 p_hz_party_site_use_ovn => l_object_version_number
1463 );
1464
1465 IF l_return_status IN ('E','U') THEN
1466 l_flag_check_status := 'N';
1467 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
1468 IF (l_request_id IS NULL) THEN
1469 l_request_id := fnd_global.conc_request_id;
1470 END IF;
1471 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.exception2 '||'E322';
1472 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
1473 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
1474 fnd_message.set_token('ERROR_CD','E322');
1475 l_debug_str := fnd_message.get || ' ' || l_msg_data;
1476 fnd_log.string_with_context( fnd_log.level_exception,
1477 l_label,
1478 l_debug_str, NULL,
1479 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1480 );
1481 END IF;
1482 IF l_enable_log = 'Y' THEN
1483 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E322','IGS_AD_RELADDR_INT_ALL');
1484 END IF;
1485 UPDATE Igs_Ad_RelAddr_Int_all
1486 SET Error_Code = 'E322',
1487 Status = '3'
1488 WHERE INTERFACE_RELADDR_ID = reladdr_rec.INTERFACE_RELADDR_ID;
1489 END IF;
1490 END IF;
1491 -- code to create part site use if site use code2 is not null
1492 IF (reladdr_rec.site_use_code_2 IS NOT NULL) AND l_flag_check_status = 'Y' THEN
1493 l_party_site_use_id := NULL;
1494 l_object_version_number := NULL;
1495 IGS_PE_PARTY_SITE_USE_PKG.HZ_PARTY_SITE_USES_AK(
1496 p_action => 'INSERT',
1497 p_rowid => l_row_id,
1498 p_party_site_use_id => l_party_site_use_id,
1499 p_party_site_id => l_party_site_id,
1500 p_site_use_type => reladdr_rec.site_use_code_2,
1501 p_status => 'A',
1502 p_return_status => l_return_status,
1503 p_msg_data => l_msg_data,
1504 p_last_update_date => l_last_update_date,
1505 p_site_use_last_update_date => l_site_use_last_update_date,
1506 P_profile_last_update_date => l_profile_last_update_date,
1507 p_hz_party_site_use_ovn => l_object_version_number
1508 );
1509
1510 IF l_return_status IN ('E','U') THEN
1511 l_flag_check_status := 'N';
1512
1513 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
1514 IF (l_request_id IS NULL) THEN
1515 l_request_id := fnd_global.conc_request_id;
1516 END IF;
1517
1518 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.exception '||'E244';
1519
1520 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
1521 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
1522 fnd_message.set_token('ERROR_CD','E244');
1523
1524 l_debug_str := fnd_message.get || ' ' || l_msg_data;
1525
1526 fnd_log.string_with_context( fnd_log.level_exception,
1527 l_label,
1528 l_debug_str, NULL,
1529 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1530 );
1531 END IF;
1532
1533 IF l_enable_log = 'Y' THEN
1534 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E244','IGS_AD_RELADDR_INT_ALL');
1535 END IF;
1536
1537 UPDATE Igs_Ad_RelAddr_Int_all
1538 SET Error_Code = 'E244',
1539 Status = '3'
1540 WHERE INTERFACE_RELADDR_ID = reladdr_rec.INTERFACE_RELADDR_ID;
1541 END IF;
1542 END IF;
1543
1544 IF l_flag_check_status = 'Y' AND l_addr_warning = 'N' THEN
1545 UPDATE igs_ad_reladdr_int_all
1546 SET error_code = NULL,
1547 status = '1'
1548 WHERE interface_reladdr_id = reladdr_rec.interface_reladdr_id;
1549
1550 l_addr_process := TRUE;
1551 END IF;
1552 EXCEPTION
1553 WHEN OTHERS THEN
1554 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
1555 IF (l_request_id IS NULL) THEN
1556 l_request_id := fnd_global.conc_request_id;
1557 END IF;
1558
1559 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_adr.exception '||'E518';
1560
1561 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
1562 fnd_message.set_token('INTERFACE_ID',reladdr_rec.interface_reladdr_id);
1563 fnd_message.set_token('ERROR_CD','E518');
1564
1565 l_debug_str := fnd_message.get || ' ' || SQLERRM;
1566
1567 fnd_log.string_with_context( fnd_log.level_exception,
1568 l_label,
1569 l_debug_str, NULL,
1570 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
1571 );
1572 END IF;
1573
1574 IF l_enable_log = 'Y' THEN
1575 igs_ad_imp_001.logerrormessage(reladdr_rec.interface_reladdr_id,'E518','IGS_AD_RELADDR_INT_ALL');
1576 END IF;
1577
1578 UPDATE Igs_Ad_RelAddr_Int_all
1579 SET Error_Code = 'E518',
1580 Status = '3'
1581 WHERE Interface_Reladdr_Id = reladdr_rec.Interface_Reladdr_Id;
1582 END;
1583 END IF; -- c_addr
1584 CLOSE addr_c;
1585 END IF; -- l_check
1586 END LOOP;
1587
1588 IF (l_addr_process) THEN
1589 --populate IGS_PE_WF_GEN.TI_ADDR_CHG_PERSONS table with party id to generate notification at the end of process
1590 IGS_PE_WF_GEN.TI_ADDR_CHG_PERSONS(NVL(IGS_PE_WF_GEN.TI_ADDR_CHG_PERSONS.LAST,0)+1) := p_rel_person_id;
1591 END IF;
1592
1593 END crt_rel_adr;
1594
1595
1596 PROCEDURE prc_rel_con_dtl (p_interface_relations_id NUMBER,
1597 p_rel_person_id NUMBER,
1598 p_source_type_id NUMBER) AS
1599
1600 l_prog_label VARCHAR2(100);
1601 l_label VARCHAR2(100);
1602 l_debug_str VARCHAR2(2000);
1603 l_enable_log VARCHAR2(1);
1604 l_request_id NUMBER;
1605 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
1606
1607 --1. Pick up all the records from the table IGS_AD_REL_CON_INT.
1608 CURSOR relcon_rec_c(cp_interface_relations_id NUMBER) IS
1609 SELECT *
1610 FROM igs_ad_rel_con_int_all
1611 WHERE status = '2'
1612 AND interface_relations_id = cp_interface_relations_id;
1613
1614 --2. The duplicate check in the table HZ_CONTACT_POINTS.
1615 CURSOR rel_cont_del_dup_rec_c
1616 (
1617 p_contact_point_type igs_ad_rel_con_int.contact_point_type%TYPE,
1618 p_email_format igs_ad_rel_con_int.email_format%TYPE,
1619 p_email_address igs_ad_rel_con_int.email_addrress%TYPE,
1620 p_phone_line_type igs_ad_rel_con_int.phone_line_type%TYPE,
1621 p_phone_country_code igs_ad_rel_con_int.phone_country_code%TYPE,
1622 p_phone_area_code igs_ad_rel_con_int.phone_area_code%TYPE,
1623 p_phone_number igs_ad_rel_con_int.phone_number%TYPE
1624 ) IS
1625 SELECT contact_point_id,
1626 primary_flag ,
1627 email_format ,
1628 phone_country_code ,
1629 phone_line_type ,
1630 phone_area_code ,
1631 phone_number ,
1632 phone_extension
1633 FROM hz_contact_points
1634 WHERE owner_table_id = p_rel_person_id
1635 AND contact_point_type = p_contact_point_type
1636 AND owner_table_name = 'HZ_PARTIES'
1637 AND (( nvl(email_format,'NulL') = nvl(p_email_format,'NulL') AND
1638 UPPER(nvl(email_address,'NulL')) = UPPER(nvl(p_email_address,'NulL')) AND
1639 contact_point_type = 'EMAIL' )OR
1640 ( nvl(phone_line_type,'NulL') = nvl(p_phone_line_type,'NulL') AND
1641 nvl(phone_country_code,'NulL') = nvl(p_phone_country_code,'NulL') AND
1642 UPPER(nvl(phone_area_code,'NulL')) = UPPER(nvl(p_phone_area_code,'NulL')) AND
1643 nvl(phone_number,'NulL') = nvl(p_phone_number,'NulL') AND
1644 contact_point_type = 'PHONE' ));
1645
1646 rel_cont_del_dup_rec rel_cont_del_dup_rec_c%ROWTYPE;
1647
1648 --Check for discrepancy in data for all the columns in the table
1649 --HZ_CONTACT_POINTS excepting the Primary Key Columns.
1650
1651
1652 CURSOR get_obj_version(c_contact_point_id NUMBER) IS
1653 SELECT object_version_number
1654 FROM hz_contact_points
1655 WHERE contact_point_id = c_contact_point_id;
1656
1657 l_obj_ver hz_contact_points.object_version_number%TYPE;
1658
1659 l_return_status IGS_AD_RELATIONS_INT.STATUS%TYPE;
1660 l_msg_count NUMBER;
1661 l_msg_data VARCHAR2(2000);
1662 l_Count NUMBER;
1663 l_Status IGS_AD_RELATIONS_INT.STATUS%TYPE;
1664 l_Error_Code IGS_AD_RELATIONS_INT.Error_Code%TYPE;
1665 l_rule igs_ad_source_cat.discrepancy_rule_cd%TYPE;
1666
1667 contact_point_rec HZ_CONTACT_POINT_V2PUB.contact_point_rec_type;
1668 email_rec HZ_CONTACT_POINT_V2PUB.email_rec_type;
1669 phone_rec HZ_CONTACT_POINT_V2PUB.phone_rec_type;
1670 l_telex_rec HZ_CONTACT_POINT_V2PUB.telex_rec_type;
1671 l_web_rec HZ_CONTACT_POINT_V2PUB.web_rec_type;
1672 l_edi_rec HZ_CONTACT_POINT_V2PUB.edi_rec_type;
1673 l_last_update_date DATE;
1674 l_check VARCHAR2(30);
1675
1676 tmp_var1 VARCHAR2(2000);
1677 tmp_var VARCHAR2(2000);
1678 -- Start Of Local Procedure prc_rel_con.
1679 PROCEDURE prc_rel_con (p_rel_con_rec relcon_rec_c%ROWTYPE) AS
1680
1681 l_return_status igs_ad_relations_int.status%TYPE;
1682 l_msg_count NUMBER;
1683 l_msg_data VARCHAR2(2000);
1684 l_Status igs_ad_relations_int.status%TYPE;
1685 l_Error_Code igs_ad_relations_int.error_code%TYPE;
1686 contact_point_rec HZ_CONTACT_POINT_V2PUB.contact_point_rec_type;
1687 email_rec HZ_CONTACT_POINT_V2PUB.email_rec_type;
1688 phone_rec HZ_CONTACT_POINT_V2PUB.phone_rec_type;
1689 l_telex_rec HZ_CONTACT_POINT_V2PUB.telex_rec_type;
1690 l_web_rec HZ_CONTACT_POINT_V2PUB.web_rec_type;
1691 l_edi_rec HZ_CONTACT_POINT_V2PUB.edi_rec_type;
1692 ln_Error_Code NUMBER;
1693 l_last_update_date DATE;
1694
1695 tmp_var1 VARCHAR2(2000);
1696 tmp_var VARCHAR2(2000);
1697 l_contact_point_id NUMBER;
1698 l_dummy VARCHAR2(1);
1699
1700 BEGIN
1701
1702 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
1703
1704 IF (l_request_id IS NULL) THEN
1705 l_request_id := fnd_global.conc_request_id;
1706 END IF;
1707
1708 l_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl.begin_prc_rel_con';
1709 l_debug_str := 'Igs_Ad_Imp_008.prc_rel_con_dtl.prc_rel_con';
1710
1711 fnd_log.string_with_context( fnd_log.level_procedure,
1712 l_label,
1713 l_debug_str, NULL,
1714 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
1715 END IF;
1716
1717 --5. if the validation is successful then, insert this record into the table hz_contact_points.
1718 --items in the record p_contact_point_rec
1719 contact_point_rec.contact_point_type := p_rel_con_rec.contact_point_type;
1720 -- contact_point_rec.status := p_rel_con_rec.status; ssomani, these two statuses are different 15 March 2001
1721 contact_point_rec.owner_table_name := 'HZ_PARTIES';
1722 contact_point_rec.primary_flag := NVL(p_rel_con_rec.primary_flag,'N');
1723 contact_point_rec.content_source_type := 'USER_ENTERED';
1724 contact_point_rec.created_by_module := 'IGS';
1725 contact_point_rec.owner_table_id := p_rel_person_id ; --ssomani, added this 15 March 2001
1726
1727 --items in the record p_email_rec
1728 IF p_rel_con_rec.contact_point_type = 'EMAIL' THEN
1729 email_rec.email_format := p_rel_con_rec.email_format;
1730 email_rec.email_address := p_rel_con_rec.email_addrress;
1731 ELSIF p_rel_con_rec.contact_point_type = 'PHONE' THEN
1732 --items in the record p_phone_rec
1733 phone_rec.phone_country_code := p_rel_con_rec.phone_country_code;
1734 phone_rec.phone_line_type := p_rel_con_rec.phone_line_type;
1735 phone_rec.phone_area_code := p_rel_con_rec.phone_area_code;
1736 phone_rec.phone_number := p_rel_con_rec.phone_number;
1737 phone_rec.phone_extension := p_rel_con_rec.phone_extension;
1738 END IF;
1739 HZ_CONTACT_POINT_V2PUB.create_contact_point(
1740 p_init_msg_list => FND_API.G_FALSE,
1741 p_contact_point_rec => contact_point_rec,
1742 p_edi_rec => l_edi_rec,
1743 p_email_rec => email_rec,
1744 p_phone_rec => phone_rec,
1745 p_telex_rec => l_telex_rec,
1746 p_web_rec => l_web_rec,
1747 x_return_status => l_return_status,
1748 x_msg_count => l_msg_count,
1749 x_msg_data => l_msg_data,
1750 x_contact_point_id => l_contact_point_id);
1751 IF l_return_status IN ( 'E' , 'U' ) THEN
1752 IF l_msg_count > 1 THEN
1753 FOR i IN 1..l_msg_count LOOP
1754 tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
1755 tmp_var1 := tmp_var1 || ' '|| tmp_var;
1756 END LOOP;
1757 l_msg_data := tmp_var1;
1758 END IF;
1759
1760 ln_Error_Code := 'E322';
1761
1762 IF l_enable_log = 'Y' THEN
1763 igs_ad_imp_001.logerrormessage(p_rel_con_rec.interface_rel_con_id,'E322','IGS_AD_REL_CON_INT_ALL');
1764 END IF;
1765
1766 UPDATE igs_ad_rel_con_int_all
1767 SET error_code = ln_Error_Code, --error code for the insert failure
1768 status = '3'
1769 WHERE interface_rel_con_id = p_rel_con_rec.interface_rel_con_id;
1770
1771 ELSE
1772 UPDATE igs_ad_rel_con_int_all
1773 SET status = '1'
1774 WHERE interface_rel_con_id = p_rel_con_rec.interface_rel_con_id;
1775 END IF;
1776 END prc_rel_con;
1777 -- End Of Local Procedure prc_rel_con.
1778 -- Start ol Local Procedure validate contact
1779 PROCEDURE Validate_Contact(relcon_rec relcon_rec_c%ROWTYPE,l_Check OUT NOCOPY VARCHAR2 ) AS
1780
1781 -- 4. phone country code is now to be validated against
1782 -- HZ_PHONE_COUNTRY_CODEs : HZ F validations -- ssawhney bug 2203778
1783 CURSOR c_ph_cntry_cd (p_phone_country_code VARCHAR2) IS
1784 SELECT 'X'
1785 FROM HZ_PHONE_COUNTRY_CODES
1786 WHERE PHONE_COUNTRY_CODE = p_phone_country_code;
1787 l_dummy VARCHAR2(1);
1788 BEGIN
1789
1790 -- Validate contact point type
1791 IF NOT
1792 (igs_pe_pers_imp_001.validate_lookup_type_code('COMMUNICATION_TYPE',relcon_rec.contact_point_type,222))
1793 THEN
1794 -- If the validation is not successful.
1795
1796 IF l_enable_log = 'Y' THEN
1797 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E246','IGS_AD_REL_CON_INT_ALL');
1798 END IF;
1799
1800 UPDATE igs_ad_rel_con_int_all
1801 SET status = '3',
1802 error_code = 'E246'
1803 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1804 l_Check := 'TRUE';
1805 RETURN;
1806 END IF;
1807
1808 IF relcon_rec.primary_flag IS NOT NULL THEN
1809 IF relcon_rec.primary_flag NOT IN ('N','Y') THEN
1810
1811 IF l_enable_log = 'Y' THEN
1812 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E450','IGS_AD_REL_CON_INT_ALL');
1813 END IF;
1814
1815 UPDATE igs_ad_rel_con_int_all
1816 SET error_code = 'E450',
1817 status = '3'
1818 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1819 l_Check := 'TRUE';
1820 RETURN;
1821 END IF;
1822 END IF;
1823
1824 IF relcon_rec.contact_point_type = 'PHONE' THEN
1825 -- Validation to check whether phone line type or phone number are null
1826 IF relcon_rec.phone_number IS NULL OR relcon_rec.phone_line_type IS NULL THEN
1827
1828 IF l_enable_log = 'Y' THEN
1829 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E250','IGS_AD_REL_CON_INT_ALL');
1830 END IF;
1831
1832 UPDATE igs_ad_rel_con_int_all
1833 SET error_code = 'E250',
1834 status = '3'
1835 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1836 l_Check := 'TRUE';
1837 RETURN;
1838 END IF;
1839
1840 -- Validate the PHONE_LINE_TYPE
1841 IF NOT
1842 (igs_pe_pers_imp_001.validate_lookup_type_code('PHONE_LINE_TYPE',relcon_rec.phone_line_type,222))
1843 THEN
1844 -- If the validation is not successful.
1845
1846
1847 IF l_enable_log = 'Y' THEN
1848 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E247','IGS_AD_REL_CON_INT_ALL');
1849 END IF;
1850
1851 UPDATE igs_ad_rel_con_int_all
1852 SET status = '3',
1853 error_code = 'E247'
1854 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1855 l_Check := 'TRUE';
1856 RETURN;
1857 END IF;
1858
1859 -- Validate the PHONE_COUNTRY_CODE
1860 IF relcon_rec.phone_country_code IS NOT NULL THEN
1861 OPEN c_ph_cntry_cd(relcon_rec.phone_country_code);
1862 FETCH c_ph_cntry_cd INTO l_dummy;
1863 IF c_ph_cntry_cd%NOTFOUND THEN
1864 -- If the validation is not successful.
1865
1866 IF l_enable_log = 'Y' THEN
1867 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E173','IGS_AD_REL_CON_INT_ALL');
1868 END IF;
1869
1870 UPDATE igs_ad_rel_con_int_all
1871 SET status = '3',
1872 error_code = 'E173'
1873 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1874 CLOSE c_ph_cntry_cd;
1875 l_Check := 'TRUE';
1876 RETURN;
1877 END IF;
1878 CLOSE c_ph_cntry_cd;
1879 END IF;
1880
1881 END IF;
1882
1883 IF relcon_rec.contact_point_type = 'EMAIL' THEN
1884 -- Validation to check whether email address is null
1885 IF relcon_rec.email_addrress IS NULL THEN
1886
1887 IF l_enable_log = 'Y' THEN
1888 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E251','IGS_AD_REL_CON_INT_ALL');
1889 END IF;
1890
1891 UPDATE igs_ad_rel_con_int_all
1892 SET error_code = 'E251',
1893 status = '3'
1894 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1895 l_Check := 'TRUE';
1896 RETURN;
1897 END IF;
1898
1899 IF NOT
1900 (igs_pe_pers_imp_001.validate_lookup_type_code('EMAIL_FORMAT',relcon_rec.email_format,222))
1901 THEN
1902
1903 IF l_enable_log = 'Y' THEN
1904 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E248','IGS_AD_REL_CON_INT_ALL');
1905 END IF;
1906
1907 UPDATE igs_ad_rel_con_int_all
1908 SET error_code = 'E248',
1909 status = '3'
1910 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
1911 l_Check := 'TRUE';
1912 RETURN;
1913 END IF;
1914 END IF;
1915
1916 l_check := 'FALSE';
1917
1918 END Validate_Contact;
1919 --end olf local procedure validate contact
1920
1921 BEGIN
1922 l_check := 'FALSE';
1923 l_Status := '3';
1924 l_Error_Code := 'E008';
1925 l_prog_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl';
1926 l_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl.';
1927 l_enable_log := igs_ad_imp_001.g_enable_log;
1928 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
1929 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
1930
1931 IF (l_request_id IS NULL) THEN
1932 l_request_id := fnd_global.conc_request_id;
1933 END IF;
1934
1935 l_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl.begin';
1936 l_debug_str := 'Igs_Ad_Imp_008.prc_rel_con_dtl';
1937
1938 fnd_log.string_with_context( fnd_log.level_procedure,
1939 l_label,
1940 l_debug_str, NULL,
1941 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
1942 END IF;
1943
1944 l_rule := Igs_Ad_Imp_001.Find_Source_Cat_Rule(p_source_type_id,'RELATIONS_CONTACTS');
1945
1946 --1. If rule is E or I, then if the match_ind is not null, the combination is invalid
1947 IF l_rule IN ('E','I') THEN
1948 UPDATE igs_ad_rel_con_int_all
1949 SET status = '3',
1950 ERROR_CODE = 'E695' -- Error code depicting incorrect combination
1951 WHERE match_ind IS NOT NULL
1952 AND status = '2'
1953 AND interface_relations_id = p_interface_relations_id;
1954 END IF;
1955
1956 --2. If rule is E and duplicate exists, update match_ind to 19 and status to 1
1957 IF l_rule = 'E' THEN
1958 UPDATE igs_ad_rel_con_int_all mi
1959 SET status = '1',
1960 match_ind = '19'
1961 WHERE mi.interface_relations_id = p_interface_relations_id
1962 AND mi.status = '2'
1963 AND EXISTS ( SELECT '1'
1964 FROM hz_contact_points pe
1965 WHERE pe.owner_table_id = p_rel_person_id
1966 AND pe.contact_point_type = UPPER(mi.contact_point_type)
1967 AND pe.owner_table_name = 'HZ_PARTIES'
1968 AND (pe.contact_point_type = 'EMAIL' AND
1969 (NVL(pe.email_format,'NulL') = NVL(UPPER(mi.email_format),'NulL') AND
1970 UPPER(NVL(pe.email_address,'NulL')) = UPPER(NVL(mi.email_addrress,'NulL'))
1971 ) OR
1972 ( pe.contact_point_type = 'PHONE' AND
1973 NVL(pe.phone_line_type,'NulL') = NVL(UPPER(mi.phone_line_type),'NulL') AND
1974 NVL(pe.phone_country_code,'NulL') = NVL(UPPER(mi.phone_country_code),'NulL') AND
1975 UPPER(NVL(pe.phone_area_code,'NulL')) = UPPER(NVL(mi.phone_area_code,'NulL')) AND
1976 NVL(UPPER(pe.phone_number),'NulL') = NVL(UPPER(mi.phone_number),'NulL')
1977 ))
1978 );
1979 END IF;
1980
1981 --3. If rule is R and there match_ind is 18,19,22 or 23 then the records must have been
1982 -- processed in prior runs and didn't get updated .. update to status 1
1983 IF l_rule = 'R' THEN
1984 UPDATE igs_ad_rel_con_int_all
1985 SET status = '1'
1986 WHERE interface_relations_id = p_interface_relations_id
1987 AND match_ind IN ('18','19','22','23')
1988 AND status = '2';
1989 END IF;
1990
1991 --4 If rule is R and match_ind is neither 21 nor 25 then error
1992 IF l_rule = 'R' THEN
1993 UPDATE igs_ad_rel_con_int_all
1994 SET status = '3',
1995 ERROR_CODE = 'E695'
1996 WHERE interface_relations_id = p_interface_relations_id
1997 AND status = '2'
1998 AND (match_ind IS NOT NULL AND match_ind NOT IN ('21','25'));
1999 END IF;
2000
2001 --5. If rule is R, set duplicated records with no discrepancy to status 1 and match_ind 23
2002 IF l_rule = 'R' THEN
2003 UPDATE igs_ad_rel_con_int_all mi
2004 SET status = '1',
2005 match_ind = '23'
2006 WHERE mi.interface_relations_id = p_interface_relations_id
2007 AND mi.match_ind IS NULL
2008 AND mi.status = '2'
2009 AND EXISTS ( SELECT 1
2010 FROM hz_contact_points pe
2011 WHERE pe.owner_table_id = p_rel_person_id
2012 AND NVL(pe.primary_flag,'N') = NVL(UPPER(mi.primary_flag),'N')
2013 AND NVL(UPPER(pe.phone_extension),'NulL') = NVL(UPPER(mi.phone_extension),'NulL')
2014 AND pe.contact_point_type = UPPER(mi.contact_point_type)
2015 AND NVL(pe.email_format,'NulL') = NVL(UPPER(mi.email_format),'NulL')
2016 AND NVL(pe.phone_line_type,'NulL') = NVL(UPPER(mi.phone_line_type),'NulL')
2017 AND NVL(pe.phone_country_code,'NulL') = NVL(UPPER(mi.phone_country_code),'NulL')
2018 AND NVL(UPPER(pe.phone_area_code),'NulL') = NVL(UPPER(mi.phone_area_code),'NulL')
2019 AND NVL(UPPER(pe.phone_number),'NulL') = NVL(UPPER(mi.phone_number),'NulL')
2020 AND NVL(UPPER(pe.email_address),'NulL') = NVL(UPPER(mi.email_addrress),'NulL')
2021 );
2022 END IF;
2023
2024 --6. If rule is R records still exist, they are duplicates and have discrepancy .. update status=3,match_ind=20
2025 IF l_rule = 'R' THEN
2026 UPDATE igs_ad_rel_con_int_all mi
2027 SET status = '3',
2028 match_ind = '20',
2029 DUP_CONTACT_POINT_ID = (SELECT pe.contact_point_id
2030 FROM hz_contact_points pe
2031 WHERE pe.owner_table_id = p_rel_person_id
2032 AND pe.contact_point_type = UPPER(mi.contact_point_type)
2033 AND pe.owner_table_name = 'HZ_PARTIES'
2034 AND ((pe.contact_point_type = 'EMAIL' AND
2035 NVL(pe.email_format,'NulL') = NVL(UPPER(mi.email_format),'NulL') AND
2036 UPPER(NVL(pe.email_address,'NulL')) = UPPER(NVL(mi.email_addrress,'NulL'))
2037 )
2038 OR
2039 (pe.contact_point_type = 'PHONE' AND
2040 NVL(pe.phone_line_type,'NulL') = NVL(UPPER(mi.phone_line_type),'NulL') AND
2041 NVL(pe.phone_country_code,'NulL') = NVL(UPPER(mi.phone_country_code),'NulL') AND
2042 UPPER(NVL(pe.phone_area_code,'NulL')) = UPPER(NVL(mi.phone_area_code,'NulL')) AND
2043 NVL(UPPER(pe.phone_number),'NulL') = NVL(UPPER(mi.phone_number),'NulL')
2044 ))
2045 AND ROWNUM = 1)
2046 WHERE mi.interface_relations_id = p_interface_relations_id
2047 AND mi.match_ind IS NULL
2048 AND mi.status = '2'
2049 AND EXISTS (SELECT '1'
2050 FROM hz_contact_points pe
2051 WHERE pe.owner_table_id = p_rel_person_id
2052 AND pe.contact_point_type = UPPER(mi.contact_point_type)
2053 AND pe.owner_table_name = 'HZ_PARTIES'
2054 AND (pe.contact_point_type = 'EMAIL' AND
2055 (NVL(pe.email_format,'NulL') = NVL(UPPER(mi.email_format),'NulL') AND
2056 UPPER(NVL(pe.email_address,'NulL')) = UPPER(NVL(mi.email_addrress,'NulL'))
2057 )
2058 OR
2059 (pe.contact_point_type = 'PHONE' AND
2060 NVL(pe.phone_line_type,'NulL') = NVL(UPPER(mi.phone_line_type),'NulL') AND
2061 NVL(pe.phone_country_code,'NulL') = NVL(UPPER(mi.phone_country_code),'NulL') AND
2062 UPPER(NVL(pe.phone_area_code,'NulL')) = UPPER(NVL(mi.phone_area_code,'NulL')) AND
2063 NVL(UPPER(pe.phone_number),'NulL') = NVL(UPPER(mi.phone_number),'NulL')
2064 ))
2065 );
2066 END IF;
2067
2068 --1. Pick up all the records from the table IGS_AD_REL_CON_INT.
2069 FOR relcon_rec IN relcon_rec_c(p_interface_relations_id) LOOP
2070 relcon_rec.contact_point_type := UPPER(relcon_rec.contact_point_type);
2071 relcon_rec.phone_line_type := UPPER(relcon_rec.phone_line_type);
2072 relcon_rec.primary_flag := UPPER(relcon_rec.primary_flag);
2073 relcon_rec.email_format := UPPER(relcon_rec.email_format);
2074 l_check := 'FALSE';
2075 Validate_Contact(relcon_rec ,l_Check );
2076 rel_cont_del_dup_rec.contact_point_id := NULL;
2077 IF l_Check = 'FALSE' THEN
2078 OPEN rel_cont_del_dup_rec_c(
2079 relcon_rec.contact_point_type,
2080 relcon_rec.email_format,
2081 relcon_rec.email_addrress,
2082 relcon_rec.phone_line_type,
2083 relcon_rec.phone_country_code,
2084 relcon_rec.phone_area_code,
2085 relcon_rec.phone_number);
2086
2087 FETCH rel_cont_del_dup_rec_c INTO rel_cont_del_dup_rec;
2088 CLOSE rel_cont_del_dup_rec_c;
2089 IF rel_cont_del_dup_rec.contact_point_id IS NOT NULL THEN
2090 IF l_rule = 'I' THEN
2091 --3. If validations are successful then update the HZ_CONTACT_POINTS table.
2092 --items in the record p_contact_point_rec
2093 contact_point_rec.contact_point_type := relcon_rec.contact_point_type;
2094 contact_point_rec.contact_point_id := rel_cont_del_dup_rec.contact_point_id;
2095 -- contact_point_rec.status := relcon_rec.status; --ssomani, unrelated statuses 15 March 2001
2096 contact_point_rec.owner_table_name := 'HZ_PARTIES';
2097 contact_point_rec.primary_flag :=NVL((NVL(relcon_rec.primary_flag,rel_cont_del_dup_rec.primary_flag)),FND_API.G_MISS_CHAR);
2098
2099 -- contact_point_rec.content_source_type := 'USER_ENTERED';
2100 -- contact_point_rec.created_by_module := 'IGS';
2101
2102 IF relcon_rec.contact_point_type = 'EMAIL' THEN
2103 --items in the record p_email_rec
2104 email_rec.email_format := NVL((NVL(relcon_rec.email_format,rel_cont_del_dup_rec.email_format)),FND_API.G_MISS_CHAR);
2105 email_rec.email_address :=NVL((NVL(relcon_rec.email_addrress,rel_cont_del_dup_rec.email_format)),FND_API.G_MISS_CHAR);
2106 ELSIF relcon_rec.contact_point_type = 'PHONE' THEN
2107 --items in the record p_phone_rec
2108 phone_rec.phone_country_code := NVL((NVL(relcon_rec.phone_country_code,rel_cont_del_dup_rec.phone_country_code)),FND_API.G_MISS_CHAR);
2109 phone_rec.phone_line_type := NVL((NVL(relcon_rec.phone_line_type,rel_cont_del_dup_rec.phone_line_type)),FND_API.G_MISS_CHAR);
2110 phone_rec.phone_area_code := NVL((NVL(relcon_rec.phone_area_code,rel_cont_del_dup_rec.phone_area_code)),FND_API.G_MISS_CHAR);
2111 phone_rec.phone_number := NVL((NVL(relcon_rec.phone_number,rel_cont_del_dup_rec.phone_number)),FND_API.G_MISS_CHAR);
2112 phone_rec.phone_extension := NVL((NVL(relcon_rec.phone_extension,rel_cont_del_dup_rec.phone_extension)),FND_API.G_MISS_CHAR);
2113 END IF;
2114
2115 OPEN get_obj_version(rel_cont_del_dup_rec.contact_point_id);
2116 FETCH get_obj_version INTO l_obj_ver;
2117 CLOSE get_obj_version;
2118
2119 --Usage of API HZ_CONTACT_POINT_PUB.update_contact_points
2120 HZ_CONTACT_POINT_V2PUB.update_contact_point(
2121 p_init_msg_list => FND_API.G_FALSE,
2122 p_contact_point_rec => contact_point_rec,
2123 p_email_rec => email_rec ,
2124 p_phone_rec => phone_rec,
2125 p_object_version_number => l_obj_ver,
2126 x_return_status => l_return_status,
2127 x_msg_count => l_msg_count,
2128 x_msg_data => l_msg_data
2129 );
2130
2131
2132
2133 --4. Update the IGS_AD_CONTACTS_INT with the following values
2134 -- If the validation and update is successful.
2135
2136 IF l_return_status NOT IN ('E','U') THEN
2137 UPDATE igs_ad_rel_con_int_all
2138 SET status = '1',
2139 match_ind = '18'
2140 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
2141 ELSE --ssomani added this check 15 March 2001
2142
2143 IF l_msg_count > 1 THEN
2144 FOR i IN 1..l_msg_count LOOP
2145 tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
2146 tmp_var1 := tmp_var1 || ' '|| tmp_var;
2147 END LOOP;
2148 l_msg_data := tmp_var1;
2149 END IF;
2150
2151 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
2152
2153 IF (l_request_id IS NULL) THEN
2154 l_request_id := fnd_global.conc_request_id;
2155 END IF;
2156
2157 l_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl.exception';
2158
2159 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
2160 fnd_message.set_token('INTERFACE_ID',relcon_rec.interface_rel_con_id);
2161 fnd_message.set_token('ERROR_CD','E014');
2162
2163 l_debug_str := fnd_message.get || ' ' || l_msg_data;
2164
2165 fnd_log.string_with_context( fnd_log.level_exception,
2166 l_label,
2167 l_debug_str, NULL,
2168 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
2169 END IF;
2170
2171 IF l_enable_log = 'Y' THEN
2172 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E014','IGS_AD_REL_CON_INT_ALL');
2173 END IF;
2174
2175 UPDATE igs_ad_rel_con_int_all
2176 SET status = '3',
2177 error_code = 'E014'
2178 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
2179 END IF;
2180
2181 ELSIF l_rule = 'R' THEN
2182 IF relcon_rec.match_ind = '21' THEN
2183 --3. If validations are successful then update the HZ_CONTACT_POINTS table.
2184 --items in the record p_contact_point_rec
2185 contact_point_rec.contact_point_type := relcon_rec.contact_point_type;
2186 contact_point_rec.contact_point_id := rel_cont_del_dup_rec.contact_point_id;
2187 -- contact_point_rec.status := relcon_rec.status; --ssomani, unrelated statuses 15 March 2001
2188 contact_point_rec.owner_table_name := 'HZ_PARTIES';
2189 contact_point_rec.primary_flag := NVL((NVL(relcon_rec.primary_flag,rel_cont_del_dup_rec.primary_flag)),FND_API.G_MISS_CHAR);
2190
2191 -- contact_point_rec.content_source_type := 'USER_ENTERED';
2192 -- contact_point_rec.created_by_module := 'IGS';
2193
2194 IF relcon_rec.contact_point_type = 'EMAIL' THEN
2195 --items in the record p_email_rec
2196 email_rec.email_format := NVL((NVL(relcon_rec.email_format,rel_cont_del_dup_rec.email_format)),FND_API.G_MISS_CHAR);
2197 email_rec.email_address :=NVL((NVL(relcon_rec.email_addrress,rel_cont_del_dup_rec.email_format)),FND_API.G_MISS_CHAR);
2198 ELSIF relcon_rec.contact_point_type = 'PHONE' THEN
2199 --items in the record p_phone_rec
2200 phone_rec.phone_country_code :=NVL((NVL(relcon_rec.phone_country_code,rel_cont_del_dup_rec.phone_country_code)),FND_API.G_MISS_CHAR);
2201 phone_rec.phone_line_type := NVL((NVL(relcon_rec.phone_line_type,rel_cont_del_dup_rec.phone_line_type)),FND_API.G_MISS_CHAR);
2202 phone_rec.phone_area_code := NVL((NVL(relcon_rec.phone_area_code,rel_cont_del_dup_rec.phone_area_code)),FND_API.G_MISS_CHAR);
2203 phone_rec.phone_number := NVL((NVL(relcon_rec.phone_number,rel_cont_del_dup_rec.phone_number)),FND_API.G_MISS_CHAR);
2204 phone_rec.phone_extension := NVL((NVL(relcon_rec.phone_extension,rel_cont_del_dup_rec.phone_extension)),FND_API.G_MISS_CHAR);
2205 END IF;
2206
2207 -- SELECT LAST_UPDATE_DATEFROM HZ_CONTACT_POINTSWHERE OWNER_TABLE_ID = contact_point_id
2208 -- returned from duplicate check.
2209
2210 OPEN get_obj_version(rel_cont_del_dup_rec.contact_point_id);
2211 FETCH get_obj_version INTO l_obj_ver;
2212 CLOSE get_obj_version;
2213
2214 --Usage of API HZ_CONTACT_POINT_PUB.update_contact_points
2215 BEGIN --ssomani added BEGIN - EXCEPTION - END Block 15 March 2001
2216
2217 HZ_CONTACT_POINT_V2PUB.update_contact_point(
2218 p_init_msg_list => FND_API.G_FALSE,
2219 p_contact_point_rec => contact_point_rec,
2220 p_email_rec => email_rec ,
2221 p_phone_rec => phone_rec,
2222 p_object_version_number => l_obj_ver,
2223 x_return_status => l_return_status,
2224 x_msg_count => l_msg_count,
2225 x_msg_data => l_msg_data
2226 );
2227
2228 IF l_return_status IN ('E','U') THEN
2229 IF l_msg_count > 1 THEN
2230 FOR i IN 1..l_msg_count LOOP
2231 tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
2232 tmp_var1 := tmp_var1 || ' '|| tmp_var;
2233 END LOOP;
2234 l_msg_data := tmp_var1;
2235 END IF;
2236
2237 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
2238
2239 IF (l_request_id IS NULL) THEN
2240 l_request_id := fnd_global.conc_request_id;
2241 END IF;
2242
2243 l_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl.exception '||'E014';
2244
2245 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
2246 fnd_message.set_token('INTERFACE_ID',relcon_rec.interface_rel_con_id);
2247 fnd_message.set_token('ERROR_CD','E014');
2248
2249 l_debug_str := fnd_message.get || ' ' || l_msg_data;
2250
2251 fnd_log.string_with_context( fnd_log.level_exception,
2252 l_label,
2253 l_debug_str, NULL,
2254 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
2255 END IF;
2256
2257 IF l_enable_log = 'Y' THEN
2258 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E014','IGS_AD_REL_CON_INT_ALL');
2259 END IF;
2260
2261 UPDATE igs_ad_rel_con_int_all
2262 SET status = '3',
2263 ERROR_CODE = 'E014'
2264 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
2265 ELSE
2266 UPDATE igs_ad_rel_con_int_all
2267 SET status = '1',
2268 ERROR_CODE = NULL,
2269 match_ind = '18'
2270 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
2271 END IF;
2272
2273 EXCEPTION
2274 WHEN OTHERS THEN
2275
2276 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
2277
2278 IF (l_request_id IS NULL) THEN
2279 l_request_id := fnd_global.conc_request_id;
2280 END IF;
2281
2282 l_label := 'igs.plsql.igs_ad_imp_008.prc_rel_con_dtl.exception '||'E518';
2283
2284 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
2285 fnd_message.set_token('INTERFACE_ID',relcon_rec.interface_rel_con_id);
2286 fnd_message.set_token('ERROR_CD','E518');
2287
2288 l_debug_str := fnd_message.get || ' ' || SQLERRM;
2289
2290 fnd_log.string_with_context( fnd_log.level_exception,
2291 l_label,
2292 l_debug_str, NULL,
2293 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
2294 END IF;
2295
2296 IF l_enable_log = 'Y' THEN
2297 igs_ad_imp_001.logerrormessage(relcon_rec.interface_rel_con_id,'E518','IGS_AD_REL_CON_INT_ALL');
2298 END IF;
2299
2300 UPDATE igs_ad_rel_con_int_all
2301 SET status = '3',
2302 error_code = 'E518'
2303 WHERE interface_rel_con_id = relcon_rec.interface_rel_con_id;
2304
2305 END;
2306 END IF;
2307 NULL;
2308 END IF;
2309 ELSE -- rel_cont_del_dup_rec_c%FOUND
2310 prc_rel_con(relcon_rec);
2311 END IF; -- rel_cont_del_dup_rec_c%FOUND
2312 END IF;
2313 END LOOP ;
2314 END prc_rel_con_dtl;
2315
2316 PROCEDURE crt_rel_acad_his (P_Interface_Relations_Id NUMBER,
2317 P_Rel_Person_Id NUMBER,
2318 p_source_type_id NUMBER) AS
2319
2320 l_prog_label VARCHAR2(100);
2321 l_label VARCHAR2(100);
2322 l_debug_str VARCHAR2(2000);
2323 l_enable_log VARCHAR2(1);
2324 l_request_id NUMBER;
2325 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
2326
2327 --1. Pick up all the records from the table IGS_AD_RELACAD_INT WHERE STATUS = '2' AND INTERFACE_RELATIONS_ID = P_INTERFACE_RELATIONS_ID
2328 CURSOR Relacad_Rec_C(cp_interface_relations_id NUMBER) IS
2329 SELECT *
2330 FROM Igs_Ad_Relacad_Int_all
2331 WHERE Status = '2'
2332 AND Interface_Relations_Id = cP_Interface_Relations_Id;
2333
2334 -- Check to see if an academic history record already exists for this person
2335 -- Duplicate check changed to ( person_id, institution_code , start_Date, end_date ) Import Process enahancements
2336 CURSOR Academic_His_C(P_Institution_Code Igs_Ad_Relacad_Int.Institution_Code%TYPE,
2337 P_Start_Date Igs_Ad_Relacad_Int.Start_Date%TYPE,
2338 P_Rel_Person_ID NUMBER,
2339 p_end_Date Igs_Ad_Relacad_Int.end_Date%TYPE
2340 ) IS
2341 SELECT *
2342 FROM IGS_AD_ACAD_HISTORY_V a
2343 WHERE a.institution_code = P_Institution_Code
2344 AND ((TRUNC(a.Start_Date) = TRUNC(P_Start_Date)) OR (a.start_date IS NULL AND P_Start_Date IS NULL))
2345 AND ((TRUNC(a.end_Date) = TRUNC(p_end_date)) OR (a.end_date IS NULL AND p_end_date IS NULL))
2346 AND a.person_id = P_Rel_Person_ID;
2347 --Cursor to select the records that are for first record updates.
2348 CURSOR c_Academic_His_first(
2349 cp_Interface_Relacad_Id Igs_Ad_Relacad_Int_all.Interface_Relacad_Id%TYPE,
2350 P_Institution_Code Igs_Ad_Relacad_Int.Institution_Code%TYPE,
2351 P_Start_Date Igs_Ad_Relacad_Int.Start_Date%TYPE,
2352 P_Rel_Person_ID NUMBER,
2353 p_end_Date Igs_Ad_Relacad_Int.end_Date%TYPE
2354 ) IS
2355
2356 SELECT 'X' a
2357 FROM Igs_Ad_Relacad_Int_all a
2358 WHERE Interface_Relacad_Id = cp_Interface_Relacad_Id
2359 AND NVL(p_start_date,p_end_date) IS NOT NULL
2360 AND EXISTS (SELECT 1 FROM hz_Education h1, hz_parties h2
2361 WHERE h1.party_id = P_Rel_Person_ID
2362 AND h2.party_number = p_institution_code
2363 AND h2.party_id = h1.school_party_id
2364 AND h1.start_date_attended IS NULL
2365 AND h1.last_date_attended IS NULL
2366 )
2367 AND NOT EXISTS ( SELECT 1 FROM hz_Education h1, hz_parties h2
2368 WHERE h1.party_id = p_rel_person_id
2369 AND h2.party_number = p_institution_code
2370 AND h2.party_id = h1.school_party_id
2371 AND NVL(h1.start_date_attended,
2372 h1.last_date_attended) IS NOT NULL
2373 );
2374 l_Academic_His_first_Rec c_Academic_His_first%ROWTYPE;
2375
2376 -- This cursor will be opened only if it is not exact match OR this record is not a candidate for first record udpate.
2377 CURSOR c_Academic_His_partial(P_Institution_Code Igs_Ad_Relacad_Int.Institution_Code%TYPE,
2378 P_Start_Date Igs_Ad_Relacad_Int.Start_Date%TYPE,
2379 P_Rel_Person_ID NUMBER,
2380 p_end_Date Igs_Ad_Relacad_Int.end_Date%TYPE
2381 ) IS
2382
2383 SELECT 1 a
2384 FROM hz_Education h1, hz_parties h2
2385 WHERE h1.party_id = P_Rel_Person_ID
2386 AND h2.party_number = p_institution_code
2387 AND h2.party_id = h1.school_party_id
2388 AND NVL(h1.start_date_attended,
2389 h1.last_date_attended) IS NOT NULL;
2390 l_Academic_His_partial c_Academic_His_partial%ROWTYPE;
2391 CURSOR c_dup_cur_first (Relacad_Rec Relacad_Rec_C%ROWTYPE, P_Rel_Person_ID NUMBER ) IS
2392 SELECT ah.rowid, ah.*
2393 FROM igs_ad_acad_history_v ah
2394 WHERE person_id = P_Rel_Person_ID
2395 AND institution_code = Relacad_Rec.institution_code
2396 AND creation_date = ( SELECT min(creation_date) FROM igs_ad_acad_history_v
2397 WHERE person_id = P_Rel_Person_ID
2398 AND institution_code = Relacad_Rec.institution_code);
2399
2400 dup_cur_first_rec c_dup_cur_first%ROWTYPE;
2401
2402
2403
2404 -- AND current_inst = P_current_inst;
2405 -- current_inst is a check box hence should not be part of duplicate check
2406 -- Person ID is added to check whether that person has academic history details.( 16-MAR-2002)
2407
2408 l_Academic_His_Rec Academic_His_C%ROWTYPE;
2409
2410 l_row_id IGS_AD_ACAD_HISTORY_V.ROW_ID%TYPE;--VARCHAR2(30);
2411 l_education_id NUMBER;
2412 l_object_version_number HZ_EDUCATION.OBJECT_VERSION_NUMBER%TYPE;
2413 l_return_status IGS_AD_RELATIONS_INT.STATUS%TYPE;
2414 l_msg_count NUMBER;
2415 l_msg_data VARCHAR2(2000);
2416 l_peron_interest_id NUMBER;
2417 l_Status IGS_AD_RELATIONS_INT.STATUS%TYPE;
2418 l_Error_Code IGS_AD_RELATIONS_INT.Error_Code%TYPE;
2419 l_rule igs_ad_source_cat.discrepancy_rule_cd%TYPE;
2420 l_check VARCHAR2(30);
2421 l_count NUMBER;
2422 l_match_ind VARCHAR2(2);
2423
2424 --Start of local procedure Validate_Acad_Hist
2425 PROCEDURE Validate_Acad_Hist( Relacad_Rec Relacad_Rec_C%ROWTYPE ,l_check OUT NOCOPY VARCHAR2 ) AS
2426
2427 -- Validate the INSTITUTION_CD.
2428 CURSOR Institution_C(cp_Institution_Cd Igs_Ad_Relacad_Int.Institution_Code%TYPE,
2429 cp_inst_status Igs_Or_Inst_Stat.S_Institution_Status%TYPE) IS
2430 SELECT 1
2431 FROM igs_pe_hz_parties pzp, hz_parties hp, Igs_Or_Inst_Stat stat
2432 WHERE pzp.party_id = hp.party_id AND
2433 hp.party_number = cp_institution_cd AND
2434 pzp.OI_INSTITUTION_STATUS = stat.Institution_Status AND
2435 pzp.inst_org_ind = 'I' AND
2436 stat.S_Institution_Status = cp_inst_status;
2437
2438 l_Institution_Rec Institution_C%ROWTYPE;
2439
2440 -- Validate the DEGREE_CODE
2441 CURSOR c_degree_code (p_degree hz_education.degree_received%TYPE) IS
2442 SELECT dg.degree_cd
2443 FROM igs_ps_degrees dg,
2444 igs_ps_type_all ps
2445 WHERE dg.degree_cd = p_degree
2446 AND dg.closed_ind ='N'
2447 AND dg.program_type = ps.course_type;
2448
2449 l_Course_Rec c_degree_code%ROWTYPE;
2450
2451
2452 CURSOR birth_date_cur(cp_person_id hz_parties.party_id%TYPE)
2453 IS
2454 SELECT birth_date
2455 FROM igs_pe_person_base_v
2456 WHERE person_id = cp_person_id;
2457
2458
2459 l_Status IGS_AD_RELATIONS_INT.STATUS%TYPE;
2460 l_Error_Code IGS_AD_RELATIONS_INT.Error_Code%TYPE;
2461 birth_date_rec birth_date_cur%ROWTYPE;
2462
2463 BEGIN
2464
2465 l_Error_Code := 'E008';
2466 l_status := '3';
2467
2468 --For UK Degree Earned and Degree Attempted should be null
2469 IF NVL(FND_PROFILE.VALUE('OSS_COUNTRY_CODE'),'*') = 'GB'
2470 AND (Relacad_Rec.degree_attempted IS NOT NULL
2471 OR Relacad_Rec.degree_earned IS NOT NULL
2472 OR Relacad_Rec.program_code IS NOT NULL) THEN
2473
2474 IF l_enable_log = 'Y' THEN
2475 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E396','IGS_AD_RELACAD_INT_ALL');
2476 END IF;
2477
2478 UPDATE Igs_Ad_Relacad_Int_all
2479 SET Error_Code = 'E396',
2480 Status = l_Status
2481 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2482 l_check := 'TRUE';
2483 RETURN;
2484
2485 END IF;
2486
2487 -- Validate the INSTITUTION_CD.
2488 OPEN Institution_C(Relacad_Rec.Institution_Code,'ACTIVE');
2489 FETCH Institution_C INTO l_Institution_Rec;
2490 IF (Institution_C%NOTFOUND) THEN
2491
2492 IF l_enable_log = 'Y' THEN
2493 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E401','IGS_AD_RELACAD_INT_ALL');
2494 END IF;
2495
2496 UPDATE Igs_Ad_Relacad_Int_all
2497 SET Error_Code = 'E401',
2498 Status = l_Status
2499 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2500 CLOSE Institution_C;
2501 l_check := 'TRUE';
2502 RETURN;
2503 END IF;
2504 CLOSE Institution_C;
2505
2506 -- Validate the DEGREE_ATTEMPTED
2507 IF (Relacad_Rec.degree_attempted IS NOT NULL) THEN
2508 OPEN c_degree_code(Relacad_Rec.degree_attempted);
2509 FETCH c_degree_code INTO l_Course_Rec;
2510 IF (c_degree_code%NOTFOUND) THEN
2511
2512 IF l_enable_log = 'Y' THEN
2513 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E402','IGS_AD_RELACAD_INT_ALL');
2514 END IF;
2515
2516 UPDATE Igs_Ad_Relacad_Int_all
2517 SET Error_Code = 'E402',
2518 Status = l_Status
2519 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2520 CLOSE c_degree_code;
2521 l_check := 'TRUE';
2522 RETURN;
2523 END IF;
2524 CLOSE c_degree_code;
2525 END IF;
2526
2527 -- Validate the DEGREE_EARNED
2528
2529 IF (Relacad_Rec.degree_earned IS NOT NULL) THEN
2530 OPEN c_degree_code(Relacad_Rec.degree_earned);
2531 FETCH c_degree_code INTO l_Course_Rec;
2532 IF (c_degree_code%NOTFOUND) THEN
2533
2534 IF l_enable_log = 'Y' THEN
2535 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E403','IGS_AD_RELACAD_INT_ALL');
2536 END IF;
2537
2538 UPDATE Igs_Ad_Relacad_Int_all
2539 SET Error_Code = 'E403',
2540 Status = l_Status
2541 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2542 CLOSE c_degree_code;
2543 l_check := 'TRUE';
2544 RETURN;
2545 END IF;
2546 CLOSE c_degree_code;
2547 END IF;
2548
2549
2550 IF RELACAD_REC.CURRENT_INST NOT IN('Y','N') THEN
2551
2552 IF l_enable_log = 'Y' THEN
2553 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E453','IGS_AD_RELACAD_INT_ALL');
2554 END IF;
2555
2556 UPDATE Igs_Ad_Relacad_Int_all
2557 SET Error_Code = 'E453',
2558 Status = l_Status
2559 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2560 l_check := 'TRUE';
2561 RETURN;
2562 END IF;
2563
2564 -- IF RELACAD_REC.CURRENT_INST = 'Y' THEN THE END DATE MUST BE NULL.
2565 IF RELACAD_REC.CURRENT_INST = 'Y' AND RELACAD_REC.END_DATE IS NOT NULL THEN
2566
2567 IF l_enable_log = 'Y' THEN
2568 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E448','IGS_AD_RELACAD_INT_ALL');
2569 END IF;
2570
2571
2572 UPDATE Igs_Ad_Relacad_Int_all
2573 SET Error_Code = 'E448',
2574 Status = l_Status
2575 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2576 l_check := 'TRUE';
2577 RETURN;
2578 END IF;
2579
2580 --6. START_DATE
2581 IF RELACAD_REC.START_DATE IS NOT NULL THEN
2582 IF NOT RELACAD_REC.START_DATE < SYSDATE THEN
2583 UPDATE Igs_Ad_Relacad_Int_all
2584 SET Error_Code = 'E405',
2585 Status = l_Status
2586 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2587 l_check := 'TRUE';
2588 RETURN;
2589 END IF;
2590 END IF;
2591
2592 --7. END_DATE
2593 IF RELACAD_REC.END_DATE IS NOT NULL
2594 AND RELACAD_REC.START_DATE IS NOT NULL THEN
2595 IF NOT RELACAD_REC.END_DATE >= RELACAD_REC.START_DATE THEN
2596 UPDATE Igs_Ad_Relacad_Int_all
2597 SET Error_Code = 'E406',
2598 Status = l_Status
2599 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2600 l_check := 'TRUE';
2601 RETURN;
2602 END IF;
2603 ELSIF RELACAD_REC.END_DATE IS NOT NULL
2604 AND RELACAD_REC.START_DATE IS NULL THEN
2605 UPDATE Igs_Ad_Relacad_Int_all
2606 SET Error_Code = 'E407',
2607 Status = l_Status
2608 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2609 l_check := 'TRUE';
2610 RETURN;
2611
2612 END IF;
2613
2614 --8. PLANNED_COMPLETION_DATE
2615 IF RELACAD_REC.PLAN_COMPLETION_DATE IS NOT NULL AND RELACAD_REC.START_DATE IS NOT NULL THEN
2616 IF NOT RELACAD_REC.PLAN_COMPLETION_DATE >= RELACAD_REC.START_DATE THEN
2617 UPDATE Igs_Ad_Relacad_Int_all
2618 SET Error_Code = 'E408',
2619 Status = l_Status
2620 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2621 l_check := 'TRUE';
2622 RETURN;
2623
2624 END IF;
2625 END IF;
2626
2627 OPEN birth_date_cur(p_rel_person_id);
2628 FETCH birth_date_cur INTO birth_date_rec;
2629 CLOSE birth_date_cur;
2630
2631 IF birth_date_rec.birth_date IS NOT NULL AND relacad_rec.start_date IS NOT NULL THEN
2632 IF relacad_rec.start_date < birth_date_rec.birth_date THEN
2633 UPDATE Igs_Ad_Relacad_Int_all
2634 SET Error_Code = 'E222',
2635 Status = l_Status
2636 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2637 l_check := 'TRUE';
2638 RETURN;
2639 END IF;
2640 END IF;
2641
2642 l_check := 'FALSE';
2643
2644 END Validate_Acad_Hist;
2645
2646 -- END of Local Procedure Validate_Acad_Hist
2647
2648 BEGIN
2649 l_check := 'FALSE';
2650 l_Status := '3';
2651 l_Error_Code := 'E008';
2652 l_prog_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his';
2653 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his.';
2654 l_enable_log := igs_ad_imp_001.g_enable_log;
2655 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
2656 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
2657
2658 IF (l_request_id IS NULL) THEN
2659 l_request_id := fnd_global.conc_request_id;
2660 END IF;
2661
2662 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his.begin';
2663 l_debug_str := 'Igs_Ad_Imp_008.crt_rel_acad_his';
2664
2665 fnd_log.string_with_context( fnd_log.level_procedure,
2666 l_label,
2667 l_debug_str, NULL,
2668 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
2669 END IF;
2670
2671 l_rule := Igs_Ad_Imp_001.Find_Source_Cat_Rule(p_source_type_id,'RELATIONS_ACAD_HISTORY');
2672
2673 --1 If rule is E or I, then if the match_ind is not null, the combination is invalid
2674 IF l_rule IN ('E','I') THEN
2675 UPDATE Igs_Ad_Relacad_Int_all
2676 SET status = '3',
2677 ERROR_CODE = 'E695' -- Error code depicting incorrect combination
2678 WHERE match_ind IS NOT NULL
2679 AND status = '2'
2680 AND Interface_Relations_Id = P_Interface_Relations_Id;
2681 END IF;
2682
2683 --2 If rule is E and duplicate exists, update match_ind to 19 and status to 1
2684 IF l_rule = 'E' THEN
2685 UPDATE Igs_Ad_Relacad_Int_all mi
2686 SET status = '1',
2687 match_ind = '19'
2688 WHERE mi.Interface_Relations_Id = P_Interface_Relations_Id
2689 AND mi.status = '2'
2690 AND EXISTS ( SELECT 1
2691 FROM Igs_Ad_Acad_History_V pe
2692 WHERE pe.Institution_Code = mi.institution_code
2693 AND ((TRUNC(pe.Start_Date) = TRUNC(mi.Start_Date)) OR (pe.start_date IS NULL AND mi.Start_date IS NULL))
2694 AND ((TRUNC(pe.end_Date) = TRUNC(mi.end_date)) OR (pe.end_date IS NULL AND mi.end_date IS NULL))
2695 AND pe.person_id = P_Rel_Person_ID);
2696 END IF;
2697
2698 --3 If rule is R and there match_ind is 18,19,22 or 23 then the records must have been
2699 -- processed in prior runs and didn't get updated .. update to status 1
2700 IF l_rule = 'R' THEN
2701 UPDATE Igs_Ad_Relacad_Int_all
2702 SET status = '1'
2703 WHERE Interface_Relations_Id = P_Interface_Relations_Id
2704 AND match_ind IN ('18','19','22','23')
2705 AND status = '2';
2706 END IF;
2707
2708 --4 If rule is R and match_ind is neither 21 nor 25 then error
2709 IF l_rule = 'R' THEN
2710 UPDATE Igs_Ad_Relacad_Int_all
2711 SET status = '3',
2712 ERROR_CODE = 'E695'
2713 WHERE Interface_Relations_Id = P_Interface_Relations_Id
2714 AND status = '2'
2715 AND (match_ind IS NOT NULL AND match_ind NOT IN ('21','25'));
2716 END IF;
2717
2718 --5 If rule is R, set duplicated records with no discrepancy to status 1 and match_ind 23
2719 IF l_rule = 'R' THEN
2720 UPDATE Igs_Ad_Relacad_Int_all mi
2721 SET status = '1',
2722 match_ind = '23'
2723 WHERE mi.Interface_Relations_Id = P_Interface_Relations_Id
2724 AND mi.match_ind IS NULL
2725 AND mi.status = '2'
2726 AND EXISTS ( SELECT '1'
2727 FROM Igs_Ad_Acad_History_V pe
2728 WHERE pe.person_id = P_Rel_Person_ID
2729 AND UPPER(pe.current_inst) = UPPER(mi.current_inst)
2730 AND ( (TRUNC(pe.Start_Date) = TRUNC(mi.Start_Date)) OR (pe.start_date IS NULL AND mi.Start_date is null) )
2731 AND ( (UPPER(pe.program_code) = UPPER(mi.program_code)) OR (pe.program_code IS NULL AND mi.program_code is null) )
2732 AND ( (UPPER(pe.degree_attempted) = UPPER(mi.degree_attempted)) or (pe.degree_attempted is null and mi.degree_attempted is null) )
2733 AND ( (UPPER(pe.degree_earned) = UPPER(mi.degree_earned)) OR (pe.degree_earned is null and mi.degree_earned is null) )
2734 AND ( (UPPER(pe.comments) = UPPER(mi.comments)) or (pe.comments is null and mi.comments is null) )
2735 AND ( (TRUNC(pe.planned_completion_date) = TRUNC(mi.plan_completion_date)) or (pe.planned_completion_date is null and mi.plan_completion_date is null) )
2736 AND UPPER(pe.Institution_Code) = UPPER(mi.Institution_Code)
2737 );
2738 END IF;
2739
2740 --6 If rule is R records still exist, they are duplicates and have discrepancy .. update status=3,match_ind=20
2741 IF l_rule = 'R' THEN
2742 UPDATE Igs_Ad_Relacad_Int_all mi
2743 SET status = '3',
2744 match_ind = '20'
2745 WHERE mi.Interface_Relations_Id = P_Interface_Relations_Id
2746 AND mi.match_ind IS NULL
2747 AND mi.status = '2'
2748 AND EXISTS ( SELECT 1
2749 FROM Igs_Ad_Acad_History_V pe
2750 WHERE pe.Institution_Code = mi.institution_code
2751 AND ((TRUNC(pe.Start_Date) = TRUNC(mi.Start_Date)) OR (pe.start_date IS NULL AND mi.Start_date IS NULL))
2752 AND ((TRUNC(pe.end_Date) = TRUNC(mi.end_date)) OR (pe.end_date IS NULL AND mi.end_date IS NULL))
2753 AND pe.person_id = P_Rel_Person_ID);
2754 END IF;
2755
2756 --1. Pick up all the records from the table IGS_AD_RELACAD_INT
2757 FOR Relacad_Rec IN Relacad_Rec_C(P_Interface_Relations_Id) LOOP
2758 Relacad_Rec.CURRENT_INST := UPPER(Relacad_Rec.CURRENT_INST);
2759 Relacad_Rec.start_date := TRUNC(Relacad_Rec.start_date);
2760 l_check:= 'FALSE';
2761 Validate_Acad_Hist( Relacad_Rec ,l_check );
2762
2763 IF l_check <> 'TRUE' THEN
2764 --7. Check to see if an academic history record already exists for this person
2765 OPEN Academic_His_C(RELACAD_REC.INSTITUTION_CODE,RELACAD_REC.START_DATE,p_rel_person_id,RELACAD_REC.END_DATE);
2766 FETCH Academic_His_C INTO l_Academic_His_Rec;
2767
2768 --8. IF the academic history details already exist for this person THEN
2769 IF Academic_His_C%FOUND THEN
2770 IF l_rule = 'I' THEN
2771 BEGIN
2772 -- Call IGS_AD_HZ_ACAD_HISTORY.UPDATE_ROW to update the row in the extension table.
2773 l_education_id := l_Academic_His_Rec.Education_ID;
2774 l_row_id := l_Academic_His_Rec.row_id;
2775
2776 Igs_Ad_Acad_History_Pkg.update_row(
2777 x_rowid => l_row_id,
2778 x_recalc_total_cp_earned => l_Academic_His_Rec.recalc_total_cp_earned,
2779 x_recalc_total_cp_attempted => l_Academic_His_Rec.recalc_total_cp_attempted,
2780 x_recalc_total_unit_gp => l_Academic_His_Rec.recalc_total_unit_gp,
2781 x_recalc_tot_gpa_units_attemp => l_Academic_His_Rec.recalc_total_gpa_units_attemp,
2782 x_recalc_inst_gpa => l_Academic_His_Rec.recalc_inst_gpa,
2783 x_recalc_grading_scale_id => l_Academic_His_Rec.recalc_grading_scale_id,
2784 x_selfrep_total_cp_attempted => l_Academic_His_Rec.selfrep_total_cp_attempted,
2785 x_selfrep_total_cp_earned => l_Academic_His_Rec.selfrep_total_cp_earned,
2786 x_selfrep_total_unit_gp => l_Academic_His_Rec.selfrep_total_unit_gp,
2787 x_selfrep_tot_gpa_uts_attemp => l_Academic_His_Rec.selfrep_total_gpa_units_attemp,
2788 x_selfrep_inst_gpa => l_Academic_His_Rec.selfrep_inst_gpa,
2789 x_selfrep_grading_scale_id => l_Academic_His_Rec.selfrep_grading_scale_id,
2790 x_selfrep_weighted_gpa => l_Academic_His_Rec.selfrep_weighted_gpa,
2791 x_selfrep_rank_in_class => l_Academic_His_Rec.selfrep_rank_in_class,
2792 x_selfrep_weighed_rank => l_Academic_His_Rec.selfrep_weighed_rank,
2793 x_selfrep_class_size => l_Academic_His_Rec.selfrep_class_size, -- x_hz_acad_hist_id => l_Academic_His_Rec.hz_acad_hist_id,
2794 x_attribute_category => l_Academic_His_Rec.attribute_category,
2795 x_attribute1 => l_Academic_His_Rec.attribute1,
2796 x_attribute2 => l_Academic_His_Rec.attribute2,
2797 x_attribute3 => l_Academic_His_Rec.attribute3,
2798 x_attribute4 => l_Academic_His_Rec.attribute4,
2799 x_attribute5 => l_Academic_His_Rec.attribute5,
2800 x_attribute6 => l_Academic_His_Rec.attribute6,
2801 x_attribute7 => l_Academic_His_Rec.attribute7,
2802 x_attribute8 => l_Academic_His_Rec.attribute8,
2803 x_attribute9 => l_Academic_His_Rec.attribute9,
2804 x_attribute10 => l_Academic_His_Rec.attribute10,
2805 x_attribute11 => l_Academic_His_Rec.attribute11,
2806 x_attribute12 => l_Academic_His_Rec.attribute12,
2807 x_attribute13 => l_Academic_His_Rec.attribute13,
2808 x_attribute14 => l_Academic_His_Rec.attribute14,
2809 x_attribute15 => l_Academic_His_Rec.attribute15,
2810 x_attribute16 => l_Academic_His_Rec.attribute16,
2811 x_attribute17 => l_Academic_His_Rec.attribute17,
2812 x_attribute18 => l_Academic_His_Rec.attribute18,
2813 x_attribute19 => l_Academic_His_Rec.attribute19,
2814 x_attribute20 => l_Academic_His_Rec.attribute20,
2815 x_type_of_school => l_Academic_His_Rec.type_of_school,
2816 x_institution_code => NVL(Relacad_Rec.institution_code,l_Academic_His_Rec.institution_code),
2817 x_education_id => l_education_id,
2818 x_person_id => l_Academic_His_Rec.person_id,
2819 x_current_inst => NVL(Relacad_Rec.current_inst,l_Academic_His_Rec.current_inst),
2820 x_degree_attempted => NVL(Relacad_Rec.degree_attempted,l_Academic_His_Rec.degree_attempted),
2821 x_program_code => NVL(Relacad_Rec.program_code,l_Academic_His_Rec.program_code ),
2822 x_degree_earned => NVL(Relacad_Rec.degree_earned,l_Academic_His_Rec.degree_earned),
2823 x_comments => NVL(Relacad_Rec.comments,l_Academic_His_Rec.comments),
2824 x_start_date => NVL(Relacad_Rec.start_date,TRUNC(l_Academic_His_Rec.start_date)),
2825 x_end_date => NVL(Relacad_Rec.end_date,TRUNC(l_Academic_His_Rec.end_date)),
2826 x_planned_completion_date => NVL(Relacad_Rec.plan_completion_date,TRUNC(l_Academic_His_Rec.planned_completion_date)),
2827 x_transcript_required => l_Academic_His_Rec.transcript_required,
2828 x_object_version_number => l_Academic_His_Rec.object_version_number,
2829 x_msg_data => l_msg_data,
2830 x_return_status => l_return_status,
2831 x_mode => 'R'
2832 );
2833
2834 IF (l_return_status = 'E' OR l_return_status = 'U') THEN
2835
2836 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
2837
2838 IF (l_request_id IS NULL) THEN
2839 l_request_id := fnd_global.conc_request_id;
2840 END IF;
2841
2842 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his.exception '||'E014';
2843
2844 l_debug_str := 'Rule - Import, IGS_AD_IMP_008.crt_rel_acad_his Update Row failed'
2845 || 'Interface Relacad Id : '
2846 || (relacad_rec.interface_relacad_id)
2847 || 'Status : 3' || 'ErrorCode : E014 HzMesg: '||l_msg_data||' SQLERRM:' || SQLERRM;
2848
2849 fnd_log.string_with_context( fnd_log.level_exception,
2850 l_label,
2851 l_debug_str, NULL,
2852 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
2853 END IF;
2854
2855 IF l_enable_log = 'Y' THEN
2856 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E014','IGS_AD_RELACAD_INT_ALL');
2857 END IF;
2858
2859 UPDATE Igs_Ad_Relacad_Int_all
2860 SET Error_Code = 'E014',
2861 Status = '3'
2862 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2863 ELSE
2864 UPDATE Igs_Ad_Relacad_Int_all
2865 SET Error_Code = NULL,
2866 Status = '1', Match_Ind = '18'
2867 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2868 END IF;
2869 END;
2870
2871 ELSIF l_rule = 'R' THEN
2872 IF Relacad_Rec.match_ind = '21' THEN
2873 BEGIN
2874 -- Call IGS_AD_HZ_ACAD_HISTORY.UPDATE_ROW to update the row in the extension table.
2875 --Standard start of API savepoint
2876 l_education_id := l_Academic_His_Rec.Education_ID;
2877 l_row_id := l_Academic_His_Rec.row_id;
2878
2879 Igs_Ad_Acad_History_Pkg.update_row(
2880 x_rowid => l_row_id,
2881 x_recalc_total_cp_earned => l_Academic_His_Rec.recalc_total_cp_earned,
2882 x_recalc_total_cp_attempted => l_Academic_His_Rec.recalc_total_cp_attempted,
2883 x_recalc_total_unit_gp => l_Academic_His_Rec.recalc_total_unit_gp,
2884 x_recalc_tot_gpa_units_attemp => l_Academic_His_Rec.recalc_total_gpa_units_attemp,
2885 x_recalc_inst_gpa => l_Academic_His_Rec.recalc_inst_gpa,
2886 x_recalc_grading_scale_id => l_Academic_His_Rec.recalc_grading_scale_id,
2887 x_selfrep_total_cp_attempted => l_Academic_His_Rec.selfrep_total_cp_attempted,
2888 x_selfrep_total_cp_earned => l_Academic_His_Rec.selfrep_total_cp_earned,
2889 x_selfrep_total_unit_gp => l_Academic_His_Rec.selfrep_total_unit_gp,
2890 x_selfrep_tot_gpa_uts_attemp => l_Academic_His_Rec.selfrep_total_gpa_units_attemp,
2891 x_selfrep_inst_gpa => l_Academic_His_Rec.selfrep_inst_gpa,
2892 x_selfrep_grading_scale_id => l_Academic_His_Rec.selfrep_grading_scale_id,
2893 x_selfrep_weighted_gpa => l_Academic_His_Rec.selfrep_weighted_gpa,
2894 x_selfrep_rank_in_class => l_Academic_His_Rec.selfrep_rank_in_class,
2895 x_selfrep_weighed_rank => l_Academic_His_Rec.selfrep_weighed_rank,
2896 x_selfrep_class_size => l_Academic_His_Rec.selfrep_class_size, -- x_hz_acad_hist_id => l_Academic_His_Rec.hz_acad_hist_id,
2897 x_attribute_category => l_Academic_His_Rec.attribute_category,
2898 x_attribute1 => l_Academic_His_Rec.attribute1,
2899 x_attribute2 => l_Academic_His_Rec.attribute2,
2900 x_attribute3 => l_Academic_His_Rec.attribute3,
2901 x_attribute4 => l_Academic_His_Rec.attribute4,
2902 x_attribute5 => l_Academic_His_Rec.attribute5,
2903 x_attribute6 => l_Academic_His_Rec.attribute6,
2904 x_attribute7 => l_Academic_His_Rec.attribute7,
2905 x_attribute8 => l_Academic_His_Rec.attribute8,
2906 x_attribute9 => l_Academic_His_Rec.attribute9,
2907 x_attribute10 => l_Academic_His_Rec.attribute10,
2908 x_attribute11 => l_Academic_His_Rec.attribute11,
2909 x_attribute12 => l_Academic_His_Rec.attribute12,
2910 x_attribute13 => l_Academic_His_Rec.attribute13,
2911 x_attribute14 => l_Academic_His_Rec.attribute14,
2912 x_attribute15 => l_Academic_His_Rec.attribute15,
2913 x_attribute16 => l_Academic_His_Rec.attribute16,
2914 x_attribute17 => l_Academic_His_Rec.attribute17,
2915 x_attribute18 => l_Academic_His_Rec.attribute18,
2916 x_attribute19 => l_Academic_His_Rec.attribute19,
2917 x_attribute20 => l_Academic_His_Rec.attribute20,
2918 x_type_of_school => l_Academic_His_Rec.type_of_school,
2919 x_institution_code => NVL(Relacad_Rec.institution_code,l_Academic_His_Rec.institution_code),
2920 x_education_id => l_education_id,
2921 x_person_id => l_Academic_His_Rec.person_id,
2922 x_current_inst => NVL(Relacad_Rec.current_inst,l_Academic_His_Rec.current_inst),
2923 x_degree_attempted => NVL(Relacad_Rec.degree_attempted,l_Academic_His_Rec.degree_attempted),
2924 x_program_code => NVL(Relacad_Rec.program_code,l_Academic_His_Rec.program_code ),
2925 x_degree_earned => NVL(Relacad_Rec.degree_earned,l_Academic_His_Rec.degree_earned),
2926 x_comments => NVL(Relacad_Rec.comments,l_Academic_His_Rec.comments),
2927 x_start_date => NVL(Relacad_Rec.start_date,TRUNC(l_Academic_His_Rec.start_date)),
2928 x_end_date => NVL(Relacad_Rec.end_date,TRUNC(l_Academic_His_Rec.end_date)),
2929 x_planned_completion_date => NVL(Relacad_Rec.plan_completion_date,TRUNC(l_Academic_His_Rec.planned_completion_date)),
2930 x_transcript_required => l_Academic_His_Rec.transcript_required,
2931 x_object_version_number => l_Academic_His_Rec.object_version_number,
2932 x_msg_data => l_msg_data,
2933 x_return_status => l_return_status,
2934 x_mode => 'R'
2935 );
2936
2937 IF (l_return_status = 'E' OR l_return_status = 'U') THEN
2938
2939 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
2940
2941 IF (l_request_id IS NULL) THEN
2942 l_request_id := fnd_global.conc_request_id;
2943 END IF;
2944
2945 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his.exception1 '||'E014';
2946
2947 l_debug_str := 'Rule - Import, IGS_AD_IMP_008.crt_rel_acad_his Update Row failed'
2948 || 'Interface Relacad Id : '
2949 || (relacad_rec.interface_relacad_id)
2950 || 'Status : 3' || 'ErrorCode : E014 HzMesg: '||l_msg_data||' SQLERRM:' || SQLERRM;
2951
2952 fnd_log.string_with_context( fnd_log.level_exception,
2953 l_label,
2954 l_debug_str, NULL,
2955 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
2956 END IF;
2957
2958 IF l_enable_log = 'Y' THEN
2959 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E014','IGS_AD_RELACAD_INT_ALL');
2960 END IF;
2961
2962 UPDATE Igs_Ad_Relacad_Int_all
2963 SET Error_Code = 'E014',
2964 Status = '3'
2965 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2966 ELSE
2967 UPDATE Igs_Ad_Relacad_Int_all
2968 SET Error_Code = NULL,
2969 Status = '1',
2970 match_ind = '18'
2971 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
2972 END IF;
2973 END;
2974 END IF;
2975
2976 END IF;
2977 ELSE
2978 l_Academic_His_first_Rec.a := NULL;
2979 OPEN c_Academic_His_first(RELACAD_REC.Interface_Relacad_Id, RELACAD_REC.INSTITUTION_CODE,RELACAD_REC.START_DATE,p_rel_person_id,RELACAD_REC.END_DATE);
2980 FETCH c_Academic_His_first INTO l_Academic_His_first_Rec;
2981 CLOSE c_Academic_His_first;
2982 IF l_Academic_His_first_Rec.a IS NOT NULL THEN
2983 OPEN c_dup_cur_first(RELACAD_REC, p_rel_person_id);
2984 FETCH c_dup_cur_first INTO dup_cur_first_rec;
2985 CLOSE c_dup_cur_first ;
2986 --Update the first record. (Import Process Enhancements)
2987 BEGIN
2988 -- Call IGS_AD_HZ_ACAD_HISTORY.UPDATE_ROW to update the row in the extension table.
2989 --Standard start of API savepoint
2990 l_education_id := dup_cur_first_rec.Education_ID;
2991 l_row_id := dup_cur_first_rec.row_id;
2992
2993 Igs_Ad_Acad_History_Pkg.update_row(
2994 x_rowid => l_row_id,
2995 x_recalc_total_cp_earned => dup_cur_first_rec.recalc_total_cp_earned,
2996 x_recalc_total_cp_attempted => dup_cur_first_rec.recalc_total_cp_attempted,
2997 x_recalc_total_unit_gp => dup_cur_first_rec.recalc_total_unit_gp,
2998 x_recalc_tot_gpa_units_attemp => dup_cur_first_rec.recalc_total_gpa_units_attemp,
2999 x_recalc_inst_gpa => dup_cur_first_rec.recalc_inst_gpa,
3000 x_recalc_grading_scale_id => dup_cur_first_rec.recalc_grading_scale_id,
3001 x_selfrep_total_cp_attempted => dup_cur_first_rec.selfrep_total_cp_attempted,
3002 x_selfrep_total_cp_earned => dup_cur_first_rec.selfrep_total_cp_earned,
3003 x_selfrep_total_unit_gp => dup_cur_first_rec.selfrep_total_unit_gp,
3004 x_selfrep_tot_gpa_uts_attemp => dup_cur_first_rec.selfrep_total_gpa_units_attemp,
3005 x_selfrep_inst_gpa => dup_cur_first_rec.selfrep_inst_gpa,
3006 x_selfrep_grading_scale_id => dup_cur_first_rec.selfrep_grading_scale_id,
3007 x_selfrep_weighted_gpa => dup_cur_first_rec.selfrep_weighted_gpa,
3008 x_selfrep_rank_in_class => dup_cur_first_rec.selfrep_rank_in_class,
3009 x_selfrep_weighed_rank => dup_cur_first_rec.selfrep_weighed_rank,
3010 x_selfrep_class_size => dup_cur_first_rec.selfrep_class_size, -- x_hz_acad_hist_id => l_Academic_His_Rec.hz_acad_hist_id,
3011 x_attribute_category => dup_cur_first_rec.attribute_category,
3012 x_attribute1 => dup_cur_first_rec.attribute1,
3013 x_attribute2 => dup_cur_first_rec.attribute2,
3014 x_attribute3 => dup_cur_first_rec.attribute3,
3015 x_attribute4 => dup_cur_first_rec.attribute4,
3016 x_attribute5 => dup_cur_first_rec.attribute5,
3017 x_attribute6 => dup_cur_first_rec.attribute6,
3018 x_attribute7 => dup_cur_first_rec.attribute7,
3019 x_attribute8 => dup_cur_first_rec.attribute8,
3020 x_attribute9 => dup_cur_first_rec.attribute9,
3021 x_attribute10 => dup_cur_first_rec.attribute10,
3022 x_attribute11 => dup_cur_first_rec.attribute11,
3023 x_attribute12 => dup_cur_first_rec.attribute12,
3024 x_attribute13 => dup_cur_first_rec.attribute13,
3025 x_attribute14 => dup_cur_first_rec.attribute14,
3026 x_attribute15 => dup_cur_first_rec.attribute15,
3027 x_attribute16 => dup_cur_first_rec.attribute16,
3028 x_attribute17 => dup_cur_first_rec.attribute17,
3029 x_attribute18 => dup_cur_first_rec.attribute18,
3030 x_attribute19 => dup_cur_first_rec.attribute19,
3031 x_attribute20 => dup_cur_first_rec.attribute20,
3032 x_type_of_school => dup_cur_first_rec.type_of_school,
3033 x_institution_code => NVL(Relacad_Rec.institution_code,dup_cur_first_rec.institution_code),
3034 x_education_id => l_education_id,
3035 x_person_id => dup_cur_first_rec.person_id,
3036 x_current_inst => NVL(Relacad_Rec.current_inst,dup_cur_first_rec.current_inst),
3037 x_degree_attempted => NVL(Relacad_Rec.degree_attempted,dup_cur_first_rec.degree_attempted),
3038 x_program_code => NVL(Relacad_Rec.program_code,dup_cur_first_rec.program_code ),
3039 x_degree_earned => NVL(Relacad_Rec.degree_earned,dup_cur_first_rec.degree_earned),
3040 x_comments => NVL(Relacad_Rec.comments,dup_cur_first_rec.comments),
3041 x_start_date => NVL(Relacad_Rec.start_date,TRUNC(dup_cur_first_rec.start_date)),
3042 x_end_date => NVL(Relacad_Rec.end_date,TRUNC(dup_cur_first_rec.end_date)),
3043 x_planned_completion_date => NVL(Relacad_Rec.plan_completion_date,TRUNC(dup_cur_first_rec.planned_completion_date)),
3044 x_transcript_required => dup_cur_first_rec.transcript_required,
3045 x_object_version_number => dup_cur_first_rec.object_version_number,
3046 x_msg_data => l_msg_data,
3047 x_return_status => l_return_status,
3048 x_mode => 'R'
3049 );
3050
3051 IF (l_return_status = 'E' OR l_return_status = 'U') THEN
3052
3053 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
3054
3055 IF (l_request_id IS NULL) THEN
3056 l_request_id := fnd_global.conc_request_id;
3057 END IF;
3058
3059 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his.exception1 '||'E014';
3060
3061 l_debug_str := 'Rule - Import, IGS_AD_IMP_008.crt_rel_acad_his Update Row failed'
3062 || 'Interface Relacad Id : '
3063 || (relacad_rec.interface_relacad_id)
3064 || 'Status : 3' || 'ErrorCode : E014 HzMesg: '||l_msg_data||' SQLERRM:' || SQLERRM;
3065
3066 fnd_log.string_with_context( fnd_log.level_exception,
3067 l_label,
3068 l_debug_str, NULL,
3069 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3070 END IF;
3071
3072 IF l_enable_log = 'Y' THEN
3073 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E014','IGS_AD_RELACAD_INT_ALL');
3074 END IF;
3075
3076 UPDATE Igs_Ad_Relacad_Int_all
3077 SET Error_Code = 'E014',
3078 Status = '3'
3079 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
3080 ELSE
3081 UPDATE Igs_Ad_Relacad_Int_all
3082 SET Error_Code = NULL,
3083 Status = '1',
3084 match_ind = '18'
3085 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
3086 END IF;
3087 END;
3088 ELSE
3089 l_Academic_His_partial.a := NULL;
3090 OPEN c_Academic_His_partial(RELACAD_REC.INSTITUTION_CODE,RELACAD_REC.START_DATE,p_rel_person_id,RELACAD_REC.END_DATE);
3091 FETCH c_Academic_His_partial INTO l_Academic_His_partial;
3092 CLOSE c_Academic_His_partial;
3093 IF l_Academic_His_partial.a IS NOT NULL THEN --PARTIAL
3094 SELECT COUNT(*) INTO l_count
3095 FROM IGS_AD_ACAD_HISTORY_V acad
3096 WHERE acad.person_id = p_rel_person_id
3097 AND acad.institution_code = RELACAD_REC.INSTITUTION_CODE;
3098 IF l_count >1 THEN
3099 UPDATE Igs_Ad_Relacad_Int_all
3100 SET Status = '3', match_ind = '14'
3101 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
3102 ELSE
3103 UPDATE Igs_Ad_Relacad_Int_all
3104 SET Status = '3', match_ind = '13'
3105 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
3106 END IF;
3107
3108 ELSE
3109 l_row_id := Null;
3110 Igs_Ad_Acad_History_Pkg.INSERT_ROW (
3111 x_rowid => l_row_id,
3112 x_education_id => l_education_id,
3113 x_person_id => p_rel_person_id,
3114 x_current_inst => relacad_rec.current_inst,
3115 x_degree_attempted => relacad_rec.degree_attempted,
3116 x_program_code => relacad_rec.program_code,
3117 x_degree_earned => relacad_rec.degree_earned,
3118 x_comments => relacad_rec.comments,
3119 x_start_date => relacad_rec.start_date,
3120 x_end_date => relacad_rec.end_date,
3121 x_planned_completion_date => relacad_rec.plan_completion_date,
3122 x_recalc_total_cp_attempted => NULL,
3123 x_recalc_total_cp_earned => NULL,
3124 x_recalc_total_unit_gp => NULL,
3125 x_recalc_tot_gpa_units_attemp => NULL,
3126 x_recalc_inst_gpa => NULL,
3127 x_recalc_grading_scale_id => NULL,
3128 x_selfrep_total_cp_attempted => NULL,
3129 x_selfrep_total_cp_earned => NULL,
3130 x_selfrep_total_unit_gp => NULL,
3131 X_selfrep_tot_gpa_uts_attemp => NULL,
3132 x_selfrep_inst_gpa => NULL,
3133 x_selfrep_grading_scale_id => NULL,
3134 x_selfrep_weighted_gpa => NULL,
3135 x_selfrep_rank_in_class => NULL,
3136 x_selfrep_weighed_rank => NULL,
3137 x_type_of_school => NULL,
3138 x_institution_code => relacad_rec.institution_code,
3139 x_attribute_category => NULL,
3140 x_attribute1 => NULL,
3141 x_attribute2 => NULL,
3142 x_attribute3 => NULL,
3143 x_attribute4 => NULL,
3144 x_attribute5 => NULL,
3145 x_attribute6 => NULL,
3146 x_attribute7 => NULL,
3147 x_attribute8 => NULL,
3148 x_attribute9 => NULL,
3149 x_attribute10 => NULL,
3150 x_attribute11 => NULL,
3151 x_attribute12 => NULL,
3152 x_attribute13 => NULL,
3153 x_attribute14 => NULL,
3154 x_attribute15 => NULL,
3155 x_attribute16 => NULL,
3156 x_attribute17 => NULL,
3157 x_attribute18 => NULL,
3158 x_attribute19 => NULL,
3159 x_attribute20 => NULL,
3160 x_selfrep_class_size => NULL,
3161 x_transcript_required => NULL,
3162 x_object_version_number => l_object_version_number,
3163 x_msg_data => l_msg_data,
3164 x_return_status => l_return_status,
3165 x_mode => 'R'
3166 ) ;
3167
3168
3169 --ssomani added this check feb 26, 2001
3170 IF (l_return_status = 'E' OR l_return_status = 'U') THEN
3171
3172 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
3173
3174 IF (l_request_id IS NULL) THEN
3175 l_request_id := fnd_global.conc_request_id;
3176 END IF;
3177
3178 l_label := 'igs.plsql.igs_ad_imp_008.crt_rel_acad_his.exception '||'E322';
3179
3180 l_debug_str := 'Rule - Import, IGS_AD_IMP_008.crt_rel_acad_his Insert Row failed'
3181 || 'Interface Relacad Id : '
3182 || (relacad_rec.interface_relacad_id)
3183 || 'Status : 3' || 'ErrorCode : E322 HzMesg: '||l_msg_data||' SQLERRM:' || SQLERRM;
3184
3185 fnd_log.string_with_context( fnd_log.level_exception,
3186 l_label,
3187 l_debug_str, NULL,
3188 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3189 END IF;
3190
3191 IF l_enable_log = 'Y' THEN
3192 igs_ad_imp_001.logerrormessage(relacad_rec.interface_relacad_id,'E322','IGS_AD_RELACAD_INT_ALL');
3193 END IF;
3194
3195 UPDATE Igs_Ad_Relacad_Int_all
3196 SET Error_Code = 'E322',
3197 Status = '3'
3198 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
3199 ELSE
3200 UPDATE Igs_Ad_Relacad_Int_all
3201 SET Error_Code = NULL,
3202 Status = '1'
3203 WHERE Interface_Relacad_Id = Relacad_Rec.Interface_Relacad_Id;
3204 END IF;
3205 END IF;
3206 END IF;
3207 END IF;
3208 CLOSE Academic_His_C;
3209 END IF;
3210 END LOOP;
3211 END crt_rel_acad_his;
3212
3213 PROCEDURE validate_relns_emp_dtls(
3214 P_RELEMP_REC IN IGS_AD_RELEMP_INT_ALL%ROWTYPE,
3215 p_rel_person_id IN hz_parties.party_id%TYPE,
3216 P_EMPLOYER_PARTY_ID IN OUT NOCOPY NUMBER,
3217 P_ERROR_CODE OUT NOCOPY VARCHAR2);
3218
3219 PROCEDURE Crt_Relns_Emp_Dtls(
3220 P_RELEMP_REC IGS_AD_RELEMP_INT_ALL%ROWTYPE, p_person_id NUMBER) AS
3221
3222 lv_var VARCHAR2(1);
3223 l_rowid VARCHAR2(25);
3224 l_msg_data VARCHAR2(2000);
3225 l_return_status VARCHAR2(1);
3226 l_Employment_History_Id NUMBER;
3227 l_error_code VARCHAR2(30);
3228 l_count NUMBER(3);
3229 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
3230 l_prog_label VARCHAR2(100);
3231 l_label VARCHAR2(100);
3232 l_debug_str VARCHAR2(2000);
3233 l_request_id NUMBER;
3234 l_object_version_number NUMBER;
3235 l_employer_party_id NUMBER;
3236 l_enable_log VARCHAR2(1);
3237 BEGIN
3238
3239 l_prog_label := 'igs.plsql.igs_ad_imp_008.crt_relns_emp_dtls';
3240 l_label := 'igs.plsql.igs_ad_imp_008.crt_relns_emp_dtls.';
3241 l_enable_log := igs_ad_imp_001.g_enable_log;
3242 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
3243 lv_var := 'N';
3244 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
3245 IF (l_request_id IS NULL) THEN
3246 l_request_id := fnd_global.conc_request_id;
3247 END IF;
3248
3249 l_label := 'igs.plsql.igs_ad_imp_008.crt_relns_emp_dtls.begin';
3250 l_debug_str := 'Igs_Ad_Imp_008.Crt_Relns_Emp_Dtls';
3251
3252 fnd_log.string_with_context( fnd_log.level_procedure,
3253 l_label,
3254 l_debug_str, NULL,
3255 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3256 END IF;
3257
3258 validate_relns_emp_dtls(P_RELEMP_REC,p_person_id,l_employer_party_id,l_error_code);
3259
3260 IF l_error_code IS NOT NULL THEN
3261 UPDATE igs_ad_relemp_int_all
3262 SET status = '3', error_code = l_error_code
3263 WHERE interface_relemp_id = p_relemp_rec.interface_relemp_id;
3264 ELSE
3265 BEGIN
3266 --Signature of Igs_Ad_Emp_Dtl_Pkg is changed to include HZ.K impact changes
3267 Igs_Ad_Emp_Dtl_Pkg.Insert_Row (
3268 X_ROWID => l_RowId,
3269 x_employment_history_id => l_Employment_History_Id,
3270 x_PERSON_ID => p_person_id,
3271 x_START_DT => P_RELEMP_REC.Start_Dt,
3272 x_END_DT => P_RELEMP_REC.End_Dt,
3273 x_TYPE_OF_EMPLOYMENT => P_RELEMP_REC.Type_Of_Employment,
3274 x_FRACTION_OF_EMPLOYMENT => P_RELEMP_REC.Fraction_Of_Employment,
3275 x_TENURE_OF_EMPLOYMENT => P_RELEMP_REC.Tenure_Of_Employment,
3276 x_POSITION => P_RELEMP_REC.Position,
3277 x_OCCUPATIONAL_TITLE_CODE => P_RELEMP_REC.OCCUPATIONAL_TITLE_CODE,
3278 x_OCCUPATIONAL_TITLE => NULL, --P_RELEMP_REC.TITLE,
3279 x_WEEKLY_WORK_HOURS => P_RELEMP_REC.WEEKLY_WORK_HOURS,
3280 x_COMMENTS => P_RELEMP_REC.Comments,
3281 x_EMPLOYER => P_RELEMP_REC.Employer,
3282 x_EMPLOYED_BY_DIVISION_NAME => P_RELEMP_REC.Employed_by_division_name,
3283 x_BRANCH => null,
3284 x_MILITARY_RANK => null,
3285 x_SERVED => null,
3286 x_STATION => null,
3287 x_CONTACT => p_RELEMP_REC.Contact, -- Bug : 2037512
3288 x_msg_data => l_msg_data,
3289 x_return_status => l_return_status,
3290 x_object_version_number => l_object_version_number,
3291 x_employed_by_party_id => l_employer_party_id,
3292 x_reason_for_leaving => p_RELEMP_REC.Reason_for_leaving,
3293 X_MODE => 'R' );
3294
3295 IF l_return_Status IN ('E','U') THEN
3296 IF l_enable_log = 'Y' THEN
3297 fnd_message.set_name('igs', 'igs_ad_crt_emp_dtl_failed');
3298 fnd_file.put_line(fnd_file.log, fnd_message.get);
3299 -- Log the message Employment Details failed
3300 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,'E322','IGS_AD_RELEMP_INT_ALL');
3301 END IF;
3302
3303 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
3304 IF (l_request_id IS NULL) THEN
3305 l_request_id := fnd_global.conc_request_id;
3306 END IF;
3307 l_label := 'igs.plsql.igs_ad_imp_008.crt_relns_emp_dtls.exception';
3308 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
3309 fnd_message.set_token('INTERFACE_ID',p_relemp_rec.interface_relemp_id);
3310 fnd_message.set_token('ERROR_CD','E322');
3311 l_debug_str := fnd_message.get || ' ' || l_msg_data;
3312 fnd_log.string_with_context( fnd_log.level_exception,
3313 l_label,
3314 l_debug_str, NULL,
3315 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3316 END IF;
3317 --ssomani, added the update of igs_ad_relemp_int 15 March 2001
3318 UPDATE igs_ad_relemp_int_all
3319 SET status = '3', error_code = 'E322'
3320 WHERE interface_relemp_id = p_relemp_rec.interface_relemp_id;
3321 ELSE
3322 UPDATE igs_ad_relemp_int_all
3323 SET status = '1', error_code = NULL
3324 WHERE interface_relemp_id = p_relemp_rec.interface_relemp_id;
3325 END IF;
3326
3327 EXCEPTION
3328 WHEN OTHERS THEN
3329 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
3330 IF (l_request_id IS NULL) THEN
3331 l_request_id := fnd_global.conc_request_id;
3332 END IF;
3333
3334 l_label := 'igs.plsql.igs_ad_imp_008.crt_relns_emp_dtls.exception '||'E518';
3335 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
3336 fnd_message.set_token('INTERFACE_ID',p_relemp_rec.interface_relemp_id);
3337 fnd_message.set_token('ERROR_CD','E518');
3338 l_debug_str := fnd_message.get || ' ' || SQLERRM;
3339 fnd_log.string_with_context( fnd_log.level_exception,
3340 l_label,
3341 l_debug_str, NULL,
3342 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3343 END IF;
3344
3345 IF l_enable_log = 'Y' THEN
3346 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,'E518','IGS_AD_RELEMP_INT_ALL');
3347 END IF;
3348
3349 UPDATE igs_ad_relemp_int_all
3350 SET status = '3', error_code = 'E518'
3351 WHERE interface_relemp_id = p_relemp_rec.interface_relemp_id;
3352 END;
3353 END IF;
3354
3355 END Crt_Relns_Emp_Dtls;
3356
3357 PROCEDURE validate_relns_emp_dtls(P_RELEMP_REC IN IGS_AD_RELEMP_INT_ALL%ROWTYPE,
3358 P_REL_PERSON_ID IN hz_parties.party_id%TYPE,
3359 P_EMPLOYER_PARTY_ID IN OUT NOCOPY NUMBER,
3360 P_ERROR_CODE OUT NOCOPY VARCHAR2) AS
3361
3362 CURSOR Validate_Occup_Title( p_occupational_title_code igs_ps_dic_occ_titls.occupational_title_code%TYPE ) IS
3363 SELECT 'Y'
3364 FROM igs_ps_dic_occ_titls
3365 WHERE occupational_title_code = p_occupational_title_code;
3366
3367 CURSOR employer_party_number_cur(cp_employer_party_number igs_ad_emp_int_all.employer_party_number%TYPE) IS
3368 SELECT party_id
3369 FROM HZ_PARTIES
3370 WHERE party_type = 'ORGANIZATION' AND
3371 party_number = cp_employer_party_number AND
3372 status <> 'M';
3373
3374 CURSOR birth_date_cur(cp_person_id igs_pe_person_base_v.person_id%TYPE) IS
3375 SELECT birth_date
3376 FROM igs_pe_person_base_v
3377 WHERE person_id = cp_person_id;
3378
3379 lv_var VARCHAR2(1);
3380 l_count NUMBER(3);
3381 l_enable_log VARCHAR2(1);
3382 l_prog_label VARCHAR2(100);
3383 l_label VARCHAR2(100);
3384 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
3385 l_debug_str VARCHAR2(2000);
3386 l_request_id NUMBER;
3387 l_birth_date DATE;
3388
3389 BEGIN
3390
3391 P_ERROR_CODE := NULL;
3392 lv_var := 'N';
3393
3394 l_prog_label := 'igs.plsql.igs_ad_imp_008.validate_relns_emp_dtls';
3395 l_label := 'igs.plsql.igs_ad_imp_008.validate_relns_emp_dtls.';
3396 l_enable_log := igs_ad_imp_001.g_enable_log;
3397 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
3398 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
3399
3400 IF (l_request_id IS NULL) THEN
3401 l_request_id := fnd_global.conc_request_id;
3402 END IF;
3403
3404 l_label := 'igs.plsql.igs_ad_imp_008.validate_relns_emp_dtls.begin';
3405 l_debug_str := 'Igs_Ad_Imp_008.validate_relns_emp_dtls';
3406
3407 fnd_log.string_with_context( fnd_log.level_procedure,
3408 l_label,
3409 l_debug_str, NULL,
3410 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3411 END IF;
3412
3413 IF P_RELEMP_REC.OCCUPATIONAL_TITLE_CODE IS NOT NULl THEN
3414 OPEN Validate_Occup_Title (P_RELEMP_REC.OCCUPATIONAL_TITLE_CODE);
3415 FETCH Validate_Occup_Title INTO lv_var;
3416 CLOSE Validate_Occup_Title;
3417 END IF;
3418
3419
3420 --ssomani, corrected these validations 15 March 2001
3421 IF (P_RELEMP_REC.OCCUPATIONAL_TITLE_CODE IS NOT NULl AND lv_var = 'N') THEN
3422 p_error_code :='E223';
3423 IF l_enable_log = 'Y' THEN
3424 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3425 END IF;
3426 RETURN;
3427 END IF;
3428
3429 IF P_RELEMP_REC.Start_DT IS NULL THEN
3430 p_error_code :='E407';
3431 IF l_enable_log = 'Y' THEN
3432 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3433 END IF;
3434 RETURN;
3435 END IF;
3436
3437 IF NVL(P_RELEMP_REC.End_Dt,P_RELEMP_REC.Start_Dt) < P_RELEMP_REC.Start_DT THEN
3438 p_error_code :='E406';
3439 IF l_enable_log = 'Y' THEN
3440 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3441 END IF;
3442 RETURN;
3443 END IF;
3444
3445 OPEN birth_date_cur(p_rel_person_id);
3446 FETCH birth_date_cur INTO l_birth_date;
3447 CLOSE birth_date_cur;
3448 -- start date must be greater than birth date
3449 IF l_birth_date IS NOT NULL THEN
3450 IF p_relemp_rec.start_dt < l_birth_date THEN
3451 p_error_code := 'E222';
3452 IF l_enable_log = 'Y' THEN
3453 igs_ad_imp_001.logerrormessage( p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3454 END IF;
3455 RETURN;
3456 END IF;
3457 END IF;
3458
3459 IF P_RELEMP_REC.TYPE_OF_EMPLOYMENT IS NOT NULL THEN
3460 IF NOT (igs_pe_pers_imp_001.validate_lookup_type_code('HZ_EMPLOYMENT_TYPE',P_RELEMP_REC.TYPE_OF_EMPLOYMENT,222)) THEN
3461 p_error_code :='E224';
3462 IF l_enable_log = 'Y' THEN
3463 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,'E224','IGS_AD_RELEMP_INT_ALL');
3464 END IF;
3465 RETURN;
3466 END IF;
3467 END IF;
3468
3469 IF NVL(P_RELEMP_REC.FRACTION_OF_EMPLOYMENT,1) NOT BETWEEN 0.01 AND 100.00 THEN
3470 p_error_code :='E225';
3471 IF l_enable_log = 'Y' THEN
3472 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3473 END IF;
3474 RETURN;
3475 END IF;
3476
3477 IF P_RELEMP_REC.TENURE_OF_EMPLOYMENT IS NOT NULL THEN
3478 IF NOT (igs_pe_pers_imp_001.validate_lookup_type_code('HZ_TENURE_CODE',P_RELEMP_REC.TENURE_OF_EMPLOYMENT,222))THEN
3479 p_error_code :='E226';
3480 IF l_enable_log = 'Y' THEN
3481 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3482 END IF;
3483 RETURN;
3484 END IF;
3485
3486 END IF;
3487
3488 IF P_RELEMP_REC.WEEKLY_WORK_HOURS < 0 OR P_RELEMP_REC.WEEKLY_WORK_HOURS > 168 THEN
3489 p_error_code :='E227';
3490 IF l_enable_log = 'Y' THEN
3491 igs_ad_imp_001.logerrormessage(p_relemp_rec.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3492 END IF;
3493 RETURN;
3494 END IF;
3495
3496 --Employer and Employed_by_party_id are mutually_exclusive
3497 IF P_RELEMP_REC.employer_party_number IS NOT NULL AND P_RELEMP_REC.EMPLOYER IS NOT NULL THEN
3498 p_error_code := 'E755';
3499 IF l_enable_log = 'Y' THEN
3500 igs_ad_imp_001.logerrormessage(P_RELEMP_REC.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3501 END IF;
3502 RETURN;
3503 END IF;
3504
3505 --validate employer_party_number from the list of values whose party_type is organization and status <> 'M'
3506 IF P_RELEMP_REC.employer_party_number IS NOT NULL THEN
3507 OPEN employer_party_number_cur(P_RELEMP_REC.employer_party_number);
3508 FETCH employer_party_number_cur INTO p_employer_party_id;
3509 IF employer_party_number_cur%NOTFOUND THEN
3510 p_error_code := 'E756';
3511 IF l_enable_log = 'Y' THEN
3512 igs_ad_imp_001.logerrormessage(P_RELEMP_REC.interface_relemp_id,p_error_code,'IGS_AD_RELEMP_INT_ALL');
3513 END IF;
3514 RETURN;
3515 END IF;
3516 CLOSE employer_party_number_cur;
3517 END IF;
3518
3519
3520 END validate_relns_emp_dtls;
3521
3522 PROCEDURE Prc_Relns_Emp_Dtls(
3523 p_interface_relations_id NUMBER,
3524 p_rel_person_id NUMBER,
3525 P_source_type_id NUMBER )
3526 IS
3527
3528 l_prog_label VARCHAR2(100);
3529 l_label VARCHAR2(100);
3530 l_debug_str VARCHAR2(2000);
3531 l_enable_log VARCHAR2(1);
3532 l_request_id NUMBER;
3533 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
3534
3535 CURSOR Relns_Emp_Dtls(cp_interface_relations_id NUMBER) IS
3536 SELECT ri.*
3537 FROM igs_ad_relemp_int_all ri
3538 WHERE
3539 INTERFACE_RELATIONS_ID = cP_INTERFACE_RELATIONS_ID AND
3540 ri.STATUS = '2';
3541
3542 lv_Var VARCHAR2(1);
3543 l_Var VARCHAR2(1);
3544 l_status VARCHAR2(1);
3545 lv_Row_Id VARCHAR2(25);
3546 lv_Employee_History_Id NUMBER;
3547 l_Rule VARCHAR2(1);
3548 l_return_Status VARCHAR2(1);
3549 l_msg_data VARCHAR2(2000);
3550 l_error_code VARCHAR2(30);
3551
3552 BEGIN
3553
3554 l_prog_label := 'igs.plsql.igs_ad_imp_008.prc_relns_emp_dtls';
3555 l_label := 'igs.plsql.igs_ad_imp_008.prc_relns_emp_dtls.';
3556 l_enable_log := igs_ad_imp_001.g_enable_log;
3557 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
3558
3559 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
3560
3561 IF (l_request_id IS NULL) THEN
3562 l_request_id := fnd_global.conc_request_id;
3563 END IF;
3564
3565 l_label := 'igs.plsql.igs_ad_imp_008.prc_relns_emp_dtls.begin';
3566 l_debug_str := 'Igs_Ad_Imp_008.Prc_Relns_Emp_Dtls';
3567
3568 fnd_log.string_with_context( fnd_log.level_procedure,
3569 l_label,
3570 l_debug_str, NULL,
3571 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3572 END IF;
3573
3574 l_rule := Igs_Ad_Imp_001.find_source_cat_rule(p_source_type_id,'RELATIONS_EMPLOYMENT_DETAILS');
3575
3576 --1 If rule is E or I, then if the match_ind is not null, the combination is invalid
3577 IF l_rule IN ('E','I') THEN
3578 UPDATE igs_ad_relemp_int_all
3579 SET status = '3',
3580 ERROR_CODE = 'E695' -- Error code depicting incorrect combination
3581 WHERE match_ind IS NOT NULL
3582 AND status = '2'
3583 AND interface_relations_id = p_interface_relations_id;
3584 END IF;
3585
3586 --2 If rule is E and duplicate exists, update match_ind to 19 and status to 1
3587 IF l_rule = 'E' THEN
3588 UPDATE igs_ad_relemp_int_all mi
3589 SET status = '1',
3590 match_ind = '19'
3591 WHERE mi.interface_relations_id = p_interface_relations_id
3592 AND mi.status = '2'
3593 AND EXISTS ( SELECT 1
3594 FROM IGS_AD_EMP_DTL pe
3595 WHERE PERSON_ID = P_REL_PERSON_ID AND
3596 ((NVL(UPPER(pe.EMPLOYER),'*!') = NVL(UPPER(mi.employer),'*')) OR
3597 (NVL(mi.employer_party_number,'*!') = NVL(pe.employed_by_party_number,'*'))) AND
3598 NVL(TRUNC(pe.START_DT),TO_DATE('4712/12/31','YYYY/MM/DD')) = NVL(TRUNC(mi.start_dt),TO_DATE('4712/12/31','YYYY/MM/DD'))
3599 );
3600 END IF;
3601
3602 --3 If rule is R and there match_ind is 18,19,22 or 23 then the records must have been
3603 -- processed in prior runs and didn't get updated .. update to status 1
3604 IF l_rule = 'R' THEN
3605 UPDATE igs_ad_relemp_int_all
3606 SET status = '1'
3607 WHERE interface_relations_id = p_interface_relations_id
3608 AND match_ind IN ('18','19','22','23')
3609 AND status = '2';
3610 END IF;
3611
3612 --4 If rule is R and match_ind is neither 21 nor 25 then error
3613 IF l_rule = 'R' THEN
3614 UPDATE igs_ad_relemp_int_all
3615 SET status = '3',
3616 ERROR_CODE = 'E695'
3617 WHERE interface_relations_id = p_interface_relations_id
3618 AND status = '2'
3619 AND (match_ind IS NOT NULL AND match_ind NOT IN ('21','25'));
3620 END IF;
3621
3622 --5 If rule is R, set duplicated records with no discrepancy to status 1 and match_ind 23
3623 IF l_rule = 'R' THEN
3624 UPDATE igs_ad_relemp_int_all mi
3625 SET status = '1',
3626 match_ind = '23'
3627 WHERE mi.interface_relations_id = p_interface_relations_id
3628 AND mi.match_ind IS NULL
3629 AND mi.status = '2'
3630 AND EXISTS ( SELECT '1'
3631 FROM IGS_AD_EMP_DTL pe
3632 WHERE pe.PERSON_ID = p_rel_person_id AND
3633 ((TRUNC(pe.START_DT) = TRUNC(mi.Start_Dt) )OR (pe.start_dt IS NULL AND mi.Start_Dt IS NULL ))AND
3634 ((TRUNC(pe.END_DT) = TRUNC(mi.End_Dt))OR ( pe.end_dt IS NULL AND mi.End_Dt IS NULL )) AND
3635 ((pe.TYPE_OF_EMPLOYMENT = UPPER(mi.Type_Of_Employment)) OR (pe.TYPE_OF_EMPLOYMENT IS NULL AND mi.Type_Of_Employment IS NULL )) AND
3636 ((pe.FRACTION_OF_EMPLOYMENT = mi.Fraction_Of_Employment) OR (pe.FRACTION_OF_EMPLOYMENT IS NULL AND mi.Fraction_Of_Employment IS NULL )) AND
3637 ((pe.TENURE_OF_EMPLOYMENT = UPPER(mi.Tenure_Of_Employment)) OR (pe.TENURE_OF_EMPLOYMENT IS NULL AND mi.Tenure_Of_Employment IS NULL ) ) AND
3638 ((UPPER(pe.POSITION) = UPPER(mi.Position)) OR (pe.POSITION IS NULL AND mi.Position IS NULL ) ) AND
3639 ((UPPER(pe.OCCUPATIONAL_TITLE_CODE) = UPPER(mi.Occupational_Title_code)) OR (pe.OCCUPATIONAL_TITLE_CODE IS NULL AND mi.Occupational_Title_code IS NULL ) )AND
3640 ((UPPER(pe.WEEKLY_WORK_HOURS) = UPPER(mi.Weekly_Work_Hours)) OR (pe.WEEKLY_WORK_HOURS IS NULL AND mi.Weekly_Work_Hours IS NULL))AND
3641 ((pe.COMMENTS = mi.Comments ) OR (pe.COMMENTS IS NULL AND mi.Comments IS NULL ) )AND
3642 (((UPPER(pe.EMPLOYER) = UPPER(mi.Employer)) OR (pe.EMPLOYER IS NULL AND mi.Employer IS NULL ) )OR
3643 ((pe.EMPLOYED_BY_PARTY_NUMBER = mi.EMPLOYER_PARTY_NUMBER) OR ( pe.EMPLOYED_BY_PARTY_NUMBER IS NULL AND mi.EMPLOYER_PARTY_NUMBER IS NULL ))) AND
3644 ((UPPER(pe.EMPLOYED_BY_DIVISION_NAME) = UPPER(mi.Employed_By_Division_Name)) OR (pe.EMPLOYED_BY_DIVISION_NAME IS NULL AND mi.Employed_By_Division_Name IS NULL ))
3645 );
3646 END IF;
3647
3648 --6 If rule is R records still exist, they are duplicates and have discrepancy .. update status=3,match_ind=20
3649 IF l_rule = 'R' THEN
3650 UPDATE igs_ad_relemp_int_all mi
3651 SET status = '3',
3652 match_ind = '20',
3653 dup_employment_history_id = (SELECT pe.employment_history_id
3654 FROM IGS_AD_EMP_DTL pe
3655 WHERE pe.person_id = P_REL_PERSON_ID AND
3656 ((NVL(UPPER(pe.EMPLOYER),'*!') = NVL(UPPER(mi.EMPLOYER),'*')) OR
3657 (NVL(pe.EMPLOYED_BY_PARTY_NUMBER,'*!') = NVL(mi.EMPLOYER_PARTY_NUMBER,'*') ))AND
3658 NVL(TRUNC(pe.START_DT),TO_DATE('4712/12/31','YYYY/MM/DD')) = NVL(TRUNC(mi.start_dt),TO_DATE('4712/12/31','YYYY/MM/DD'))
3659 AND ROWNUM = 1)
3660 WHERE mi.interface_relations_id = p_interface_relations_id
3661 AND mi.match_ind IS NULL
3662 AND mi.status = '2'
3663 AND EXISTS (SELECT '1'
3664 FROM IGS_AD_EMP_DTL pe
3665 WHERE pe.PERSON_ID = P_REL_PERSON_ID AND
3666 ((NVL(UPPER(pe.EMPLOYER),'*!') = NVL(UPPER(mi.EMPLOYER),'*')) OR
3667 (NVL(pe.EMPLOYED_BY_PARTY_NUMBER,'*!') = NVL(mi.EMPLOYER_PARTY_NUMBER,'*'))) AND
3668 NVL(TRUNC(pe.START_DT),TO_DATE('4712/12/31','YYYY/MM/DD')) = NVL(TRUNC(mi.start_dt),TO_DATE('4712/12/31','YYYY/MM/DD'))
3669 );
3670 END IF;
3671
3672 FOR Relns_Emp_Dtls_Rec IN Relns_Emp_Dtls(p_interface_relations_id) LOOP
3673
3674 DECLARE
3675 CURSOR chk_dup_cur(cp_Relns_Emp_Dtls_Rec Relns_Emp_Dtls%ROWTYPE,
3676 cp_person_id NUMBER) IS
3677 SELECT pe.*
3678 FROM igs_ad_emp_dtl pe
3679 WHERE pe.person_id = cp_person_id
3680 AND (((NVL(UPPER(pe.employer),'*!')) = NVL(UPPER(cp_Relns_Emp_Dtls_Rec.employer),'*'))
3681 OR (NVL(pe.employed_by_party_number,'*!') = NVL(cp_Relns_Emp_Dtls_Rec.employer_party_number,'*')))
3682 AND NVL(TRUNC(pe.START_DT),TO_DATE('4712/12/31','YYYY/MM/DD')) = NVL(TRUNC(cp_Relns_Emp_Dtls_Rec.start_dt),TO_DATE('4712/12/31','YYYY/MM/DD'));
3683
3684 chk_dup_rec chk_dup_cur%ROWTYPE;
3685 l_employer_party_id NUMBER;
3686 l_count NUMBER(3);
3687 BEGIN
3688 -- changing tenure of employment and type of employment case insensitive
3689 Relns_Emp_Dtls_Rec.Type_Of_Employment := UPPER(Relns_Emp_Dtls_Rec.Type_Of_Employment);
3690 Relns_Emp_Dtls_Rec.Tenure_of_Employment := UPPER(Relns_Emp_Dtls_Rec.Tenure_of_Employment);
3691 Relns_Emp_Dtls_Rec.start_dt := TRUNC(Relns_Emp_Dtls_Rec.start_dt);
3692 Relns_Emp_Dtls_Rec.end_dt := TRUNC(Relns_Emp_Dtls_Rec.end_dt);
3693
3694 OPEN chk_dup_cur(Relns_Emp_Dtls_Rec,p_rel_person_id);
3695 FETCH chk_dup_cur INTO chk_dup_rec;
3696 IF chk_dup_cur%FOUND THEN
3697 IF l_Rule = 'I' THEN
3698 DECLARE
3699 l_exists VARCHAR2(1):='N';
3700 l_count NUMBER(3);
3701
3702 BEGIN
3703 --ssomani corrected the validation 15 March 2001
3704
3705 validate_relns_emp_dtls(Relns_Emp_Dtls_Rec,p_rel_person_id,l_employer_party_id,l_error_code);
3706
3707 IF l_error_code IS NOT NULL THEN
3708 UPDATE igs_ad_relemp_int_all
3709 SET status = '3', error_code = l_error_code
3710 WHERE interface_relemp_id = relns_emp_dtls_rec.interface_relemp_id;
3711 ELSE
3712 --Signature of Igs_Ad_Emp_Dtl_Pkg is changed to include HZ.K impact changes
3713 Igs_Ad_Emp_Dtl_Pkg.Update_Row (
3714 x_rowid => chk_dup_rec.Row_Id,
3715 x_employment_history_id => chk_dup_rec.Employment_History_Id,
3716 x_person_id => NVL(p_rel_person_id,chk_dup_rec.person_id),
3717 x_start_dt => NVL(relns_emp_dtls_rec.start_dt,chk_dup_rec.start_dt),
3718 x_end_dt => NVL(relns_emp_dtls_rec.end_dt,chk_dup_rec.end_dt),
3719 x_type_of_employment => NVL(relns_emp_dtls_rec.type_of_employment,chk_dup_rec.type_of_employment),
3720 x_fraction_of_employment => NVL(relns_emp_dtls_rec.fraction_of_employment,chk_dup_rec.fraction_of_employment),
3721 x_tenure_of_employment => NVL(relns_emp_dtls_rec.tenure_of_employment,chk_dup_rec.tenure_of_employment),
3722 x_position => NVL(relns_emp_dtls_rec.position,chk_dup_rec.position),
3723 x_occupational_title_code => NVL(relns_emp_dtls_rec.occupational_title_code,chk_dup_rec.occupational_title_code),
3724 x_occupational_title => chk_dup_rec.occupational_title,
3725 x_weekly_work_hours => NVL(relns_emp_dtls_rec.weekly_work_hours,chk_dup_rec.weekly_work_hours),
3726 x_comments => NVL(relns_emp_dtls_rec.comments,chk_dup_rec.comments),
3727 x_employer => NVL(relns_emp_dtls_rec.employer,chk_dup_rec.employer),
3728 x_employed_by_division_name => NVL(relns_emp_dtls_rec.employed_by_division_name,chk_dup_rec.employed_by_division_name),
3729 x_branch => NVL(relns_emp_dtls_rec.branch,chk_dup_rec.branch),
3730 x_military_rank => NVL(relns_emp_dtls_rec.military_rank,chk_dup_rec.military_rank),
3731 x_served => NVL(relns_emp_dtls_rec.served,chk_dup_rec.served),
3732 x_station => NVL(relns_emp_dtls_rec.station,chk_dup_rec.station),
3733 x_contact => NVL(relns_emp_dtls_rec.contact, chk_dup_rec.contact), -- bug : 2037512
3734 x_msg_data => l_msg_data,
3735 x_return_status => l_return_status,
3736 x_object_version_number => chk_dup_rec.object_version_number,
3737 x_employed_by_party_id => NVL(l_employer_party_id,chk_dup_rec.employed_by_party_id),
3738 x_reason_for_leaving => NVL(relns_emp_dtls_rec.reason_for_leaving,chk_dup_rec.reason_for_leaving),
3739 x_mode => 'R'
3740 );
3741
3742 IF l_return_Status IN ('E','U') THEN
3743 IF l_enable_log = 'Y' THEN
3744 igs_ad_imp_001.logerrormessage(relns_emp_dtls_rec.interface_relemp_id,'E014','IGS_AD_RELEMP_INT_ALL');
3745 END IF;
3746
3747 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
3748 IF (l_request_id IS NULL) THEN
3749 l_request_id := fnd_global.conc_request_id;
3750 END IF;
3751 l_label := 'igs.plsql.igs_ad_imp_008.prc_relns_emp_dtls.exception '||'E014';
3752
3753 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
3754 fnd_message.set_token('INTERFACE_ID',relns_emp_dtls_rec.interface_relemp_id);
3755 fnd_message.set_token('ERROR_CD','E014');
3756
3757 l_debug_str := fnd_message.get || ' ' || l_msg_data;
3758 fnd_log.string_with_context( fnd_log.level_exception,
3759 l_label,
3760 l_debug_str, NULL,
3761 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
3762 );
3763 END IF;
3764 UPDATE igs_ad_relemp_int_all
3765 SET error_code = 'E014', status = '3'
3766 WHERE interface_relemp_id = relns_emp_dtls_rec.interface_relemp_id;
3767 ELSE
3768 UPDATE igs_ad_relemp_int_all
3769 SET status = '1', error_code = NULL, match_ind ='18'
3770 WHERE interface_relemp_id = relns_emp_dtls_rec.interface_relemp_id;
3771 END IF;
3772 END IF;
3773 END;
3774 ELSIF l_rule = 'R' THEN
3775 IF Relns_Emp_Dtls_Rec.match_ind = '21' THEN
3776 DECLARE
3777 l_exists VARCHAR2(1):='N';
3778 l_count NUMBER(3);
3779 l_employer_party_id NUMBER;
3780
3781 BEGIN
3782 --ssomani corrected the validation 15 March 2001
3783
3784 validate_relns_emp_dtls(Relns_Emp_Dtls_Rec,p_rel_person_id,l_employer_party_id,l_error_code);
3785 IF l_error_code IS NOT NULL THEN
3786 UPDATE igs_ad_relemp_int_all
3787 SET status = '3', error_code = l_error_code
3788 WHERE interface_relemp_id = relns_emp_dtls_rec.interface_relemp_id;
3789 ELSE
3790 --Signature of Igs_Ad_Emp_Dtl_Pkg is changed to include HZ.K impact changes
3791 Igs_Ad_Emp_Dtl_Pkg.Update_Row (
3792 x_rowid => chk_dup_rec.Row_Id,
3793 x_employment_history_id => chk_dup_rec.Employment_History_Id,
3794 x_person_id => NVL(p_rel_person_id,chk_dup_rec.person_id),
3795 x_start_dt => NVL(relns_emp_dtls_rec.start_dt,chk_dup_rec.start_dt),
3796 x_end_dt => NVL(relns_emp_dtls_rec.end_dt,chk_dup_rec.end_dt),
3797 x_type_of_employment => NVL(relns_emp_dtls_rec.type_of_employment,chk_dup_rec.type_of_employment),
3798 x_fraction_of_employment => NVL(relns_emp_dtls_rec.fraction_of_employment,chk_dup_rec.fraction_of_employment),
3799 x_tenure_of_employment => NVL(relns_emp_dtls_rec.tenure_of_employment,chk_dup_rec.tenure_of_employment),
3800 x_position => NVL(relns_emp_dtls_rec.position,chk_dup_rec.position),
3801 x_occupational_title_code => NVL(relns_emp_dtls_rec.occupational_title_code,chk_dup_rec.occupational_title_code),
3802 x_occupational_title => chk_dup_rec.occupational_title,
3803 x_weekly_work_hours => NVL(relns_emp_dtls_rec.weekly_work_hours,chk_dup_rec.weekly_work_hours),
3804 x_comments => NVL(relns_emp_dtls_rec.comments,chk_dup_rec.comments),
3805 x_employer => NVL(relns_emp_dtls_rec.employer,chk_dup_rec.employer),
3806 x_employed_by_division_name => NVL(relns_emp_dtls_rec.employed_by_division_name,chk_dup_rec.employed_by_division_name),
3807 x_branch => NVL(relns_emp_dtls_rec.branch,chk_dup_rec.branch),
3808 x_military_rank => NVL(relns_emp_dtls_rec.military_rank,chk_dup_rec.military_rank),
3809 x_served => NVL(relns_emp_dtls_rec.served,chk_dup_rec.served),
3810 x_station => NVL(relns_emp_dtls_rec.station,chk_dup_rec.station),
3811 x_contact => NVL(relns_emp_dtls_rec.contact, chk_dup_rec.contact), -- Bug : 2037512
3812 x_msg_data => l_msg_data,
3813 x_return_status => l_return_status,
3814 x_object_version_number => chk_dup_rec.object_version_number,
3815 x_employed_by_party_id => NVL(l_employer_party_id,chk_dup_rec.employed_by_party_id),
3816 x_reason_for_leaving => NVL(relns_emp_dtls_rec.reason_for_leaving,chk_dup_rec.reason_for_leaving),
3817 x_mode => 'R'
3818 );
3819 IF l_return_Status IN ('E','U') THEN
3820 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
3821 IF (l_request_id IS NULL) THEN
3822 l_request_id := fnd_global.conc_request_id;
3823 END IF;
3824 l_label := 'igs.plsql.igs_ad_imp_008.prc_relns_emp_dtls.exception';
3825 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
3826 fnd_message.set_token('INTERFACE_ID',relns_emp_dtls_rec.interface_relemp_id);
3827 fnd_message.set_token('ERROR_CD','E014');
3828 l_debug_str := fnd_message.get || ' ' || l_msg_data;
3829 fnd_log.string_with_context( fnd_log.level_exception,
3830 l_label,
3831 l_debug_str, NULL,
3832 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id)
3833 );
3834 END IF;
3835
3836 IF l_enable_log = 'Y' THEN
3837 igs_ad_imp_001.logerrormessage(relns_emp_dtls_rec.interface_relemp_id,'E014','IGS_AD_RELEMP_INT_ALL');
3838 END IF;
3839 UPDATE igs_ad_relemp_int_all
3840 SET error_code = 'E014', status = '3'
3841 WHERE interface_relemp_id = relns_emp_dtls_rec.interface_relemp_id;
3842 ELSE
3843 UPDATE igs_ad_relemp_int_all
3844 SET error_code = NULL, status = '1', match_ind ='18'
3845 WHERE interface_relemp_id = relns_emp_dtls_rec.interface_relemp_id;
3846 END IF;
3847 END IF;
3848 END;
3849 END IF; /*match_ind = 21*/
3850 END IF; /*l_rule*/
3851 ELSE
3852 Crt_Relns_Emp_Dtls(Relns_Emp_Dtls_Rec, p_Rel_Person_Id);
3853 END IF;
3854 CLOSE chk_dup_cur;
3855 END;
3856 END LOOP;
3857 END;
3858 -- End of Prc_Relns_Emp_Dtls
3859
3860
3861 --
3862 -- Start of Main Procedure for Person Special Need
3863 --
3864
3865 PROCEDURE prc_pe_spl_needs (
3866 p_source_type_id IN NUMBER,
3867 p_batch_id IN NUMBER )
3868 AS
3869 /*
3870 || Created By : [email protected]
3871 || Created On : 06-Jul-2001
3872 || Purpose : This procedure is for importing person Special Need Information.
3873 || DLD: Person Interface DLD. Enh Bug# 2103692.
3874 || Known limitations, enhancements or remarks :
3875 || Change History :
3876 || Who When What
3877 || pkpatel 23-DEC-2002 Bug No: 2722027
3878 || The call to PRC_SPECIAL_NEEDS added and all the code was moved to IGSAD89B.pls
3879 || (reverse chronological order - newest change first)
3880 */
3881 --Start of the Main Processing
3882 BEGIN
3883 igs_ad_imp_011.prc_special_needs(
3884 p_source_type_id,
3885 p_batch_id);
3886
3887 END prc_pe_spl_needs;
3888 --
3889 -- End of Main Procedure PRC_PE_SPL_NEEDS
3890 --
3891
3892 -- Prc_Pe_Stat is now changed to Prc_Pe_Stat_Main
3893 -- Person Interface DLD. 2103692 -- ssawhney
3894
3895 PROCEDURE Prc_Pe_Stat_Main(
3896 p_source_type_id IN NUMBER,
3897 p_batch_id IN NUMBER )
3898 /*
3899 || Created By : ssawhney
3900 || Created On : 15 november
3901 || Purpose : Prc_Pe_Stat is now changed to Prc_Pe_Stat_Main
3902 ||
3903 || Change :
3904 || npalanis 6-JAN-2003 Bug : 2734697
3905 || code added to commit after import of every
3906 || 100 records .New variable l_processed_records added
3907 || ssawhney 27may bug 2385296. - the person id should be picked from IGS_AD_INTERFACE and not IGS_AD_STAT_INT.
3908 || the person id is now referred as stat_rec.pid.
3909 || kumma 02-JUL-2002 bug 2421786 remved the duplicate log messages. after a call to Validate_Person_Statistics
3910 || if there is error then it was logging a error message though it was already done
3911 || in called procedure Validate_Person_Statistics. also changed the interface_id to
3912 || interface_stat_id
3913 || npalanis 19-OCT-2002 Bug - 2608360
3914 || The stat package call is changed for transition of code classes to lookups
3915 */
3916 AS
3917
3918 -- modified as part of Person Interface DLD
3919 -- ssawhney 2193692
3920
3921 p_status VARCHAR2(1);
3922 p_error_code VARCHAR2(30);
3923 l_rowid VARCHAR2(25);
3924 l_var VARCHAR2(2000);
3925 l_var_person VARCHAR2(1);
3926 l_rule VARCHAR2(1);
3927 l_statistics_id NUMBER;
3928 l_processed_records NUMBER(5);
3929
3930 l_prog_label VARCHAR2(100);
3931 l_label VARCHAR2(100);
3932 l_debug_str VARCHAR2(2000);
3933 l_enable_log VARCHAR2(1);
3934 l_request_id NUMBER;
3935 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
3936
3937 CURSOR per_stat(cp_interface_run_id igs_ad_interface_all.interface_run_id%TYPE) IS
3938 SELECT mi.*, i.person_id pid
3939 FROM igs_ad_stat_int_all mi, igs_ad_interface_all i
3940 WHERE mi.interface_run_id = cp_interface_run_id
3941 AND mi.interface_id = i.interface_id
3942 AND i.interface_run_id = cp_interface_run_id
3943 AND mi.status = '2'
3944 AND i.status IN ('1','4');
3945
3946 stat_rec per_stat%ROWTYPE;
3947 l_error_code VARCHAR2(30);
3948 l_status VARCHAR2(10);
3949 l_success VARCHAR2(1);
3950
3951 l_return_status VARCHAR2(1);
3952 l_msg_data VARCHAR2(2000);
3953 l_msg_count NUMBER;
3954 l_party_last_update_date DATE;
3955 l_person_profile_id NUMBER;
3956 l_default_date DATE := IGS_GE_DATE.IGSDATE('4712/12/01');
3957
3958 PROCEDURE Validate_Person_Statistics(p_per_stat per_stat%ROWTYPE, p_success OUT NOCOPY VARCHAR2, p_error_code OUT NOCOPY VARCHAR2)
3959 IS
3960 l_var VARCHAR2(1);
3961 l_birth_date DATE;
3962
3963 BEGIN
3964
3965 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
3966
3967 IF (l_request_id IS NULL) THEN
3968 l_request_id := fnd_global.conc_request_id;
3969 END IF;
3970
3971 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.begin_validate_person_statistics';
3972 l_debug_str := 'Igs_Ad_Imp_008.Validate_Person_Statistics';
3973
3974 fnd_log.string_with_context( fnd_log.level_procedure,
3975 l_label,
3976 l_debug_str, NULL,
3977 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
3978 END IF;
3979
3980 IF p_per_stat.RELIGION_CD IS NOT NULL THEN
3981 -- kumma, added the condition in where clause that the code should not be marked as closed.
3982 -- bug 2421786
3983 IF NOT
3984 (igs_pe_pers_imp_001.validate_lookup_type_code('PE_RELIGION',p_per_stat.religion_cd,8405))
3985 THEN
3986 p_success := 'N';
3987 p_error_code := 'E205';
3988
3989 IF l_enable_log = 'Y' THEN
3990 igs_ad_imp_001.logerrormessage(p_per_stat.interface_stat_id,'E205','IGS_AD_STAT_INT_ALL');
3991 END IF;
3992
3993 UPDATE igs_ad_stat_int_all
3994 SET error_code = 'E205',
3995 status = '3'
3996 WHERE interface_stat_id = p_per_stat.interface_stat_id;
3997 RETURN;
3998 END IF;
3999 END IF;
4000
4001 IF p_per_stat.MARITAL_STATUS IS NOT NULL THEN
4002 IF NOT
4003 (igs_pe_pers_imp_001.validate_lookup_type_code('MARITAL_STATUS',p_per_stat.marital_status,222))
4004 THEN
4005 --Bug Id : 2138382
4006 p_success := 'N';
4007 p_error_code := 'E206';
4008
4009 IF l_enable_log = 'Y' THEN
4010 igs_ad_imp_001.logerrormessage(p_per_stat.interface_stat_id,'E206','IGS_AD_STAT_INT_ALL');
4011 END IF;
4012
4013 UPDATE igs_ad_stat_int_all
4014 SET error_code = 'E206',
4015 status = '3'
4016 WHERE interface_stat_id = p_per_stat.interface_stat_id;
4017 RETURN;
4018 END IF;
4019 END IF;
4020
4021 --kumma, adding validations for the MARITAL_STATUS_EFFECTIVE_DATE, this date should not be less than the
4022 -- date of birth, bug 2421786
4023
4024 IF p_per_stat.MARITAL_STATUS_EFFECTIVE_DATE IS NOT NULL THEN
4025 DECLARE
4026 CURSOR c_mar_eff_dt(p_person_id igs_pe_person.person_id%TYPE) IS
4027 SELECT BIRTH_DATE
4028 FROM IGS_PE_PERSON_BASE_V WHERE PERSON_ID =p_person_id;
4029
4030 BEGIN
4031 OPEN c_mar_eff_dt(p_per_stat.pid);
4032 FETCH c_mar_eff_dt INTO l_birth_date;
4033 CLOSE c_mar_eff_dt;
4034 IF l_birth_date IS NOT NULL THEN
4035 IF p_per_stat.MARITAL_STATUS_EFFECTIVE_DATE < l_birth_date THEN
4036 raise no_data_found;
4037 END IF;
4038 END IF;
4039 EXCEPTION
4040 WHEN OTHERS THEN
4041 p_success := 'N';
4042 p_error_code := 'E277';
4043
4044 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4045
4046 IF (l_request_id IS NULL) THEN
4047 l_request_id := fnd_global.conc_request_id;
4048 END IF;
4049
4050 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception '||'E277';
4051
4052 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4053 fnd_message.set_token('INTERFACE_ID',p_per_stat.interface_stat_id);
4054 fnd_message.set_token('ERROR_CD','E277');
4055
4056 l_debug_str := fnd_message.get || ' ' || SQLERRM;
4057
4058 fnd_log.string_with_context( fnd_log.level_exception,
4059 l_label,
4060 l_debug_str, NULL,
4061 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4062 END IF;
4063
4064 IF l_enable_log = 'Y' THEN
4065 igs_ad_imp_001.logerrormessage(p_per_stat.interface_stat_id,'E277','IGS_AD_STAT_INT_ALL');
4066 END IF;
4067
4068 UPDATE igs_ad_stat_int_all
4069 SET error_code = 'E277',
4070 status = '3'
4071 WHERE interface_stat_id = p_per_stat.interface_stat_id;
4072 RETURN;
4073 END;
4074 END IF;
4075
4076 -- code for country_cd3 and resid_stat_id to be removed, as this column is obsoleted from the table
4077 -- ssawhney Person Interface DLD. 2103692
4078
4079 IF p_per_stat.ETHNIC_ORIGIN IS NOT NULL THEN
4080 IF NOT
4081 (igs_pe_pers_imp_001.validate_lookup_type_code('IGS_ETHNIC_ORIGIN',p_per_stat.ETHNIC_ORIGIN,8405))
4082 THEN
4083 p_success := 'N';
4084 p_error_code := 'E207';
4085
4086 IF l_enable_log = 'Y' THEN
4087 igs_ad_imp_001.logerrormessage(p_per_stat.interface_stat_id,'E207','IGS_AD_STAT_INT_ALL');
4088 END IF;
4089
4090 UPDATE igs_ad_stat_int_all
4091 SET error_code = 'E207',
4092 status = '3'
4093 WHERE interface_stat_id = p_per_stat.interface_stat_id;
4094
4095 RETURN;
4096 END IF;
4097 END IF;
4098 -- All the validations has been moved out NOCOPY to HZ packages
4099 p_success := 'Y';
4100 EXCEPTION
4101 WHEN OTHERS THEN
4102 p_success := 'N';
4103 END;
4104 -- End local Proc Validate_Person_Statistics
4105 --Local procedure to validate descriptive flexfield
4106
4107 PROCEDURE Validate_desc_flex(stat_rec IN per_stat%ROWTYPE,
4108 p_success OUT NOCOPY VARCHAR2)
4109 AS
4110 BEGIN
4111 IF NOT igs_ad_imp_018.validate_desc_flex(
4112 p_attribute_category =>stat_rec.attribute_category,
4113 p_attribute1 =>stat_rec.attribute1 ,
4114 p_attribute2 =>stat_rec.attribute2 ,
4115 p_attribute3 =>stat_rec.attribute3 ,
4116 p_attribute4 =>stat_rec.attribute4 ,
4117 p_attribute5 =>stat_rec.attribute5 ,
4118 p_attribute6 =>stat_rec.attribute6 ,
4119 p_attribute7 =>stat_rec.attribute7 ,
4120 p_attribute8 =>stat_rec.attribute8 ,
4121 p_attribute9 =>stat_rec.attribute9 ,
4122 p_attribute10 =>stat_rec.attribute10 ,
4123 p_attribute11 =>stat_rec.attribute11 ,
4124 p_attribute12 =>stat_rec.attribute12 ,
4125 p_attribute13 =>stat_rec.attribute13 ,
4126 p_attribute14 =>stat_rec.attribute14 ,
4127 p_attribute15 =>stat_rec.attribute15 ,
4128 p_attribute16 =>stat_rec.attribute16 ,
4129 p_attribute17 =>stat_rec.attribute17 ,
4130 p_attribute18 =>stat_rec.attribute18 ,
4131 p_attribute19 =>stat_rec.attribute19 ,
4132 p_attribute20 =>stat_rec.attribute20 ,
4133 p_desc_flex_name =>'IGS_PE_PERS_STAT' ) THEN
4134
4135
4136 p_success := 'N';
4137 RAISE NO_DATA_FOUND;
4138 ELSE
4139 p_success := 'Y' ;
4140
4141 END IF;
4142 EXCEPTION
4143 WHEN NO_DATA_FOUND THEN
4144 L_MSG_DATA := SQLERRM;
4145 UPDATE IGS_AD_STAT_INT_ALL
4146 SET status = '3',
4147 error_code = 'E170'
4148 WHERE interface_id = stat_rec.INTERFACE_ID;
4149
4150 -- there was a call to update IGS_AD_INTERFACE with status=3, that is not required.
4151 -- UPDATE IGS_AD_INTERFACE
4152
4153 -- Call Log detail
4154
4155 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4156
4157 IF (l_request_id IS NULL) THEN
4158 l_request_id := fnd_global.conc_request_id;
4159 END IF;
4160
4161 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception '||'E170';
4162
4163 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4164 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4165 fnd_message.set_token('ERROR_CD','E170');
4166
4167 l_debug_str := fnd_message.get || ' ' || SQLERRM;
4168
4169 fnd_log.string_with_context( fnd_log.level_exception,
4170 l_label,
4171 l_debug_str, NULL,
4172 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4173 END IF;
4174
4175 IF l_enable_log = 'Y' THEN
4176 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E170','IGS_AD_STAT_INT_ALL');
4177 END IF;
4178
4179
4180
4181 END Validate_desc_flex;
4182
4183 PROCEDURE Crt_Pe_Stat( stat_rec IN per_stat%ROWTYPE,
4184 p_error_code OUT NOCOPY VARCHAR2,
4185 p_status OUT NOCOPY VARCHAR2) AS
4186 l_statistics_id NUMBER;
4187 l_rowid VARCHAR2(25);
4188 l_success VARCHAR2(1);
4189 l_return_status VARCHAR2(1);
4190 l_msg_data VARCHAR2(2000);
4191 l_msg_count NUMBER;
4192 l_party_last_update_date DATE;
4193 l_person_profile_id NUMBER;
4194 l_error_code VARCHAR2(30);
4195 l_object_version_number NUMBER;
4196
4197
4198 BEGIN
4199
4200 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
4201
4202 IF (l_request_id IS NULL) THEN
4203 l_request_id := fnd_global.conc_request_id;
4204 END IF;
4205
4206 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.begin_crt_pe_stat';
4207 l_debug_str := 'Igs_Ad_Imp_008.Crt_Pe_Stat';
4208
4209 fnd_log.string_with_context( fnd_log.level_procedure,
4210 l_label,
4211 l_debug_str, NULL,
4212 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4213 END IF;
4214
4215 Validate_Person_Statistics(p_per_stat => stat_rec, p_success => l_success, p_error_code =>l_error_code);
4216
4217 IF l_success = 'Y' THEN
4218 --Validation check of Descriptive Flexfield
4219 -- Added as a part of bug number 2203778
4220 l_success := NULL;
4221 Validate_desc_flex(stat_rec ,l_success );
4222 IF l_success = 'Y' THEN
4223
4224 --Bayadav :Changed the columns values getting passed for attribute1 to attribute20 from null
4225 --to new flexfield columns added in iGS_AD_STAT_INT table to pass these flexfields values in newly added
4226 -- felxfield in IGS_PE_STAT_DETAILS table as a part of bug 2203778
4227
4228 igs_pe_stat_pkg.insert_row(
4229 X_ACTION=> 'INSERT',
4230 X_ROWID=> l_rowid,
4231 X_PERSON_ID => stat_rec.pid, --stat_rec.person_id,
4232 X_ETHNIC_ORIGIN_ID =>stat_rec.ethnic_origin,
4233 X_MARITAL_STATUS => stat_rec.marital_status,
4234 X_MARITAL_STAT_EFFECT_DT => stat_rec.marital_status_effective_date,
4235 X_ANN_FAMILY_INCOME=> NULL,
4236 X_NUMBER_IN_FAMILY=> NULL,
4237 X_CONTENT_SOURCE_TYPE => 'USER_ENTERED',
4238 X_INTERNAL_FLAG=> NULL,
4239 X_PERSON_NUMBER => NULL,
4240 X_EFFECTIVE_START_DATE => SYSDATE,
4241 X_EFFECTIVE_END_DATE => NULL,
4242 X_ETHNIC_ORIGIN => NULL,
4243 X_RELIGION=> stat_rec.religion_cd,
4244 X_NEXT_TO_KIN => NULL,
4245 X_NEXT_TO_KIN_MEANING => NULL,
4246 X_PLACE_OF_BIRTH => stat_rec.place_of_birth,
4247 X_SOCIO_ECO_STATUS => NULL,
4248 X_SOCIO_ECO_STATUS_DESC => NULL,
4249 X_FURTHER_EDUCATION => NULL,
4250 X_FURTHER_EDUCATION_DESC => NULL,
4251 X_IN_STATE_TUITION=> NULL,
4252 X_TUITION_ST_DATE=> NULL,
4253 X_TUITION_END_DATE => NULL,
4254 X_PERSON_INITIALS => NULL,
4255 X_PRIMARY_CONTACT_ID => NULL,
4256 X_PERSONAL_INCOME => NULL,
4257 X_HEAD_OF_HOUSEHOLD_FLAG => NULL,
4258 X_CONTENT_SOURCE_NUMBER => NULL,
4259 X_HZ_PARTIES_OVN => l_object_version_number,
4260 X_attribute_category => stat_rec.attribute_category,
4261 X_attribute1 => stat_rec.attribute1 ,
4262 X_attribute2 => stat_rec.attribute2 ,
4263 X_attribute3 => stat_rec.attribute3 ,
4264 X_attribute4 => stat_rec.attribute4 ,
4265 X_attribute5 => stat_rec.attribute5 ,
4266 X_attribute6 => stat_rec.attribute6 ,
4267 X_attribute7 => stat_rec.attribute7 ,
4268 X_attribute8 => stat_rec.attribute8 ,
4269 X_attribute9 => stat_rec.attribute9 ,
4270 X_attribute10 => stat_rec.attribute10 ,
4271 X_attribute11 => stat_rec.attribute11 ,
4272 X_attribute12 => stat_rec.attribute12 ,
4273 X_attribute13 => stat_rec.attribute13 ,
4274 X_attribute14 => stat_rec.attribute14 ,
4275 X_attribute15 => stat_rec.attribute15 ,
4276 X_attribute16 => stat_rec.attribute16 ,
4277 X_attribute17 => stat_rec.attribute17 ,
4278 X_attribute18 => stat_rec.attribute18 ,
4279 X_attribute19 => stat_rec.attribute19 ,
4280 X_attribute20 => stat_rec.attribute20 ,
4281 X_GLOBAL_ATTRIBUTE_CATEGORY => NULL,
4282 X_GLOBAL_ATTRIBUTE1 => NULL,
4283 X_GLOBAL_ATTRIBUTE2 => NULL,
4284 X_GLOBAL_ATTRIBUTE3 => NULL,
4285 X_GLOBAL_ATTRIBUTE4 => NULL,
4286 X_GLOBAL_ATTRIBUTE5 => NULL,
4287 X_GLOBAL_ATTRIBUTE6 => NULL,
4288 X_GLOBAL_ATTRIBUTE7 => NULL,
4289 X_GLOBAL_ATTRIBUTE8 => NULL,
4290 X_GLOBAL_ATTRIBUTE9 => NULL,
4291 X_GLOBAL_ATTRIBUTE10 => NULL,
4292 X_GLOBAL_ATTRIBUTE11 => NULL,
4293 X_GLOBAL_ATTRIBUTE12 => NULL,
4294 X_GLOBAL_ATTRIBUTE13 => NULL,
4295 X_GLOBAL_ATTRIBUTE14 => NULL,
4296 X_GLOBAL_ATTRIBUTE15 => NULL,
4297 X_GLOBAL_ATTRIBUTE16 => NULL,
4298 X_GLOBAL_ATTRIBUTE17 => NULL,
4299 X_GLOBAL_ATTRIBUTE18 => NULL,
4300 X_GLOBAL_ATTRIBUTE19 => NULL,
4301 X_GLOBAL_ATTRIBUTE20 => NULL,
4302 X_PARTY_LAST_UPDATE_DATE => L_party_last_update_date,
4303 X_PERSON_PROFILE_ID=> l_person_profile_id,
4304 X_MATR_CAL_TYPE => NULL,
4305 X_MATR_SEQUENCE_NUMBER => NULL,
4306 X_INIT_CAL_TYPE => NULL,
4307 X_INIT_SEQUENCE_NUMBER => NULL,
4308 X_RECENT_CAL_TYPE => NULL,
4309 X_RECENT_SEQUENCE_NUMBER => NULL,
4310 X_CATALOG_CAL_TYPE => NULL,
4311 X_CATALOG_SEQUENCE_NUMBER => NULL,
4312 Z_RETURN_STATUS => l_return_status,
4313 Z_MSG_COUNT => l_msg_count,
4314 Z_MSG_DATA => l_msg_data,
4315 X_BIRTH_CNTRY_RESN_CODE => NULL --- prbhardw
4316 );
4317
4318 IF l_return_status IN('E','U') THEN
4319 p_status :='3';
4320 p_error_code := 'E005';
4321
4322 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4323
4324 IF (l_request_id IS NULL) THEN
4325 l_request_id := fnd_global.conc_request_id;
4326 END IF;
4327
4328 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception '||'E005';
4329
4330 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4331 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4332 fnd_message.set_token('ERROR_CD','E005');
4333
4334 l_debug_str := fnd_message.get || ' ' || l_msg_data;
4335
4336 fnd_log.string_with_context( fnd_log.level_exception,
4337 l_label,
4338 l_debug_str, NULL,
4339 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4340 END IF;
4341
4342 IF l_enable_log = 'Y' THEN
4343 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E005','IGS_AD_STAT_INT_ALL');
4344 END IF;
4345 ELSE
4346 p_status :='1';
4347 p_error_code := NULL;
4348 END IF;
4349 ELSE
4350 --In case descriptive validation failed
4351 p_status := '3';
4352 p_error_code := 'E170';
4353
4354 END IF;
4355
4356 -- else part will be required now. ssawhney.
4357 ELSE
4358 p_status := '3';
4359 p_error_code := l_error_code; -- assign to p_error_code and this will be used down the line
4360
4361 END IF;
4362
4363
4364 EXCEPTION
4365
4366 WHEN OTHERS THEN
4367 l_msg_data := SQLERRM;
4368 p_status :='3';
4369 p_error_code := 'E005';
4370
4371
4372 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4373
4374 IF (l_request_id IS NULL) THEN
4375 l_request_id := fnd_global.conc_request_id;
4376 END IF;
4377
4378 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception2';
4379
4380 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4381 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4382 fnd_message.set_token('ERROR_CD','E005');
4383
4384 l_debug_str := fnd_message.get || ' ' || SQLERRM;
4385
4386 fnd_log.string_with_context( fnd_log.level_exception,
4387 l_label,
4388 l_debug_str, NULL,
4389 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4390 END IF;
4391
4392 IF l_enable_log = 'Y' THEN
4393 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E005','IGS_AD_STAT_INT_ALL');
4394 END IF;
4395
4396 END Crt_Pe_Stat; -- end of local procedure crt_pe_stat
4397
4398 -- main procedure begins
4399 BEGIN
4400 -- Call Log header
4401 l_processed_records := 0;
4402 l_prog_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main';
4403 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.';
4404 l_enable_log := igs_ad_imp_001.g_enable_log;
4405 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
4406
4407 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
4408
4409 IF (l_request_id IS NULL) THEN
4410 l_request_id := fnd_global.conc_request_id;
4411 END IF;
4412
4413 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.begin';
4414 l_debug_str := 'Igs_Ad_Imp_008.Prc_Pe_Stat_Main';
4415
4416 fnd_log.string_with_context( fnd_log.level_procedure,
4417 l_label,
4418 l_debug_str, NULL,
4419 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4420 END IF;
4421
4422 l_rule := Igs_Ad_Imp_001.find_source_cat_rule (p_source_type_id, 'PERSON_STATISTICS');
4423 --ssomani, corrected the looping 15 March 2001
4424
4425 --1. If rule is E or I, then if the match_ind is not null, the combination is invalid
4426 IF l_rule IN ('E','I') THEN
4427 UPDATE IGS_AD_STAT_INT_all
4428 SET status = '3',
4429 ERROR_CODE = 'E695' -- Error code depicting incorrect combination
4430 WHERE match_ind IS NOT NULL
4431 AND status = '2'
4432 AND interface_run_id = l_interface_run_id;
4433 END IF;
4434
4435 --2 If rule is E and duplicate exists, update match_ind to 19 and status to 1
4436 IF l_rule = 'E' THEN
4437 UPDATE IGS_AD_STAT_INT_all mi
4438 SET status = '1',
4439 match_ind = '19'
4440 WHERE mi.interface_run_id = l_interface_run_id
4441 AND mi.status = '2'
4442 AND EXISTS ( SELECT '1'
4443 FROM hz_parties hp, igs_ad_interface_all ii
4444 WHERE ii.interface_run_id = l_interface_run_id
4445 AND ii.interface_id = mi.interface_id
4446 AND ii.person_id = hp.party_id);
4447 END IF;
4448
4449 --3 If rule is R and there match_ind is 18,19,22 or 23 then the records must have been
4450 -- processed in prior runs and didn't get updated .. update to status 1
4451 IF l_rule = 'R' THEN
4452 UPDATE IGS_AD_STAT_INT_all
4453 SET status = '1'
4454 WHERE interface_run_id = l_interface_run_id
4455 AND match_ind IN ('18','19','22','23')
4456 AND status = '2';
4457 END IF;
4458
4459 --4 If rule is R and match_ind is neither 21 nor 25 then error
4460 IF l_rule = 'R' THEN
4461 UPDATE IGS_AD_STAT_INT_all
4462 SET status = '3',
4463 ERROR_CODE = 'E695'
4464 WHERE interface_run_id = l_interface_run_id
4465 AND status = '2'
4466 AND (match_ind IS NOT NULL AND match_ind NOT IN ('21','25'));
4467 END IF;
4468
4469 --5 If rule is R, set duplicated records with no discrepancy to status 1 and match_ind 23
4470 IF l_rule = 'R' THEN
4471 UPDATE IGS_AD_STAT_INT_all mi
4472 SET status = '1',
4473 match_ind = '23'
4474 WHERE mi.interface_run_id = l_interface_run_id
4475 AND mi.match_ind IS NULL
4476 AND mi.status = '2'
4477 AND EXISTS ( SELECT 1
4478 FROM hz_person_profiles pp,
4479 igs_pe_stat_details sd,
4480 igs_ad_interface_all ii
4481 WHERE ii.interface_run_id = l_interface_run_id AND
4482 ii.interface_id = mi.interface_id AND
4483 ii.person_id = pp.party_id AND
4484 sd.person_id(+) = pp.party_id AND
4485 SYSDATE BETWEEN pp.effective_start_date AND NVL(pp.effective_end_date, SYSDATE) AND
4486 NVL(pp.declared_ethnicity,'*') = NVL(mi.ethnic_origin,'*') AND
4487 NVL(pp.marital_status,'*') = NVL(UPPER(mi.marital_status),'*') AND
4488 NVL(sd.religion_cd,'*') = NVL(mi.religion_cd,'*') AND
4489 NVL(TRUNC(pp.marital_status_effective_date), l_default_date)
4490 = NVL(TRUNC(mi.marital_status_effective_date),l_default_date)AND
4491 NVL(UPPER(pp.place_of_birth),'*') = NVL(UPPER(mi.place_of_birth),'*') AND
4492 NVL(UPPER(sd.attribute1),'*') = NVL(UPPER(mi.attribute1),'*') AND
4493 NVL(UPPER(sd.attribute2),'*') = NVL(UPPER(mi.attribute2),'*') AND
4494 NVL(UPPER(sd.attribute3),'*') = NVL(UPPER(mi.attribute3),'*') AND
4495 NVL(UPPER(sd.attribute4),'*') = NVL(UPPER(mi.attribute4),'*') AND
4496 NVL(UPPER(sd.attribute5),'*') = NVL(UPPER(mi.attribute5),'*') AND
4497 NVL(UPPER(sd.attribute6),'*') = NVL(UPPER(mi.attribute6),'*') AND
4498 NVL(UPPER(sd.attribute7),'*') = NVL(UPPER(mi.attribute7),'*') AND
4499 NVL(UPPER(sd.attribute8),'*') = NVL(UPPER(mi.attribute8),'*') AND
4500 NVL(UPPER(sd.attribute9),'*') = NVL(UPPER(mi.attribute9),'*') AND
4501 NVL(UPPER(sd.attribute10),'*') = NVL(UPPER(mi.attribute10),'*') AND
4502 NVL(UPPER(sd.attribute11),'*') = NVL(UPPER(mi.attribute11),'*') AND
4503 NVL(UPPER(sd.attribute12),'*') = NVL(UPPER(mi.attribute12),'*') AND
4504 NVL(UPPER(sd.attribute13),'*') = NVL(UPPER(mi.attribute13),'*') AND
4505 NVL(UPPER(sd.attribute14),'*') = NVL(UPPER(mi.attribute14),'*') AND
4506 NVL(UPPER(sd.attribute15),'*') = NVL(UPPER(mi.attribute15),'*') AND
4507 NVL(UPPER(sd.attribute16),'*') = NVL(UPPER(mi.attribute16),'*') AND
4508 NVL(UPPER(sd.attribute17),'*') = NVL(UPPER(mi.attribute17),'*') AND
4509 NVL(UPPER(sd.attribute18),'*') = NVL(UPPER(mi.attribute18),'*') AND
4510 NVL(UPPER(sd.attribute19),'*') = NVL(UPPER(mi.attribute19),'*') AND
4511 NVL(UPPER(sd.attribute20),'*') = NVL(UPPER(mi.attribute20),'*') AND
4512 NVL(UPPER(sd.attribute_category),'*') = NVL(UPPER(mi.attribute_category),'*')
4513 );
4514 END IF;
4515
4516 --6 If rule is R records still exist, they are duplicates and have discrepancy .. update status=3,match_ind=20
4517 IF l_rule = 'R' THEN
4518 UPDATE IGS_AD_STAT_INT_all mi
4519 SET status = '3',
4520 match_ind = '20'
4521 WHERE mi.interface_run_id = l_interface_run_id
4522 AND mi.match_ind IS NULL
4523 AND mi.status = '2'
4524 AND EXISTS (SELECT '1'
4525 FROM hz_parties hp,
4526 igs_ad_interface_all ii
4527 WHERE ii.interface_run_id = l_interface_run_id
4528 AND ii.interface_id = mi.interface_id
4529 AND ii.person_id = hp.party_id);
4530 END IF;
4531
4532 FOR stat_rec IN per_stat(l_interface_run_id) LOOP
4533 DECLARE
4534 CURSOR chk_dup_cur(cp_person_id igs_pe_stat_v.person_id%TYPE) IS
4535 SELECT
4536 p.rowid row_id,
4537 pp.person_profile_id,
4538 p.party_id person_id,
4539 p.party_number person_number,
4540 pp.effective_start_date,
4541 pp.effective_end_date,
4542 pp.declared_ethnicity ethnic_origin_id,
4543 pp.marital_status,
4544 pp.marital_status_effective_date,
4545 pp.internal_flag,
4546 sd.religion_cd religion,
4547 sd.next_to_kin,
4548 pp.place_of_birth,
4549 sd.socio_eco_cd socio_eco_status,
4550 sd.further_education_cd further_education,
4551 pp.household_size number_in_family,
4552 pp.household_income ann_family_income,
4553 sd.in_state_tuition,
4554 sd.tuition_st_date,
4555 sd.tuition_end_date,
4556 sd.matr_cal_type,
4557 sd.matr_sequence_number,
4558 sd.init_cal_type,
4559 sd.init_sequence_number,
4560 sd.recent_cal_type,
4561 sd.recent_sequence_number,
4562 sd.catalog_cal_type,
4563 sd.catalog_sequence_number,
4564 sd.attribute_category attribute_category,
4565 sd.attribute1 attribute1,
4566 sd.attribute2 attribute2,
4567 sd.attribute3 attribute3,
4568 sd.attribute4 attribute4,
4569 sd.attribute5 attribute5,
4570 sd.attribute6 attribute6,
4571 sd.attribute7 attribute7,
4572 sd.attribute8 attribute8,
4573 sd.attribute9 attribute9,
4574 sd.attribute10 attribute10,
4575 sd.attribute11 attribute11,
4576 sd.attribute12 attribute12,
4577 sd.attribute13 attribute13,
4578 sd.attribute14 attribute14,
4579 sd.attribute15 attribute15,
4580 sd.attribute16 attribute16,
4581 sd.attribute17 attribute17,
4582 sd.attribute18 attribute18,
4583 sd.attribute19 attribute19,
4584 sd.attribute20 attribute20,
4585 pp.global_attribute_category,
4586 pp.global_attribute1,
4587 pp.global_attribute2,
4588 pp.global_attribute3,
4589 pp.global_attribute4,
4590 pp.global_attribute5,
4591 pp.global_attribute6,
4592 pp.global_attribute7,
4593 pp.global_attribute8,
4594 pp.global_attribute9,
4595 pp.global_attribute10,
4596 pp.global_attribute11,
4597 pp.global_attribute12,
4598 pp.global_attribute13,
4599 pp.global_attribute14,
4600 pp.global_attribute15,
4601 pp.global_attribute16,
4602 pp.global_attribute17,
4603 pp.global_attribute18,
4604 pp.global_attribute19,
4605 pp.global_attribute20,
4606 pp.person_initials,
4607 pp.primary_contact_id,
4608 pp.personal_income,
4609 pp.head_of_household_flag,
4610 pp.content_source_type,
4611 pp.content_source_number,
4612 p.object_version_number object_version_number
4613 FROM
4614 hz_person_profiles pp,
4615 igs_pe_stat_details sd,
4616 hz_parties p
4617 WHERE
4618 sd.person_id(+) = p.party_id AND
4619 pp.party_id = p.party_id AND
4620 SYSDATE BETWEEN pp.effective_start_date AND NVL(pp.effective_end_date, SYSDATE) AND
4621 p.party_id = cp_person_id;
4622
4623 chk_dup_rec chk_dup_cur%ROWTYPE;
4624 BEGIN
4625 l_processed_records := l_processed_records + 1 ;
4626 -- kumma, 2421786
4627 -- marital status and ethnic origin are made case insensitive
4628 stat_rec.marital_status := UPPER(stat_rec.marital_status);
4629 stat_rec.ethnic_origin := UPPER(stat_rec.ethnic_origin);
4630 stat_rec.marital_status_effective_date := TRUNC(stat_rec.marital_status_effective_date);
4631
4632 OPEN chk_dup_cur(stat_rec.pid);
4633 FETCH chk_dup_cur INTO chk_dup_rec;
4634 IF chk_dup_cur%FOUND THEN
4635 IF l_rule = 'I' THEN
4636 BEGIN
4637
4638 Validate_Person_Statistics(p_per_stat => stat_rec, p_success => l_success, p_error_code=>l_error_code);
4639 IF l_success = 'Y' THEN
4640 -- ssawhney 2203778 person_id was passed into person number
4641 -- and ethenic_origin_id is not a field in int tables
4642
4643 --Validation check of Descriptive Flexfield
4644 -- Added as a part of bug number 2203778
4645 l_success := NULL;
4646 Validate_desc_flex(stat_rec ,l_success );
4647
4648 IF l_success = 'Y' THEN
4649 IGS_PE_STAT_PKG.Update_Row(
4650 X_ACTION => 'UPDATE',
4651 x_rowid => chk_dup_rec.row_id,
4652 x_person_id => stat_rec.pid, -- stat_rec.person_id ,
4653 x_ethnic_origin_id => NVL(stat_rec.ethnic_origin,chk_dup_rec.ethnic_origin_id), -- BUG ID: 2138382
4654 x_marital_status => NVL(stat_rec.marital_status,chk_dup_rec.marital_status),
4655 x_marital_stat_effect_dt => NVL(stat_rec.marital_status_effective_date,TRUNC(chk_dup_rec.marital_status_effective_date)),
4656 x_ann_family_income => chk_dup_rec.ann_family_income,
4657 x_number_in_family => chk_dup_rec.number_in_family,
4658 x_content_source_type => 'USER_ENTERED',
4659 x_internal_flag => chk_dup_rec.internal_flag,
4660 x_person_number => chk_dup_rec.person_number,
4661 x_effective_start_date => TRUNC(chk_dup_rec.effective_start_date),
4662 x_effective_end_date => TRUNC(chk_dup_rec.effective_end_date),
4663 x_ethnic_origin => NULL,
4664 x_religion => NVL(stat_rec.religion_cd,chk_dup_rec.religion),
4665 x_next_to_kin => chk_dup_rec.next_to_kin,
4666 x_next_to_kin_meaning => NULL,
4667 x_place_of_birth => NVL(stat_rec.place_of_birth,chk_dup_rec.place_of_birth),
4668 x_socio_eco_status => chk_dup_rec.socio_eco_status,
4669 x_socio_eco_status_desc => NULL,
4670 x_further_education => chk_dup_rec.further_education,
4671 x_further_education_desc => NULL,
4672 x_in_state_tuition => chk_dup_rec.in_state_tuition,
4673 x_tuition_st_date => TRUNC(chk_dup_rec.tuition_st_date),
4674 x_tuition_end_date => TRUNC(chk_dup_rec.tuition_end_date),
4675 x_person_initials => chk_dup_rec.person_initials,
4676 x_primary_contact_id => chk_dup_rec.primary_contact_id,
4677 x_personal_income => chk_dup_rec.personal_income,
4678 x_head_of_household_flag => chk_dup_rec.head_of_household_flag,
4679 x_content_source_number => chk_dup_rec.content_source_number,
4680 x_attribute_category => NVL(stat_rec.attribute_category,chk_dup_rec.attribute_category),
4681 x_hz_parties_ovn => chk_dup_rec.object_version_number,
4682 x_attribute1 => NVL(stat_rec.attribute1,chk_dup_rec.attribute1),
4683 x_attribute2 => NVL(stat_rec.attribute2,chk_dup_rec.attribute2),
4684 x_attribute3 => NVL(stat_rec.attribute3,chk_dup_rec.attribute3),
4685 x_attribute4 => NVL(stat_rec.attribute4,chk_dup_rec.attribute4),
4686 x_attribute5 => NVL(stat_rec.attribute5,chk_dup_rec.attribute5),
4687 x_attribute6 => NVL(stat_rec.attribute6,chk_dup_rec.attribute6),
4688 x_attribute7 => NVL(stat_rec.attribute7,chk_dup_rec.attribute7),
4689 x_attribute8 => NVL(stat_rec.attribute8,chk_dup_rec.attribute8),
4690 x_attribute9 => NVL(stat_rec.attribute9,chk_dup_rec.attribute9),
4691 x_attribute10 => NVL(stat_rec.attribute10,chk_dup_rec.attribute10),
4692 x_attribute11 => NVL(stat_rec.attribute11,chk_dup_rec.attribute11),
4693 x_attribute12 => NVL(stat_rec.attribute12,chk_dup_rec.attribute12),
4694 x_attribute13 => NVL(stat_rec.attribute13,chk_dup_rec.attribute13),
4695 x_attribute14 => NVL(stat_rec.attribute14,chk_dup_rec.attribute14),
4696 x_attribute15 => NVL(stat_rec.attribute15,chk_dup_rec.attribute15),
4697 x_attribute16 => NVL(stat_rec.attribute16,chk_dup_rec.attribute16),
4698 x_attribute17 => NVL(stat_rec.attribute17,chk_dup_rec.attribute17),
4699 x_attribute18 => NVL(stat_rec.attribute18,chk_dup_rec.attribute18),
4700 x_attribute19 => NVL(stat_rec.attribute19,chk_dup_rec.attribute19),
4701 x_attribute20 => NVL(stat_rec.attribute20,chk_dup_rec.attribute20),
4702 x_global_attribute_category => chk_dup_rec.global_attribute_category,
4703 x_global_attribute1 => chk_dup_rec.global_attribute1,
4704 x_global_attribute2=> chk_dup_rec.global_attribute1,
4705 x_global_attribute3=> chk_dup_rec.global_attribute1,
4706 x_global_attribute4=> chk_dup_rec.global_attribute1,
4707 x_global_attribute5=> chk_dup_rec.global_attribute1,
4708 x_global_attribute6=> chk_dup_rec.global_attribute1,
4709 x_global_attribute7=> chk_dup_rec.global_attribute1,
4710 x_global_attribute8=> chk_dup_rec.global_attribute1,
4711 x_global_attribute9=> chk_dup_rec.global_attribute1,
4712 x_global_attribute10=> chk_dup_rec.global_attribute1,
4713 x_global_attribute11=> chk_dup_rec.global_attribute1,
4714 x_global_attribute12=> chk_dup_rec.global_attribute1,
4715 x_global_attribute13=> chk_dup_rec.global_attribute1,
4716 x_global_attribute14=> chk_dup_rec.global_attribute1,
4717 x_global_attribute15=> chk_dup_rec.global_attribute1,
4718 x_global_attribute16=> chk_dup_rec.global_attribute1,
4719 x_global_attribute17=> chk_dup_rec.global_attribute1,
4720 x_global_attribute18=> chk_dup_rec.global_attribute1,
4721 x_global_attribute19=> chk_dup_rec.global_attribute1,
4722 x_global_attribute20=> chk_dup_rec.global_attribute1,
4723 x_party_last_update_date=> l_party_last_update_date,
4724 x_person_profile_id => chk_dup_rec.person_profile_id,
4725 x_matr_cal_type => chk_dup_rec.matr_cal_type,
4726 x_matr_sequence_number => chk_dup_rec.matr_sequence_number,
4727 x_init_cal_type => chk_dup_rec.init_cal_type,
4728 x_init_sequence_number => chk_dup_rec.init_sequence_number,
4729 x_recent_cal_type => chk_dup_rec.recent_cal_type,
4730 x_recent_sequence_number => chk_dup_rec.recent_sequence_number,
4731 x_catalog_cal_type => chk_dup_rec.catalog_cal_type,
4732 x_catalog_sequence_number => chk_dup_rec.catalog_sequence_number,
4733 z_return_status => l_return_status,
4734 z_msg_count => l_msg_count,
4735 z_msg_data => l_msg_data,
4736 x_birth_cntry_resn_code => NULL --- prbhardw
4737 );
4738
4739 IF l_return_status IN('E','U') THEN
4740 UPDATE igs_ad_stat_int_all
4741 SET status = '3',error_code = 'E014'
4742 WHERE interface_id = stat_rec.interface_id
4743 AND interface_stat_id = stat_rec.interface_stat_id;
4744
4745 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4746
4747 IF (l_request_id IS NULL) THEN
4748 l_request_id := fnd_global.conc_request_id;
4749 END IF;
4750
4751 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception '||'E014';
4752
4753 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4754 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4755 fnd_message.set_token('ERROR_CD','E014');
4756
4757 l_debug_str := fnd_message.get || ' ' || l_msg_data;
4758
4759 fnd_log.string_with_context( fnd_log.level_exception,
4760 l_label,
4761 l_debug_str, NULL,
4762 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4763 END IF;
4764
4765 IF l_enable_log = 'Y' THEN
4766 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E014','IGS_AD_STAT_INT_ALL');
4767 END IF;
4768 ELSE
4769 UPDATE
4770 igs_ad_stat_int_all
4771 SET
4772 error_code = NULL, --ssomani, added this 15 March 2001
4773 status = '1', match_ind = '18'
4774 WHERE
4775 interface_id = stat_rec.interface_id
4776 AND interface_stat_id = stat_rec.interface_stat_id;
4777 END IF;
4778 END IF; --l_success =Y for dflex validation.
4779 -- kumma, removed the else clause, 2421786
4780 END IF; --l_success =Y for Stat validation.
4781 EXCEPTION
4782 WHEN OTHERS THEN
4783 l_msg_data := SQLERRM;
4784 UPDATE igs_ad_stat_int_all
4785 SET status = '3',
4786 error_code = 'E518'
4787 WHERE interface_id = stat_rec.interface_id
4788 AND interface_stat_id = stat_rec.interface_stat_id;
4789
4790 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4791
4792 IF (l_request_id IS NULL) THEN
4793 l_request_id := fnd_global.conc_request_id;
4794 END IF;
4795
4796 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception '||'E518';
4797
4798 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4799 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4800 fnd_message.set_token('ERROR_CD','E518');
4801
4802 l_debug_str := fnd_message.get || ' ' || SQLERRM;
4803
4804 fnd_log.string_with_context( fnd_log.level_exception,
4805 l_label,
4806 l_debug_str, NULL,
4807 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4808 END IF;
4809
4810 IF l_enable_log = 'Y' THEN
4811 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E518','IGS_AD_STAT_INT_ALL');
4812 END IF;
4813 END;
4814
4815 ELSIF l_rule = 'R' THEN
4816 IF stat_rec.match_ind = '21' THEN
4817
4818 BEGIN
4819
4820 Validate_Person_Statistics(p_per_stat => stat_rec, p_success => l_success, p_error_code =>l_error_code);
4821
4822 IF l_success = 'Y' THEN -- null handling
4823 --Validation check of Descriptive Flexfield
4824 -- Added as a part of bug number 2203778
4825 l_success := NULL;
4826 Validate_desc_flex(stat_rec ,l_success );
4827
4828 IF l_success = 'Y' THEN -- for dff
4829
4830 IGS_PE_STAT_PKG.Update_Row(
4831 X_ACTION => 'UPDATE',
4832 x_rowid => chk_dup_rec.row_id,
4833 x_person_id => stat_rec.pid, --stat_rec.person_id,
4834 x_ethnic_origin_id => NVL(stat_rec.ethnic_origin,chk_dup_rec.ethnic_origin_id), -- BUG ID : 2138382
4835 x_marital_status => NVL(stat_rec.marital_status,chk_dup_rec.marital_status),
4836 x_marital_stat_effect_dt => NVL(stat_rec.marital_status_effective_date,chk_dup_rec.marital_status_effective_date),
4837 x_ann_family_income => chk_dup_rec.ann_family_income,
4838 x_number_in_family => chk_dup_rec.number_in_family,
4839 x_content_source_type => 'USER_ENTERED',
4840 x_internal_flag => chk_dup_rec.internal_flag,
4841 x_person_number => chk_dup_rec.person_number,
4842 x_effective_start_date => TRUNC(chk_dup_rec.effective_start_date),
4843 x_effective_end_date => TRUNC(chk_dup_rec.effective_end_date),
4844 x_ethnic_origin => NULL,
4845 x_religion => NVL(stat_rec.religion_cd,chk_dup_rec.religion),
4846 x_next_to_kin => chk_dup_rec.next_to_kin,
4847 x_next_to_kin_meaning => NULL,
4848 x_place_of_birth => NVL(stat_rec.place_of_birth,chk_dup_rec.place_of_birth),
4849 x_socio_eco_status => chk_dup_rec.socio_eco_status,
4850 x_socio_eco_status_desc => NULL,
4851 x_further_education => chk_dup_rec.further_education,
4852 x_further_education_desc => NULL,
4853 x_in_state_tuition => chk_dup_rec.in_state_tuition,
4854 x_tuition_st_date => TRUNC(chk_dup_rec.tuition_st_date),
4855 x_tuition_end_date => TRUNC(chk_dup_rec.tuition_end_date),
4856 x_person_initials => chk_dup_rec.person_initials,
4857 x_primary_contact_id => chk_dup_rec.primary_contact_id,
4858 x_personal_income => chk_dup_rec.personal_income,
4859 x_head_of_household_flag => chk_dup_rec.head_of_household_flag,
4860 x_content_source_number => chk_dup_rec.content_source_number,
4861 x_hz_parties_ovn => chk_dup_rec.object_version_number,
4862 x_attribute_category => NVL(stat_rec.attribute_category,chk_dup_rec.attribute_category),
4863 x_attribute1 => NVL(stat_rec.attribute1,chk_dup_rec.attribute1),
4864 x_attribute2 => NVL(stat_rec.attribute2,chk_dup_rec.attribute2),
4865 x_attribute3 => NVL(stat_rec.attribute3,chk_dup_rec.attribute3),
4866 x_attribute4 => NVL(stat_rec.attribute4,chk_dup_rec.attribute4),
4867 x_attribute5 => NVL(stat_rec.attribute5,chk_dup_rec.attribute5),
4868 x_attribute6 => NVL(stat_rec.attribute6,chk_dup_rec.attribute6),
4869 x_attribute7 => NVL(stat_rec.attribute7,chk_dup_rec.attribute7),
4870 x_attribute8 => NVL(stat_rec.attribute8,chk_dup_rec.attribute8),
4871 x_attribute9 => NVL(stat_rec.attribute9,chk_dup_rec.attribute9),
4872 x_attribute10 => NVL(stat_rec.attribute10,chk_dup_rec.attribute10),
4873 x_attribute11 => NVL(stat_rec.attribute11,chk_dup_rec.attribute11),
4874 x_attribute12 => NVL(stat_rec.attribute12,chk_dup_rec.attribute12),
4875 x_attribute13 => NVL(stat_rec.attribute13,chk_dup_rec.attribute13),
4876 x_attribute14 => NVL(stat_rec.attribute14,chk_dup_rec.attribute14),
4877 x_attribute15 => NVL(stat_rec.attribute15,chk_dup_rec.attribute15),
4878 x_attribute16 => NVL(stat_rec.attribute16,chk_dup_rec.attribute16),
4879 x_attribute17 => NVL(stat_rec.attribute17,chk_dup_rec.attribute17),
4880 x_attribute18 => NVL(stat_rec.attribute18,chk_dup_rec.attribute18),
4881 x_attribute19 => NVL(stat_rec.attribute19,chk_dup_rec.attribute19),
4882 x_attribute20 => NVL(stat_rec.attribute20,chk_dup_rec.attribute20),
4883 x_global_attribute_category => chk_dup_rec.global_attribute_category,
4884 x_global_attribute1 => chk_dup_rec.global_attribute1,
4885 x_global_attribute2=> chk_dup_rec.global_attribute1,
4886 x_global_attribute3=> chk_dup_rec.global_attribute1,
4887 x_global_attribute4=> chk_dup_rec.global_attribute1,
4888 x_global_attribute5=> chk_dup_rec.global_attribute1,
4889 x_global_attribute6=> chk_dup_rec.global_attribute1,
4890 x_global_attribute7=> chk_dup_rec.global_attribute1,
4891 x_global_attribute8=> chk_dup_rec.global_attribute1,
4892 x_global_attribute9=> chk_dup_rec.global_attribute1,
4893 x_global_attribute10=> chk_dup_rec.global_attribute1,
4894 x_global_attribute11=> chk_dup_rec.global_attribute1,
4895 x_global_attribute12=> chk_dup_rec.global_attribute1,
4896 x_global_attribute13=> chk_dup_rec.global_attribute1,
4897 x_global_attribute14=> chk_dup_rec.global_attribute1,
4898 x_global_attribute15=> chk_dup_rec.global_attribute1,
4899 x_global_attribute16=> chk_dup_rec.global_attribute1,
4900 x_global_attribute17=> chk_dup_rec.global_attribute1,
4901 x_global_attribute18=> chk_dup_rec.global_attribute1,
4902 x_global_attribute19=> chk_dup_rec.global_attribute1,
4903 x_global_attribute20=> chk_dup_rec.global_attribute1,
4904 x_party_last_update_date=> l_party_last_update_date,
4905 x_person_profile_id => chk_dup_rec.person_profile_id,
4906 x_matr_cal_type => chk_dup_rec.matr_cal_type,
4907 x_matr_sequence_number => chk_dup_rec.matr_sequence_number,
4908 x_init_cal_type => chk_dup_rec.init_cal_type,
4909 x_init_sequence_number => chk_dup_rec.init_sequence_number,
4910 x_recent_cal_type => chk_dup_rec.recent_cal_type,
4911 x_recent_sequence_number => chk_dup_rec.recent_sequence_number,
4912 x_catalog_cal_type => chk_dup_rec.catalog_cal_type,
4913 x_catalog_sequence_number => chk_dup_rec.catalog_sequence_number,
4914 z_return_status => l_return_status,
4915 z_msg_count => l_msg_count,
4916 z_msg_data => l_msg_data,
4917 x_birth_cntry_resn_code => NULL --- prbhardw
4918 );
4919
4920
4921 IF l_return_status IN('E','U') THEN
4922 UPDATE igs_ad_stat_int_all
4923 SET status = '3',
4924 error_code = 'E014'
4925 WHERE interface_id = stat_rec.interface_id
4926 AND interface_stat_id = stat_rec.interface_stat_id;
4927
4928 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4929
4930 IF (l_request_id IS NULL) THEN
4931 l_request_id := fnd_global.conc_request_id;
4932 END IF;
4933
4934 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception1';
4935
4936 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4937 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4938 fnd_message.set_token('ERROR_CD','E014');
4939
4940 l_debug_str := fnd_message.get || ' ' || l_msg_data;
4941
4942 fnd_log.string_with_context( fnd_log.level_exception,
4943 l_label,
4944 l_debug_str, NULL,
4945 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4946 END IF;
4947
4948 IF l_enable_log = 'Y' THEN
4949 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E014','IGS_AD_STAT_INT_ALL');
4950 END IF;
4951
4952
4953 ELSE
4954 UPDATE igs_ad_stat_int_all
4955 SET status = '1', ERROR_CODE = NULL, match_ind = '18'
4956 WHERE
4957 interface_id = stat_rec.interface_id
4958 AND interface_stat_id = stat_rec.interface_stat_id;
4959 END IF;
4960 END IF; -- for dff
4961
4962 ELSE -- else l_success = 'N'
4963 UPDATE
4964 igs_ad_stat_int_all
4965 SET
4966
4967 status = '3',
4968 error_code = p_error_code
4969 WHERE
4970 interface_id = stat_rec.interface_id
4971 AND interface_stat_id = stat_rec.interface_stat_id;
4972
4973
4974 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
4975
4976 IF (l_request_id IS NULL) THEN
4977 l_request_id := fnd_global.conc_request_id;
4978 END IF;
4979
4980 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception2';
4981
4982 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
4983 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
4984 fnd_message.set_token('ERROR_CD',p_error_code);
4985
4986 l_debug_str := fnd_message.get || ' ' || l_msg_data;
4987
4988 fnd_log.string_with_context( fnd_log.level_exception,
4989 l_label,
4990 l_debug_str, NULL,
4991 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
4992 END IF;
4993
4994 IF l_enable_log = 'Y' THEN
4995 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,p_error_code,'IGS_AD_STAT_INT_ALL');
4996 END IF;
4997
4998
4999 END IF; -- null handling
5000
5001 EXCEPTION WHEN OTHERS THEN
5002 UPDATE igs_ad_stat_int_all
5003 SET
5004
5005 status = '3',
5006 error_code = 'E014'
5007 WHERE
5008 interface_id = stat_rec.interface_id
5009 AND interface_stat_id = stat_rec.interface_stat_id;
5010
5011 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5012
5013 IF (l_request_id IS NULL) THEN
5014 l_request_id := fnd_global.conc_request_id;
5015 END IF;
5016
5017 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception3';
5018
5019 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
5020 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
5021 fnd_message.set_token('ERROR_CD','E014');
5022
5023 l_debug_str := fnd_message.get || ' ' || SQLERRM;
5024
5025 fnd_log.string_with_context( fnd_log.level_exception,
5026 l_label,
5027 l_debug_str, NULL,
5028 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5029 END IF;
5030
5031 IF l_enable_log = 'Y' THEN
5032 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E014','IGS_AD_STAT_INT_ALL');
5033 END IF;
5034
5035 END;
5036 END IF;--end if for match_ind = '21'
5037 END IF;-- end if for l_rule = 'e'
5038 ELSE
5039 Crt_Pe_Stat(stat_rec =>stat_rec, p_status =>l_status, p_error_code=>l_error_code );
5040 UPDATE igs_ad_stat_int_all
5041 SET status = l_status,error_code = l_error_code
5042 WHERE interface_id = stat_rec.interface_id
5043 AND interface_stat_id = stat_rec.interface_stat_id;
5044 END IF;
5045 CLOSE chk_dup_cur;
5046 EXCEPTION
5047 WHEN OTHERS THEN
5048 IF chk_dup_cur%ISOPEN THEN
5049 CLOSE chk_dup_cur;
5050 END IF;
5051 UPDATE igs_ad_stat_int_all
5052 SET status = '3',error_code = 'E518'
5053 WHERE interface_id = stat_rec.interface_id
5054 AND interface_stat_id = stat_rec.interface_stat_id;
5055
5056
5057 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5058
5059 IF (l_request_id IS NULL) THEN
5060 l_request_id := fnd_global.conc_request_id;
5061 END IF;
5062
5063 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_main.exception '||'E518';
5064
5065 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
5066 fnd_message.set_token('INTERFACE_ID',stat_rec.interface_stat_id);
5067 fnd_message.set_token('ERROR_CD','E518');
5068
5069 l_debug_str := fnd_message.get || ' ' || SQLERRM;
5070
5071 fnd_log.string_with_context( fnd_log.level_exception,
5072 l_label,
5073 l_debug_str, NULL,
5074 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5075 END IF;
5076
5077 IF l_enable_log = 'Y' THEN
5078 igs_ad_imp_001.logerrormessage(stat_rec.interface_stat_id,'E518','IGS_AD_STAT_INT_ALL');
5079 END IF;
5080
5081 END;
5082
5083 IF l_processed_records = 100 THEN
5084 COMMIT;
5085 l_processed_records := 0;
5086 END IF;
5087 END LOOP;
5088 END Prc_Pe_Stat_Main;
5089
5090 PROCEDURE Prc_Pe_Stat_Biodemo (
5091 p_source_type_id IN NUMBER,
5092 p_batch_id IN NUMBER )
5093 AS
5094 /*
5095 || Created By : ssawhney
5096 || Purpose : Person Stats - Biodemo Import
5097 || Known limitations, enhancements or remarks :
5098 || Change History :
5099 || Who When What
5100 || npalanis 6-JAN-2003 Bug : 2734697
5101 || code added to commit after import of every
5102 || 100 records .New variable l_processed_records added
5103 */
5104
5105 l_prog_label VARCHAR2(100);
5106 l_label VARCHAR2(100);
5107 l_debug_str VARCHAR2(2000);
5108 l_enable_log VARCHAR2(1);
5109 l_request_id NUMBER;
5110 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
5111 CURSOR c_biodemo(cp_interface_run_id igs_ad_interface_all.interface_run_id%TYPE) IS
5112 SELECT mi.*,i.person_id
5113 FROM igs_pe_eit_int mi,
5114 igs_ad_interface_all i
5115 WHERE mi.information_type IN ('PE_STAT_RES_COUNTRY','PE_STAT_RES_STATE', 'PE_STAT_RES_STATUS')
5116 AND mi.interface_run_id = cp_interface_run_id
5117 AND mi.interface_id = i.interface_id
5118 AND i.interface_run_id = cp_interface_run_id
5119 AND mi.status = '2';
5120
5121 biodem_rec c_biodemo%ROWTYPE;
5122
5123 CURSOR c_dup_cur (biodem_rec c_biodemo%ROWTYPE) IS
5124 SELECT rowid, pe.*
5125 FROM igs_pe_eit pe
5126 WHERE person_id = biodem_rec.person_id AND
5127 information_type = biodem_rec.information_type AND
5128 start_date = TRUNC(biodem_rec.start_date);
5129
5130 dup_cur_rec c_dup_cur%ROWTYPE;
5131
5132 l_rule igs_ad_source_cat.discrepancy_rule_cd%TYPE;
5133 l_count number;
5134 l_status biodem_rec.status%TYPE;
5135 l_error_code biodem_rec.error_code%TYPE;
5136 l_match_ind biodem_rec.match_ind%TYPE;
5137 l_processed_records NUMBER(5);
5138
5139 -- local procedure
5140
5141 PROCEDURE crt_biodemo (
5142 biodem_rec IN c_biodemo%ROWTYPE,
5143 p_error_code OUT NOCOPY VARCHAR2,
5144 p_status OUT NOCOPY VARCHAR2 )
5145 /*
5146 || Created By : ssawhney
5147 || Purpose : Person Stats - Local Insert Biodemo details proc
5148 || Known limitations, enhancements or remarks :
5149 */
5150 AS
5151 l_count NUMBER(3);
5152 l_rowid VARCHAR2(25);
5153 l_pe_eit_id NUMBER;
5154 CURSOR date_overlap(cp_start_date IGS_PE_EIT.start_date%TYPE,
5155 cp_end_date IGS_PE_EIT.end_date%TYPE,
5156 cp_information_type IGS_PE_EIT.information_type%TYPE,
5157 cp_person_id NUMBER) IS
5158 SELECT count(1) FROM IGS_PE_EIT
5159 WHERE person_id = cp_person_id
5160 AND INFORMATION_TYPE = cp_information_type
5161 AND (
5162 NVL(TRUNC(cp_end_date),IGS_GE_DATE.igsdate('4712/12/31')) BETWEEN START_DATE
5163 AND NVL(END_DATE,IGS_GE_DATE.igsdate('4712/12/31')) OR
5164 cp_start_date BETWEEN START_DATE AND NVL(END_DATE,IGS_GE_DATE.igsdate('4712/12/31')) OR
5165 (cp_start_Date < START_DATE AND
5166 NVL(end_date,IGS_GE_DATE.igsdate('4712/12/31'))< NVL(cp_end_date ,IGS_GE_DATE.igsdate('4712/12/31')) )
5167 );
5168 BEGIN
5169 -- Call Log header
5170 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
5171
5172 IF (l_request_id IS NULL) THEN
5173 l_request_id := fnd_global.conc_request_id;
5174 END IF;
5175
5176 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.begin_crt_biodemo';
5177 l_debug_str := 'Igs_Ad_Imp_008.prc_pe_stat_biodemo.crt_biodemo';
5178
5179 fnd_log.string_with_context( fnd_log.level_procedure,
5180 l_label,
5181 l_debug_str, NULL,
5182 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5183 END IF;
5184 OPEN date_overlap(biodem_rec.start_date,biodem_rec.end_date, biodem_rec.information_type,biodem_rec.person_id);
5185 FETCH date_overlap INTO l_count;
5186 CLOSE date_overlap;
5187 IF l_count > 0 THEN
5188 p_error_code := 'E228';
5189 p_status :='3';
5190
5191 IF l_enable_log = 'Y' THEN
5192 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,'E228','IGS_PE_EIT_INT');
5193 END IF;
5194 ELSE
5195 Igs_Pe_Eit_Pkg.insert_row (
5196 x_rowid => l_rowid,
5197 x_pe_eit_id => l_pe_eit_id,
5198 x_person_id => biodem_rec.person_id,
5199 x_information_type => biodem_rec.information_type,
5200 x_pei_information1 => biodem_rec.pei_information1,
5201 x_pei_information2 => biodem_rec.pei_information2,
5202 x_pei_information3 => biodem_rec.pei_information3,
5203 x_pei_information4 => biodem_rec.pei_information4,
5204 x_pei_information5 => biodem_rec.pei_information5,
5205 x_start_date => biodem_rec.start_date,
5206 x_end_date => biodem_rec.end_date,
5207 x_mode => 'R'
5208 );
5209 p_error_code:=NULL;
5210 p_status :='1';
5211 END IF;
5212
5213 EXCEPTION
5214 WHEN OTHERS THEN
5215 p_status := '3';
5216 p_error_code := 'E161';
5217 -- Call Log detail
5218
5219 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5220
5221 IF (l_request_id IS NULL) THEN
5222 l_request_id := fnd_global.conc_request_id;
5223 END IF;
5224
5225 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.exception '||'E161';
5226
5227 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
5228 fnd_message.set_token('INTERFACE_ID',biodem_rec.interface_id);
5229 fnd_message.set_token('ERROR_CD','E161');
5230
5231 l_debug_str := fnd_message.get || ' ' || SQLERRM;
5232
5233 fnd_log.string_with_context( fnd_log.level_exception,
5234 l_label,
5235 l_debug_str, NULL,
5236 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5237 END IF;
5238
5239 IF l_enable_log = 'Y' THEN
5240 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,'E161','IGS_PE_EIT_INT');
5241 END IF;
5242
5243
5244 END crt_biodemo; -- END OF LOCAL PROCEDURE crt_biodemo
5245
5246
5247 -- Start Local Procedure Validate_Record for validation of the record values
5248
5249 FUNCTION Validate_Record(p_biodemo_rec IN c_biodemo%ROWTYPE) RETURN BOOLEAN
5250 /*
5251 || Created By : ssawhney
5252 || Purpose : Person Stats - Local validate function
5253 || Known limitations, enhancements or remarks :
5254 || WHO WHEN WHAT
5255 || skpandey 09-Jan-2006 Bug#4178224
5256 || Changed the definition of region_cd_cur cursor as a part of New Geography Model
5257 */
5258 IS
5259 l_var VARCHAR2(1);
5260
5261 -- validate the territory if passed
5262 CURSOR c_country(cp_territory_code VARCHAR2) IS
5263 SELECT 'X' var
5264 FROM fnd_territories_vl
5265 WHERE territory_code = NVL(cp_territory_code,'0');
5266
5267 country_rec c_country%ROWTYPE;
5268
5269 -- validate state if passed
5270 CURSOR c_state(cp_geography_type hz_geographies.geography_type%TYPE, cp_geography_cd hz_geographies.geography_code%TYPE, cp_country_cd hz_geographies.country_code%TYPE) IS
5271 SELECT 'X'
5272 FROM hz_geographies
5273 WHERE GEOGRAPHY_TYPE = cp_geography_type
5274 AND geography_code = NVL(cp_geography_cd, '0')
5275 AND COUNTRY_CODE = cp_country_cd;
5276
5277 state_rec c_state%ROWTYPE;
5278
5279
5280 -- Validate date of birth
5281 CURSOR birth_date_cur(cp_person_id NUMBER) IS
5282 SELECT birth_date
5283 FROM igs_pe_person_base_v
5284 WHERE person_id = cp_person_id;
5285
5286 l_birth_date igs_pe_person_base_v.birth_date%TYPE;
5287 l_error VARCHAR2(30);
5288 BEGIN
5289 -- Call Log header
5290
5291 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
5292
5293 IF (l_request_id IS NULL) THEN
5294 l_request_id := fnd_global.conc_request_id;
5295 END IF;
5296
5297 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.begin_validate_record';
5298 l_debug_str := 'Igs_Ad_Imp_008.prc_pe_stat_biodemo.Validate_Record';
5299
5300 fnd_log.string_with_context( fnd_log.level_procedure,
5301 l_label,
5302 l_debug_str, NULL,
5303 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5304 END IF;
5305
5306 -- test for input data if its NOT NULL
5307 OPEN birth_date_cur(p_biodemo_rec.person_id);
5308 FETCH birth_date_cur INTO l_birth_date;
5309 CLOSE birth_date_cur;
5310
5311 IF l_birth_date IS NOT NULL THEN
5312 IF p_biodemo_rec.start_date < l_birth_date THEN
5313 l_error := 'E222';
5314 RAISE NO_DATA_FOUND;
5315 END IF;
5316 END IF;
5317
5318 IF p_biodemo_rec.pei_information1 IS NOT NULL THEN
5319
5320 -- validate for country
5321 IF p_biodemo_rec.information_type = 'PE_STAT_RES_COUNTRY' THEN
5322 OPEN c_country(p_biodemo_rec.pei_information1);
5323 FETCH c_country INTO country_rec;
5324 IF c_country%NOTFOUND THEN
5325 l_error := 'E105';
5326 RAISE no_data_found;
5327 ELSE
5328 CLOSE c_country;
5329 l_error := NULL;
5330 END IF;
5331
5332 -- validate for state
5333 ELSIF p_biodemo_rec.information_type = 'PE_STAT_RES_STATE' THEN
5334 OPEN c_state('STATE',p_biodemo_rec.pei_information1, FND_PROFILE.VALUE('OSS_COUNTRY_CODE'));
5335 FETCH c_state INTO state_rec;
5336 -- CLOSE c_state;
5337 IF c_state%NOTFOUND THEN
5338 l_error := 'E106';
5339 RAISE no_data_found;
5340 ELSE
5341 CLOSE c_state;
5342 l_error := NULL;
5343 END IF;
5344
5345 -- validate for citizenship status
5346 ELSIF p_biodemo_rec.information_type = 'PE_STAT_RES_STATUS' THEN
5347 -- validate code if passed
5348 IF NOT
5349 (igs_pe_pers_imp_001.validate_lookup_type_code('PE_CITI_STATUS',NVL(p_biodemo_rec.pei_information1,'0'),8405))
5350 THEN
5351 l_error := 'E107';
5352 RAISE no_data_found;
5353 ELSE
5354 l_error := NULL;
5355 END IF;
5356 END IF ;
5357
5358 END IF; -- pei_information1 IS NOT NULL
5359
5360 -- validate start and end dates
5361 IF p_biodemo_rec.start_date > NVL(p_biodemo_rec.end_date, IGS_GE_DATE.IGSDATE('4712/12/31')) THEN
5362 l_error := 'E108';
5363 RAISE no_data_found;
5364 END IF;
5365
5366 -- if all validations pass then update the INTERFACE Table
5367 RETURN TRUE;
5368
5369 EXCEPTION
5370 -- search for NO_DATA_FOUND, as its not trapped, OTHERS will be raised
5371
5372 WHEN OTHERS THEN
5373
5374 IF c_state%ISOPEN THEN
5375 CLOSE c_state;
5376 END IF;
5377 IF c_country%ISOPEN THEN
5378 CLOSE c_country;
5379 END IF;
5380 -- update for failure
5381
5382 UPDATE igs_pe_eit_int
5383 SET status = '3',
5384 error_code = l_error
5385 WHERE interface_eit_id = p_biodemo_rec.interface_eit_id;
5386
5387 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5388
5389 IF (l_request_id IS NULL) THEN
5390 l_request_id := fnd_global.conc_request_id;
5391 END IF;
5392
5393 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.validate_record';
5394
5395 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
5396 fnd_message.set_token('INTERFACE_ID',p_biodemo_rec.interface_eit_id);
5397 fnd_message.set_token('ERROR_CD',l_error);
5398
5399 l_debug_str := fnd_message.get || ' ' || SQLERRM;
5400
5401 fnd_log.string_with_context( fnd_log.level_exception,
5402 l_label,
5403 l_debug_str, NULL,
5404 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5405 END IF;
5406
5407 IF l_enable_log = 'Y' THEN
5408 igs_ad_imp_001.logerrormessage(p_biodemo_rec.interface_eit_id,l_error,'IGS_PE_EIT_INT');
5409 END IF;
5410
5411 RETURN FALSE ;
5412
5413 END validate_record; -- End Local function Validate_Record
5414
5415
5416 BEGIN -- Start the Prc_Pe_Stat_Biodemo Now.
5417
5418 l_prog_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo';
5419 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.';
5420 l_enable_log := igs_ad_imp_001.g_enable_log;
5421 l_interface_run_id := igs_ad_imp_001.g_interface_run_id;
5422 -- Call Log header
5423 l_processed_records := 0;
5424 l_count := 0;
5425
5426 IF fnd_log.test(fnd_log.level_procedure,l_prog_label) THEN
5427
5428 IF (l_request_id IS NULL) THEN
5429 l_request_id := fnd_global.conc_request_id;
5430 END IF;
5431
5432 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.begin';
5433 l_debug_str := 'Igs_Ad_Imp_008.Prc_Pe_Stat_Biodemo';
5434
5435 fnd_log.string_with_context( fnd_log.level_procedure,
5436 l_label,
5437 l_debug_str, NULL,
5438 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5439 END IF;
5440
5441 l_rule :=IGS_AD_IMP_001.Find_Source_Cat_Rule(p_source_type_id, 'PERSON_STATISTICS');
5442 --
5443 --1 If rule is E or I, then if the match_ind is not null, the combination is invalid
5444 IF l_rule IN ('E','I') THEN
5445 UPDATE igs_pe_eit_int
5446 SET status = '3',
5447 ERROR_CODE = 'E695' -- Error code depicting incorrect combination
5448 WHERE match_ind IS NOT NULL
5449 AND status = '2'
5450 AND interface_run_id = l_interface_run_id;
5451 END IF;
5452
5453 --2 If rule is E and duplicate exists, update match_ind to 19 and status to 1
5454 IF l_rule = 'E' THEN
5455 UPDATE igs_pe_eit_int mi
5456 SET status = '1',
5457 match_ind = '19'
5458 WHERE mi.interface_run_id = l_interface_run_id
5459 AND mi.status = '2'
5460 AND EXISTS ( SELECT '1'
5461 FROM igs_pe_eit pe, igs_ad_interface_all ii
5462 WHERE ii.interface_run_id = l_interface_run_id
5463 AND ii.interface_id = mi.interface_id
5464 AND ii.person_id = pe.person_id
5465 AND UPPER(mi.information_type) = UPPER(pe.information_type)
5466 AND TRUNC(pe.start_date) = TRUNC(mi.start_date));
5467 END IF;
5468
5469 --3 If rule is R and there match_ind is 18,19,22 or 23 then the records must have been
5470 -- processed in prior runs and didn't get updated .. update to status 1
5471 IF l_rule = 'R' THEN
5472 UPDATE igs_pe_eit_int
5473 SET status = '1'
5474 WHERE interface_run_id = l_interface_run_id
5475 AND match_ind IN ('18','19','22','23')
5476 AND status = '2';
5477 END IF;
5478
5479 --4 If rule is R and match_ind is neither 21 nor 25 then error
5480 IF l_rule = 'R' THEN
5481 UPDATE igs_pe_eit_int
5482 SET status = '3',
5483 ERROR_CODE = 'E695'
5484 WHERE interface_run_id = l_interface_run_id
5485 AND status = '2'
5486 AND (match_ind IS NOT NULL AND match_ind NOT IN ('21','25'));
5487 END IF;
5488
5489 --5 If rule is R, set duplicated records with no discrepancy to status 1 and match_ind 23
5490 IF l_rule = 'R' THEN
5491 UPDATE igs_pe_eit_int mi
5492 SET status = '1',
5493 match_ind = '23'
5494 WHERE mi.interface_run_id = l_interface_run_id
5495 AND mi.match_ind IS NULL
5496 AND mi.status = '2'
5497 AND EXISTS ( SELECT '1'
5498 FROM igs_pe_eit pe, igs_ad_interface_all ii
5499 WHERE ii.interface_run_id = l_interface_run_id
5500 AND ii.interface_id = mi.interface_id
5501 AND ii.person_id = pe.person_id
5502 AND UPPER(mi.information_type) = UPPER(pe.information_type)
5503 AND TRUNC(pe.start_date) = TRUNC(mi.start_date)
5504 AND NVL(UPPER(pe.pei_information1),'1') = NVL(UPPER(mi.pei_information1),'1')
5505 AND NVL(UPPER(pe.pei_information2),'2') = NVL(UPPER(mi.pei_information2),'2')
5506 AND NVL(UPPER(pe.pei_information3),'3') = NVL(UPPER(mi.pei_information3),'3')
5507 AND NVL(UPPER(pe.pei_information4),'4') = NVL(UPPER(mi.pei_information4),'4')
5508 AND NVL(UPPER(pe.pei_information5),'5') = NVL(UPPER(mi.pei_information5),'5')
5509 AND NVL(TRUNC(pe.end_date),IGS_GE_DATE.IGSDATE('4712/12/01'))=
5510 NVL(TRUNC(mi.end_date),IGS_GE_DATE.IGSDATE('4712/12/01'))
5511 );
5512 END IF;
5513
5514 --6 If rule is R records still exist, they are duplicates and have discrepancy .. update status=3,match_ind=20
5515 IF l_rule = 'R' THEN
5516 UPDATE igs_pe_eit_int mi
5517 SET status = '3',
5518 match_ind = '20',
5519 DUP_PE_EIT_ID = (SELECT pe.pe_eit_id
5520 FROM igs_pe_eit pe, igs_ad_interface_all ii
5521 WHERE mi.interface_run_id = l_interface_run_id
5522 AND ii.interface_id = mi.interface_id
5523 AND ii.person_id = pe.person_id
5524 AND UPPER(mi.information_type) = UPPER(pe.information_type)
5525 AND TRUNC(pe.start_date) = TRUNC(mi.start_date))
5526 WHERE mi.interface_run_id = l_interface_run_id
5527 AND mi.match_ind IS NULL
5528 AND mi.status = '2'
5529 AND EXISTS (SELECT '1'
5530 FROM igs_pe_eit pe, igs_ad_interface_all ii
5531 WHERE ii.interface_run_id = l_interface_run_id
5532 AND ii.interface_id = mi.interface_id
5533 AND ii.person_id = pe.person_id
5534 AND UPPER(mi.information_type) = UPPER(pe.information_type)
5535 AND TRUNC(pe.start_date) = TRUNC(mi.start_date));
5536 END IF;
5537
5538 FOR biodem_rec IN c_biodemo(l_interface_run_id) LOOP -- LOOP Started
5539 l_processed_records := l_processed_records + 1;
5540 BEGIN
5541 --
5542 -- Set the status, match_ind, error_code of the interface record
5543 --
5544 l_status := biodem_rec.status;
5545 l_error_code := biodem_rec.error_code;
5546 l_match_ind := biodem_rec.match_ind;
5547 biodem_rec.start_date := TRUNC(biodem_rec.start_date);
5548 biodem_rec.end_date := TRUNC(biodem_rec.end_date);
5549 -- validate the current record
5550 IF validate_record( p_biodemo_rec => biodem_rec ) THEN -- 1 IF
5551 -- check for duplicates
5552 dup_cur_rec.pe_eit_id := NULL; -- initialise
5553 OPEN c_dup_cur ( biodem_rec);
5554 FETCH c_dup_cur INTO dup_cur_rec;
5555 CLOSE c_dup_cur;
5556
5557 IF dup_cur_rec.pe_eit_id IS NOT NULL THEN -- duplicate found. -- 2 IF
5558 -- follow the path of insert/updates depending on the RETURN value of the RULE.
5559 IF l_rule = 'I' THEN
5560 DECLARE
5561 CURSOR date_overlap(cp_start_date IGS_PE_EIT.start_date%TYPE,
5562 cp_end_date IGS_PE_EIT.end_date%TYPE,
5563 cp_information_type IGS_PE_EIT.information_type%TYPE,
5564 cp_person_id NUMBER) IS
5565 SELECT COUNT(1) FROM IGS_PE_EIT
5566 WHERE person_id = cp_person_id
5567 AND INFORMATION_TYPE = cp_information_type
5568 AND start_date <> cp_start_date
5569 AND (NVL(cp_end_date,IGS_GE_DATE.igsdate('4712/12/31')) BETWEEN START_DATE AND NVL(END_DATE,IGS_GE_DATE.igsdate('4712/12/31'))
5570 OR
5571 cp_start_date BETWEEN START_DATE AND NVL(END_DATE,IGS_GE_DATE.igsdate('4712/12/31'))
5572 OR
5573 ( cp_start_date < START_DATE AND
5574 NVL(end_date,IGS_GE_DATE.igsdate('4712/12/31'))< NVL(cp_end_date,IGS_GE_DATE.igsdate('4712/12/31')) ) );
5575
5576 l_count NUMBER(3);
5577 BEGIN
5578 OPEN date_overlap(biodem_rec.start_date,biodem_rec.end_date,
5579 biodem_rec.information_type,biodem_rec.person_id);
5580 FETCH date_overlap INTO l_count;
5581 CLOSE date_overlap;
5582
5583 IF l_count > 0 THEN
5584
5585 UPDATE igs_pe_eit_int
5586 SET status = '3',
5587 error_code = 'E228'
5588 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5589
5590 IF l_enable_log = 'Y' THEN
5591 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,'E228','IGS_PE_EIT_INT');
5592 END IF;
5593
5594 ELSE
5595 -- open the Null handling cursor
5596 igs_pe_eit_pkg.update_row (
5597 x_rowid => dup_cur_rec.rowid,
5598 x_pe_eit_id => dup_cur_rec.pe_eit_id,
5599 x_person_id => dup_cur_rec.person_id,
5600 x_information_type => dup_cur_rec.information_type,
5601 x_pei_information1 => NVL(biodem_rec.pei_information1,dup_cur_rec.pei_information1),
5602 x_pei_information2 => NVL(biodem_rec.pei_information2,dup_cur_rec.pei_information2),
5603 x_pei_information3 => NVL(biodem_rec.pei_information3,dup_cur_rec.pei_information3),
5604 x_pei_information4 => NVL(biodem_rec.pei_information4,dup_cur_rec.pei_information4),
5605 x_pei_information5 => NVL(biodem_rec.pei_information5,dup_cur_rec.pei_information5),
5606 x_start_date => dup_cur_rec.start_date,
5607 x_end_date => NVL(biodem_rec.end_date,dup_cur_rec.end_date),
5608 x_mode => 'R'
5609 );
5610
5611 UPDATE igs_pe_eit_int
5612 SET status = '1',
5613 match_ind = '18'
5614 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5615 END IF;
5616
5617 EXCEPTION
5618 WHEN OTHERS THEN
5619 UPDATE igs_pe_eit_int
5620 SET status = '3',
5621 error_code = 'E090'
5622 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5623
5624 -- Call Log detail
5625
5626 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5627
5628 IF (l_request_id IS NULL) THEN
5629 l_request_id := fnd_global.conc_request_id;
5630 END IF;
5631
5632 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.exception '||'E090';
5633
5634 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
5635 fnd_message.set_token('INTERFACE_ID',biodem_rec.interface_eit_id);
5636 fnd_message.set_token('ERROR_CD','E090');
5637
5638 l_debug_str := fnd_message.get || ' ' || SQLERRM;
5639
5640 fnd_log.string_with_context( fnd_log.level_exception,
5641 l_label,
5642 l_debug_str, NULL,
5643 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5644 END IF;
5645
5646 IF l_enable_log = 'Y' THEN
5647 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,'E090','IGS_PE_EIT_INT');
5648 END IF;
5649
5650 END;
5651
5652 ELSIF l_rule ='R' THEN
5653
5654 IF l_match_ind =21 THEN
5655 DECLARE
5656 CURSOR date_overlap(cp_start_date IGS_PE_EIT.start_date%TYPE,
5657 cp_end_date IGS_PE_EIT.end_date%TYPE,
5658 cp_information_type IGS_PE_EIT.information_type%TYPE,
5659 cp_person_id NUMBER) IS
5660 SELECT count(1) FROM IGS_PE_EIT
5661 WHERE person_id = cp_person_id
5662 AND INFORMATION_TYPE = cp_information_type
5663 AND start_date <> cp_start_date
5664 AND (NVL(cp_end_date,IGS_GE_DATE.igsdate('4712/12/31')) BETWEEN START_DATE AND NVL(END_DATE,IGS_GE_DATE.igsdate('4712/12/31'))
5665 OR
5666 cp_start_date BETWEEN START_DATE AND NVL(END_DATE,IGS_GE_DATE.igsdate('4712/12/31'))
5667 OR
5668 ( cp_start_date < START_DATE AND
5669 NVL(end_date,IGS_GE_DATE.igsdate('4712/12/31'))< NVL(cp_end_date,IGS_GE_DATE.igsdate('4712/12/31')) ) );
5670 l_count NUMBER(3);
5671 BEGIN
5672 OPEN date_overlap(biodem_rec.start_date,biodem_rec.end_date,
5673 biodem_rec.information_type,biodem_rec.person_id);
5674 FETCH date_overlap INTO l_count;
5675 CLOSE date_overlap;
5676
5677 IF l_count > 0 THEN
5678
5679 UPDATE igs_pe_eit_int
5680 SET status = '3',
5681 error_code = 'E228'
5682 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5683
5684 IF l_enable_log = 'Y' THEN
5685 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,'E228','IGS_PE_EIT_INT');
5686 END IF;
5687
5688 ELSE
5689 igs_pe_eit_pkg.update_row (
5690 x_rowid => dup_cur_rec.rowid,
5691 x_pe_eit_id => dup_cur_rec.pe_eit_id,
5692 x_person_id => dup_cur_rec.person_id,
5693 x_information_type => dup_cur_rec.information_type,
5694 x_pei_information1 => NVL(biodem_rec.pei_information1,dup_cur_rec.pei_information1),
5695 x_pei_information2 => NVL(biodem_rec.pei_information2,dup_cur_rec.pei_information2),
5696 x_pei_information3 => NVL(biodem_rec.pei_information3,dup_cur_rec.pei_information3),
5697 x_pei_information4 => NVL(biodem_rec.pei_information4,dup_cur_rec.pei_information4),
5698 x_pei_information5 => NVL(biodem_rec.pei_information5,dup_cur_rec.pei_information5),
5699 x_start_date => dup_cur_rec.start_date,
5700 x_end_date => NVL(biodem_rec.end_date,dup_cur_rec.end_date),
5701 x_mode => 'R'
5702 );
5703
5704 UPDATE igs_pe_eit_int
5705 SET status = '1', error_code = NULL,match_ind = '18'
5706 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5707 END IF;
5708 EXCEPTION
5709 WHEN OTHERS THEN
5710 UPDATE igs_pe_eit_int
5711 SET status = '3',
5712 error_code = 'E089'
5713 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5714
5715 -- Call Log detail
5716
5717 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5718
5719 IF (l_request_id IS NULL) THEN
5720 l_request_id := fnd_global.conc_request_id;
5721 END IF;
5722
5723 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat_biodemo.exception '||'E089';
5724
5725 fnd_message.set_name('IGS','IGS_PE_IMP_ERROR');
5726 fnd_message.set_token('INTERFACE_ID',biodem_rec.interface_eit_id);
5727 fnd_message.set_token('ERROR_CD','E089');
5728
5729 l_debug_str := fnd_message.get || ' ' || SQLERRM;
5730
5731 fnd_log.string_with_context( fnd_log.level_exception,
5732 l_label,
5733 l_debug_str, NULL,
5734 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5735 END IF;
5736
5737 IF l_enable_log = 'Y' THEN
5738 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,'E089','IGS_PE_EIT_INT');
5739 END IF;
5740
5741 END;
5742
5743 END IF; -- end if of match ind check
5744 END IF ; -- end if or l_rule
5745
5746 ELSE -- this is the else of Count > 0 ie 2 IF
5747
5748 -- since there are no dup records, insert the current rec in OSS and update the
5749 -- interface table with the status.
5750
5751 crt_biodemo (biodem_rec => biodem_rec,
5752 p_error_code => l_error_code,
5753 p_status => l_status );
5754
5755 UPDATE igs_pe_eit_int
5756 SET status = l_status,
5757 error_code = l_error_code
5758 WHERE interface_eit_id = biodem_rec.interface_eit_id;
5759
5760 -- Call Log detail
5761
5762 IF l_status <> '1' THEN
5763 IF l_enable_log = 'Y' THEN
5764 igs_ad_imp_001.logerrormessage(biodem_rec.interface_eit_id,l_error_code,'IGS_PE_EIT_INT');
5765 END IF;
5766 END IF;
5767 END IF; -- for 2 IF
5768 -- ELSE already taken care in the Validate Record function for update of interface table
5769 END IF; -- for 1 IF
5770 END ;
5771
5772 IF l_processed_records = 100 THEN
5773 COMMIT;
5774 l_processed_records := 0;
5775 END IF;
5776
5777 END LOOP;
5778 --
5779 -- End of Cursor Loop
5780 --
5781
5782 END Prc_Pe_Stat_Biodemo;
5783
5784
5785
5786
5787 -- Import Statistic Details
5788 -- Person Interface DLD, 2103692 -- ssawhney
5789
5790 PROCEDURE Prc_Pe_Stat (
5791 p_source_type_id IN NUMBER,
5792 p_batch_id IN NUMBER )
5793 AS
5794 /*
5795 || Created By : ssawhney
5796 || Purpose : Person Stats Import
5797 || Known limitations, enhancements or remarks :
5798 || Change History :
5799 || Who When What
5800 || pkpatel 6-FEB-2003 bug No: 2758854
5801 || Added the call igs_ad_imp_025.prc_pe_race for processing Multiple Races
5802 */
5803
5804 l_prog_label VARCHAR2(100);
5805 l_label VARCHAR2(100);
5806 l_debug_str VARCHAR2(2000);
5807 l_enable_log VARCHAR2(1);
5808 l_request_id NUMBER;
5809 l_interface_run_id igs_ad_interface_all.interface_run_id%TYPE;
5810 BEGIN
5811
5812 l_prog_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat';
5813 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat.';
5814 l_enable_log := igs_ad_imp_001.g_enable_log;
5815
5816 Prc_Pe_Stat_Main (p_source_type_id, p_batch_id);
5817 Prc_Pe_Stat_Biodemo (p_source_type_id, p_batch_id);
5818 igs_ad_imp_025.prc_pe_race (p_source_type_id, p_batch_id);
5819
5820 EXCEPTION
5821 WHEN OTHERS THEN
5822 IF fnd_log.test(fnd_log.level_exception,l_prog_label) THEN
5823
5824 IF (l_request_id IS NULL) THEN
5825 l_request_id := fnd_global.conc_request_id;
5826 END IF;
5827
5828 l_label := 'igs.plsql.igs_ad_imp_008.prc_pe_stat.exception1';
5829 l_debug_str := SQLERRM || ' ';
5830
5831 fnd_log.string_with_context( fnd_log.level_exception,
5832 l_label,
5833 l_debug_str, NULL,
5834 NULL,NULL,NULL,NULL,TO_CHAR(l_request_id));
5835 END IF;
5836 END Prc_Pe_Stat;
5837
5838
5839
5840 END Igs_Ad_Imp_008;