[Home] [Help]
PACKAGE BODY: APPS.HZ_MAP_PARTY_PUB
Source
1 package body HZ_MAP_PARTY_PUB AS
2 /*$Header: ARHMAPSB.pls 120.73 2010/03/16 18:56:56 awu ship $*/
3
4 /*
5 | MODIFICATION HISTORY
6 | Jan 2003 VJN Introduced Changes for the Mapping Program to call
7 | the conform party procedure, which would conform the purchased
8 | party to the DNB Hierarchy.
9 |
10 +===========================================================================*/
11
12 G_PKG_NAME CONSTANT VARCHAR2(30) := 'HZ_MAP_PARTY_PUB';
13
14 --Bug 1736056: Default country to 'US' if it is NULL.
15 G_DEFAULT_COUNTRY_CODE VARCHAR2(30) := 'US';
16 -- isMixNMatchEnabled VARCHAR2(1) ;
17
18 -- Bug 3107162
19 G_ERROR_FLAG VARCHAR2(1) := 'N';
20 G_PARTY_INTERFACE_ID NUMBER(15);
21
22 TYPE related_duns_rec_type IS RECORD(
23 DUNS_NUMBER hz_party_interface.HQ_DUNS_NUMBER%TYPE,
24 NAME hz_party_interface.HQ_NAME%TYPE,
25 COUNTRY hz_party_interface.HQ_COUNTRY%TYPE,
26 ADDRESS1 hz_party_interface.HQ_ADDRESS1%TYPE,
27 CITY hz_party_interface.HQ_CITY%TYPE,
28 PRIMARY_GEO_AREA hz_party_interface.HQ_PRIMARY_GEO_AREA%TYPE,
29 COUNTY hz_party_interface.HQ_COUNTY%TYPE,
30 POSTAL_CODE hz_party_interface.HQ_POSTAL_CODE%TYPE,
31 PHONE_NUMBER hz_party_interface.HQ_PHONE_NUMBER%TYPE,
32 RELATIONSHIP_CODE hz_relationships.relationship_code%type,
33 RELATIONSHIP_TYPE hz_relationships.relationship_type%type,
34 MAIN_PARTY_ID NUMBER,
35 MAIN_DUNS_NUMBER VARCHAR2(15),
36 CONTENT_SOURCE_TYPE VARCHAR2(30)
37 );
38
39
40 procedure do_map(
41 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
42 x_return_status IN OUT NOCOPY VARCHAR2
43 );
44
45 procedure check_mosr_mapping (
46 p_duns_number_c IN VARCHAR2,
47 --4227564
48 p_party_id IN VARCHAR2,
49 p_inactivate_flag IN VARCHAR2,
50 x_return_status IN OUT NOCOPY VARCHAR2,
51 x_msg_count OUT NOCOPY NUMBER,
52 x_msg_data OUT NOCOPY VARCHAR2
53 );
54
55 procedure populate_to_classification(
56 p_code_assignment_rec IN OUT NOCOPY hz_classification_v2pub.code_assignment_rec_type,
57 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
58 -- p_is_new_party IN BOOLEAN ,
59 x_return_status IN OUT NOCOPY VARCHAR2
60 ) ;
61 -- Bug 3417357 : Added parameter p_create_new
62 procedure store_location(
63 p_location_rec IN OUT NOCOPY hz_location_v2pub.location_rec_type,
64 p_party_id IN NUMBER,
65 p_create_new IN BOOLEAN,
66 x_return_status IN OUT NOCOPY VARCHAR2
67 );
68
69
70 procedure store_financial_report(
71 --p_fin_rep_rec IN OUT NOCOPY hz_org_info_pub.financial_reports_rec_type,
72 p_fin_rep_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.financial_report_rec_type,
73 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
74 x_return_status IN OUT NOCOPY VARCHAR2
75 );
76
77
78 procedure store_financial_number(
79 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
80 --p_fin_num_rec IN OUT NOCOPY hz_org_info_pub.financial_numbers_rec_type,
81 p_fin_num_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.financial_number_rec_type,
82 p_new_fin_report IN VARCHAR2,
83 p_type_of_financial_report IN VARCHAR2,
84 x_return_status IN OUT NOCOPY VARCHAR2
85 );
86
87
88 procedure store_related_duns(
89 p_commit IN VARCHAR2:= FND_API.G_FALSE,
90 p_group_id IN NUMBER,
91 x_return_status IN OUT NOCOPY VARCHAR2
92 );
93
94 -- VJN Added a new OUT parameter for conforming DNB Purchasee
95 procedure do_store_related_duns(
96 p_related_duns_rec IN related_duns_rec_type,
97 x_return_status IN OUT NOCOPY VARCHAR2,
98 x_conform_party_id OUT NOCOPY number
99 );
100
101
102 procedure store_error(
103 p_status VARCHAR2,
104 p_party_interface_id NUMBER
105 );
106
107
108 procedure do_assign_org_record(
109 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
110 l_organization_rec OUT NOCOPY HZ_PARTY_V2PUB.organization_rec_type
111 );
112
113
114 procedure do_assign_location_record(
115 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
116 l_location_rec OUT NOCOPY hz_location_v2pub.location_rec_type
117 );
118
119 procedure do_assign_credit_ratings(
120 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
121 p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE,
122 --l_credit_ratings_rec OUT NOCOPY HZ_PARTY_INFO_PUB.CREDIT_RATINGS_REC_TYPE
123 l_credit_ratings_rec OUT NOCOPY HZ_PARTY_INFO_V2PUB.CREDIT_RATING_REC_TYPE
124 );
125
126 procedure do_assign_financial_report(
127 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
128 --l_fin_rep_rec IN OUT NOCOPY HZ_ORG_INFO_PUB.FINANCIAL_REPORTS_REC_TYPE,
129 l_fin_rep_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_REPORT_REC_TYPE,
130 p_type_of_financial_report IN HZ_FINANCIAL_REPORTS.TYPE_OF_FINANCIAL_REPORT%type
131 );
132
133 PROCEDURE create_dynamic_lookups(
134 p_party_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
135 x_return_status IN OUT NOCOPY VARCHAR2
136 );
137
138 PROCEDURE create_lookup(
139 p_lookup_code IN VARCHAR2,
140 p_lookup_type IN VARCHAR2,
141 x_return_status IN OUT NOCOPY VARCHAR2
142 );
143
144 PROCEDURE rectify_error_fields(
145 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE
146 );
147
148 PROCEDURE set_hz_dnb_invalid_data(
149 p_column_name IN VARCHAR2,
150 p_dnb_value IN VARCHAR2,
151 p_tca_value IN VARCHAR2
152 );
153
154 PROCEDURE check_new_duns(
155 p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE,
156 x_return_status OUT NOCOPY VARCHAR2
157 );
158
159 /*===========================================================================+
160 | FUNCTION
161 | set_hz_dnb_invalid_data
162 |
163 | DESCRIPTION
164 | o If value for any field passed by DNB is not valid, then this
165 | information is stored in hz_party_interface_errors
166 |
167 | SCOPE - PRIVATE
168 |
169 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
170 |
171 | ARGUMENTS : IN:
172 | p_column_name (Column Name)
173 | p_dnb_value (Invalid Value passed by DNB)
174 | p_tca_type (Rectified TCA value)
175 | OUT:
176 | IN/ OUT:
177 |
178 | RETURNS : NONE
179 |
180 | NOTES
181 |
182 | MODIFICATION HISTORY
183 |
184 | 19-AUG-2004 Rajib Ranjan Borah o Bug 3107162. Creted.
185 | 13-OCT-2004 Sravanthi A o Bug 3107162: Modified to set token
186 | to 'NULL' when p_tca_value is null
187 |
188 +===========================================================================*/
189
190 PROCEDURE set_hz_dnb_invalid_data(
191 p_column_name IN VARCHAR2,
192 p_dnb_value IN VARCHAR2,
193 p_tca_value IN VARCHAR2
194 )IS
195 l_message_text VARCHAR2(2000) := NULL;
196 BEGIN
197 FND_MESSAGE.SET_NAME('AR','HZ_DNB_INVALID_DATA');
198 FND_MESSAGE.SET_TOKEN('FIELD_NAME',p_column_name);
199 FND_MESSAGE.SET_TOKEN('DNB_VALUE',p_dnb_value);
200 --bug 3107162: when a field is rectified to NULL error message should
201 --be that the field is set to 'NULL' instead of blank
202 IF p_tca_value IS NULL THEN
203 FND_MESSAGE.SET_TOKEN('TCA_VALUE','NULL');
204 ELSE
205 FND_MESSAGE.SET_TOKEN('TCA_VALUE',p_tca_value);
206 END IF;
207 l_message_text := FND_MESSAGE.GET;
208
209 INSERT INTO hz_party_interface_errors (
210 interface_error_id,
211 party_interface_id,
212 message_text,
213 created_by,
214 creation_date,
215 last_updated_by,
216 last_update_date,
217 last_update_login)
218 VALUES (
219 hz_party_interface_errors_s.nextval,
220 G_PARTY_INTERFACE_ID,
221 l_message_text,
222 hz_utility_v2pub.created_by,
223 hz_utility_v2pub.creation_date,
224 hz_utility_v2pub.last_updated_by,
225 hz_utility_v2pub.last_update_date,
226 hz_utility_v2pub.last_update_login);
227 G_ERROR_FLAG:='Y';
228
229 END set_hz_dnb_invalid_data;
230
231
232 /*===========================================================================+
233 | PROCEDURE
234 | rectify_error_fields
235 |
236 | DESCRIPTION
237 | o If the value passed by DNB for any field is not a valid one,
238 | this procedure replaces the same with a valid value.
239 | ( So that information bought from DNB does not error out NOCOPY ).
240 | ~ Yes/ No lookups will be defaulted to N.
241 | ~ Currency code columns will be set to NULL.
242 | ~ Other lookup code columns will be set to NULL.
243 | o Status in hz_party_interface will be W1, W2 instead of P1,
244 | P2 respectively if this procedure modifies any errorneous
245 | DNB data.
246 | o Inserts a record in hz_party_interface_errors for each field
247 | rectified.
248 |
249 | SCOPE - PRIVATE
250 |
251 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
252 |
253 | o set_hz_dnb_invalid_data
254 |
255 | ARGUMENTS : IN:
256 | OUT:
257 | IN/ OUT: p_interface_rec
258 |
259 | RETURNS : NONE
260 |
261 | NOTES
262 |
263 | MODIFICATION HISTORY
264 |
265 | 18-AUG-2004 Rajib Ranjan Borah o Bug 3107162. Created.
266 | 13-SEP-2004 Rajib Ranjan Borah o Bug 3848365. Dynamic lookups will be
267 | created for invalid sic code values
268 | instead of nullifying them.
269 | 13-OCT-2004 Sravanthi A o Bug 3107162: Commented out NOCOPY code for
270 | validation of det_history_ind
271 | Commented out NOCOPY code that sets local_activity_code
272 | of interface record to 'NACE'.
273 +===========================================================================*/
274
275 PROCEDURE rectify_error_fields(
276 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE
277 ) IS
278
279 CURSOR c_currency_field (p_currency_code IN VARCHAR2) IS
280 SELECT '1'
281 FROM FND_CURRENCIES
282 WHERE currency_code = p_currency_code AND
283 currency_flag = 'Y' AND
284 enabled_flag IN ('Y','N') AND
285 (
286 start_date_active IS NULL OR
287 start_date_active <= SYSDATE
288 ) AND
289 (
290 end_date_active IS NULL OR
291 end_date_active >= SYSDATE
292 );
293
294 CURSOR c_ar_lookup_field (p_lookup_type IN VARCHAR2, p_lookup_code IN VARCHAR2) IS
295 SELECT '1'
296 FROM AR_LOOKUPS
297 WHERE lookup_type = p_lookup_type AND
298 lookup_code = p_lookup_code AND
299 enabled_flag = 'Y' AND
300 (
301 start_date_active IS NULL OR
302 start_date_active <= SYSDATE
303 ) AND
304 (
305 end_date_active IS NULL OR
306 END_DATE_ACTIVE >= SYSDATE
307 );
308 l_temp_cur_var VARCHAR2(1);
309 BEGIN
310 G_ERROR_FLAG := 'N';
311 G_PARTY_INTERFACE_ID := p_interface_rec.party_interface_id;
312
313 /*----------------------------------------------------------------------*/
314 -- Currency related columns are set to NULL if the value is not present --
315 -- in FND_CURRENCIES.currency.code. --
316 -- --
317 -- Such columns include: --
318 -- ~ ANNUAL_SALES_CURRENCY --
319 -- ~ CAPITAL_CURRENCY_CODE --
320 -- ~ FINANCIAL_NUMBER_CURRENCY --
321 -- ~ MAX_CREDIT_CURRENCY --
322 -- ~ PREF_FUNCTIONAL_CURRENCY --
323 -- ~ TANGIBLE_NET_WORTH_CURR --
324 /*----------------------------------------------------------------------*/
325
326 IF p_interface_rec.annual_sales_currency IS NOT NULL THEN
327 OPEN c_currency_field( p_interface_rec.annual_sales_currency);
328 FETCH c_currency_field INTO l_temp_cur_var;
329 IF c_currency_field%NOTFOUND THEN
330 set_hz_dnb_invalid_data( p_column_name => 'ANNUAL_SALES_CURRENCY',
331 p_dnb_value => p_interface_rec.annual_sales_currency,
332 p_tca_value => NULL);
333 p_interface_rec.annual_sales_currency := NULL;
334 END IF;
335 CLOSE c_currency_field;
336 END IF;
337
338 IF p_interface_rec.capital_currency_code IS NOT NULL THEN
339 OPEN c_currency_field( p_interface_rec.capital_currency_code);
340 FETCH c_currency_field INTO l_temp_cur_var;
341 IF c_currency_field%NOTFOUND THEN
342 set_hz_dnb_invalid_data( p_column_name => 'CAPITAL_CURRENCY_CODE',
343 p_dnb_value => p_interface_rec.capital_currency_code,
344 p_tca_value => NULL);
345 p_interface_rec.capital_currency_code := NULL;
346 END IF;
347 CLOSE c_currency_field;
348 END IF;
349
350 IF p_interface_rec.financial_number_currency IS NOT NULL THEN
351 OPEN c_currency_field( p_interface_rec.financial_number_currency);
352 FETCH c_currency_field INTO l_temp_cur_var;
353 IF c_currency_field%NOTFOUND THEN
354 set_hz_dnb_invalid_data( p_column_name => 'FINANCIAL_NUMBER_CURRENCY',
355 p_dnb_value => p_interface_rec.financial_number_currency,
356 p_tca_value => NULL);
357 p_interface_rec.financial_number_currency := NULL;
358 END IF;
359 CLOSE c_currency_field;
360 END IF;
361
362 IF p_interface_rec.max_credit_currency IS NOT NULL THEN
363 OPEN c_currency_field( p_interface_rec.max_credit_currency);
364 FETCH c_currency_field INTO l_temp_cur_var;
365 IF c_currency_field%NOTFOUND THEN
366 set_hz_dnb_invalid_data( p_column_name => 'MAX_CREDIT_CURRENCY',
367 p_dnb_value => p_interface_rec.max_credit_currency,
368 p_tca_value => NULL);
369 p_interface_rec.max_credit_currency := NULL;
370 END IF;
371 CLOSE c_currency_field;
372 END IF;
373
374 IF p_interface_rec.pref_functional_currency IS NOT NULL THEN
375 OPEN c_currency_field( p_interface_rec.pref_functional_currency);
376 FETCH c_currency_field INTO l_temp_cur_var;
377 IF c_currency_field%NOTFOUND THEN
378 set_hz_dnb_invalid_data( p_column_name => 'PREF_FUNCTIONAL_CURRENCY',
379 p_dnb_value => p_interface_rec.pref_functional_currency,
380 p_tca_value => NULL);
381 p_interface_rec.pref_functional_currency := NULL;
382 END IF;
383 CLOSE c_currency_field;
384 END IF;
385
386 IF p_interface_rec.tangible_net_worth_curr IS NOT NULL THEN
387 OPEN c_currency_field( p_interface_rec.tangible_net_worth_curr);
388 FETCH c_currency_field INTO l_temp_cur_var;
389 IF c_currency_field%NOTFOUND THEN
390 set_hz_dnb_invalid_data( p_column_name => 'TANGIBLE_NET_WORTH_CURR',
391 p_dnb_value => p_interface_rec.tangible_net_worth_curr,
392 p_tca_value => NULL);
393 p_interface_rec.tangible_net_worth_curr := NULL;
394 END IF;
395 CLOSE c_currency_field;
396 END IF;
397
398 /*--------------------------------------------------------------------*/
399 -- Phone_country_code should be a valid value in HZ_PHONE_COUNTRY_CODES.
400 --
401 -- Set to NULL otherwise.
402 /*--------------------------------------------------------------------*/
403
404 BEGIN
405 IF p_interface_rec.phone_country_code IS NOT NULL THEN
406 SELECT '1'
407 INTO l_temp_cur_var
408 FROM HZ_PHONE_COUNTRY_CODES
409 WHERE phone_country_code = p_interface_rec.phone_country_code AND
410 ROWNUM = 1;
411 END IF;
412 EXCEPTION
413 WHEN NO_DATA_FOUND THEN
414 set_hz_dnb_invalid_data(
415 p_column_name => 'PHONE_COUNTRY_CODE',
416 p_dnb_value => p_interface_rec.phone_country_code,
417 p_tca_value => NULL );
418 p_interface_rec.phone_country_code := NULL;
419 END;
420
421 /*--------------------------------------------------------------------*/
422 -- Local_activity_code_type should be a valid lookup code in lookup --
423 -- type LOCAL_ACTIVITY_CODE_TYPE --
424 -- --
425 -- If local_activity_code_type is not a valid value, nullify both --
426 -- local_activity_code_type and loacl_activity_code. --
427 /*--------------------------------------------------------------------*/
428
429 BEGIN
430 IF p_interface_rec.local_activity_code_type IS NOT NULL THEN
431 OPEN c_ar_lookup_field ('LOCAL_ACTIVITY_CODE_TYPE',p_interface_rec.local_activity_code_type);
432 FETCH c_ar_lookup_field INTO l_temp_cur_var;
433
434 IF c_ar_lookup_field%NOTFOUND THEN
435 set_hz_dnb_invalid_data(
436 p_column_name => 'LOCAL_ACTIVITY_CODE_TYPE',
437 p_dnb_value => p_interface_rec.local_activity_code_type,
438 p_tca_value => NULL);
439 p_interface_rec.local_activity_code_type := NULL;
440
441 IF p_interface_rec.local_activity_code IS NOT NULL THEN
442 set_hz_dnb_invalid_data(
443 p_column_name => 'LOCAL_ACTIVITY_CODE',
444 p_dnb_value => p_interface_rec.local_activity_code,
445 p_tca_value => NULL);
446 p_interface_rec.local_activity_code := NULL;
447 END IF;
448 --bug 3107162: Commented out this code
449 -- ELSIF p_interface_rec.local_activity_code_type IN ('4','5') THEN
450 -- p_interface_rec.local_activity_code_type := 'NACE';
451 ELSIF p_interface_rec.local_activity_code_type IN ('4','5') THEN
452 p_interface_rec.local_activity_code := SUBSTRB(REPLACE(p_interface_rec.local_activity_code,' ',''),1,4);
453 END IF;
454 CLOSE c_ar_lookup_field;
455 ELSE -- Local activity code type is NULL
456 IF p_interface_rec.local_activity_code IS NOT NULL THEN
457 -- Local activity code is not NULL but type is NULL, so nullify code also.
458 set_hz_dnb_invalid_data(
459 p_column_name => 'LOCAL_ACTIVITY_CODE',
460 p_dnb_value => p_interface_rec.local_activity_code,
461 p_tca_value => NULL);
462 p_interface_rec.local_activity_code := NULL;
463 END IF;
464 END IF;
465 END;
466
467 -- Rectification of hq_branch_ind, local_bus_iden_type, rent_own_ind.
468 BEGIN
469 IF p_interface_rec.hq_branch_ind = 'H' THEN
470 p_interface_rec.hq_branch_ind := 'HQ';
471 ELSIF p_interface_rec.hq_branch_ind = 'B' THEN
472 p_interface_rec.hq_branch_ind := 'BR';
473 ELSIF p_interface_rec.hq_branch_ind = 'S' THEN
474 p_interface_rec.hq_branch_ind := 'SL';
475 ELSIF p_interface_rec.hq_branch_ind IS NOT NULL THEN
476 OPEN c_ar_lookup_field ('HQ_BRANCH_IND',p_interface_rec.hq_branch_ind);
477 FETCH c_ar_lookup_field INTO l_temp_cur_var;
478 IF c_ar_lookup_field%NOTFOUND THEN
479 set_hz_dnb_invalid_data( p_column_name => 'HQ_BRANCH_IND',
480 p_dnb_value => p_interface_rec.hq_branch_ind,
481 p_tca_value => NULL);
482 p_interface_rec.hq_branch_ind := NULL;
483 END IF;
484 CLOSE c_ar_lookup_field;
485 END IF;
486 END;
487
488 IF p_interface_rec.local_bus_iden_type IS NOT NULL THEN
489 OPEN c_ar_lookup_field ('LOCAL_BUS_IDEN_TYPE',p_interface_rec.local_bus_iden_type );
490 FETCH c_ar_lookup_field INTO l_temp_cur_var;
491 IF c_ar_lookup_field%NOTFOUND THEN
492 set_hz_dnb_invalid_data( p_column_name => 'LOCAL_BUS_IDEN_TYPE',
493 p_dnb_value => p_interface_rec.local_bus_iden_type,
494 p_tca_value => NULL);
495 p_interface_rec.local_bus_iden_type := NULL;
496 END IF;
497 CLOSE c_ar_lookup_field;
498 END IF;
499
500 IF p_interface_rec.rent_own_ind IS NOT NULL THEN
501 OPEN c_ar_lookup_field( 'OWN_RENT_IND',p_interface_rec.rent_own_ind );
502 FETCH c_ar_lookup_field INTO l_temp_cur_var;
503 IF c_ar_lookup_field%NOTFOUND THEN
504 set_hz_dnb_invalid_data( p_column_name => 'RENT_OWN_IND',
505 p_dnb_value => p_interface_rec.rent_own_ind,
506 p_tca_value => NULL);
507 p_interface_rec.rent_own_ind := NULL;
508 END IF;
509 CLOSE c_ar_lookup_field;
510 END IF;
511
512 /*-------------------------------------------------------*/
513 -- Bug 4086866: If the passed value for YEAR_ESTABLISHED or INCORP_YEAR
514 -- has more than 4 characters, set the field to NULL.
515 /*-------------------------------------------------------*/
516 IF p_interface_rec.year_established > 9999 or p_interface_rec.year_established < 0 THEN
517 set_hz_dnb_invalid_data( p_column_name => 'YEAR_ESTABLISHED',
518 p_dnb_value => p_interface_rec.year_established,
519 p_tca_value => NULL);
520 p_interface_rec.year_established := NULL;
521 END IF;
522
523 IF p_interface_rec.incorp_year > 9999 or p_interface_rec.incorp_year < 0 THEN
524 set_hz_dnb_invalid_data( p_column_name => 'INCORP_YEAR',
525 p_dnb_value => p_interface_rec.incorp_year,
526 p_tca_value => NULL);
527 p_interface_rec.incorp_year := NULL;
528 END IF;
529
530 /*---------------------------------------------------------------------*/
531 -- If the value for SIC_CODE_TYPE is not a valid lookup_code of lookup --
532 -- type 'SIC_CODE_TYPE', set the value of SIC_CODE_TYPE and SIC_CODE1, --
533 -- SIC_CODE2,..SIC_CODE6 to NULL. --
534 -- Furthermore, if any of the sic codes have a value, and sic code --
535 -- type is NULL, then default it to '1985 SIC' --
536 /*---------------------------------------------------------------------*/
537 DECLARE
538 p_sic_code_substrb_flag BOOLEAN := FALSE;
539 BEGIN
540 IF replace(p_interface_rec.sic_code_type, ' ','') IN ('1972','1977','1987') THEN
541 p_interface_rec.sic_code_type := replace(p_interface_rec.sic_code_type,' ','') || ' SIC';
542 END IF;
543
544 IF p_interface_rec.sic_code_type IS NOT NULL THEN
545 OPEN c_ar_lookup_field( 'SIC_CODE_TYPE',p_interface_rec.sic_code_type);
546 FETCH c_ar_lookup_field INTO l_temp_cur_var;
547 IF c_ar_lookup_field%NOTFOUND THEN
548 -- SIC_CODE_TYPE is an invalid value.
549 -- Nullify SIC_CODE_TYPE and SIC_CODE1...SIC_CODE6.
550 CLOSE c_ar_lookup_field;
551
552 set_hz_dnb_invalid_data(
553 p_column_name => 'SIC_CODE_TYPE',
554 p_dnb_value => p_interface_rec.sic_code_type,
555 p_tca_value => NULL);
556 p_interface_rec.sic_code_type := NULL;
557
558 IF p_interface_rec.sic_code1 IS NOT NULL THEN
559 set_hz_dnb_invalid_data(
560 p_column_name => 'SIC_CODE1',
561 p_dnb_value => p_interface_rec.sic_code1,
562 p_tca_value => NULL);
563 p_interface_rec.sic_code1 := NULL;
564 END IF;
565
566 IF p_interface_rec.sic_code2 IS NOT NULL THEN
567 set_hz_dnb_invalid_data(
568 p_column_name => 'SIC_CODE2',
569 p_dnb_value => p_interface_rec.sic_code2,
570 p_tca_value => NULL);
571 p_interface_rec.sic_code2 := NULL;
572 END IF;
573
574 IF p_interface_rec.sic_code3 IS NOT NULL THEN
575 set_hz_dnb_invalid_data(
576 p_column_name => 'SIC_CODE3',
577 p_dnb_value => p_interface_rec.sic_code3,
578 p_tca_value => NULL);
579 p_interface_rec.sic_code3 := NULL;
580 END IF;
581
582 IF p_interface_rec.sic_code4 IS NOT NULL THEN
583 set_hz_dnb_invalid_data(
584 p_column_name => 'SIC_CODE4',
585 p_dnb_value => p_interface_rec.sic_code4,
586 p_tca_value => NULL);
587 p_interface_rec.sic_code4 := NULL;
588 END IF;
589
590 IF p_interface_rec.sic_code5 IS NOT NULL THEN
591 set_hz_dnb_invalid_data(
592 p_column_name => 'SIC_CODE5',
593 p_dnb_value => p_interface_rec.sic_code5,
594 p_tca_value => NULL);
595 p_interface_rec.sic_code5 := NULL;
596 END IF;
597
598 IF p_interface_rec.sic_code6 IS NOT NULL THEN
599 set_hz_dnb_invalid_data(
600 p_column_name => 'SIC_CODE6',
601 p_dnb_value => p_interface_rec.sic_code6,
602 p_tca_value => NULL);
603 p_interface_rec.sic_code6 := NULL;
604 END IF;
605
606 ELSE
607
608 CLOSE c_ar_lookup_field;
609 IF (
610 p_interface_rec.sic_code1 IS NULL AND
611 p_interface_rec.sic_code2 IS NULL AND
612 p_interface_rec.sic_code3 IS NULL AND
613 p_interface_rec.sic_code4 IS NULL AND
614 p_interface_rec.sic_code5 IS NULL AND
615 p_interface_rec.sic_code6 IS NULL
616 )
617 THEN
618 -- Either both sic code type and sic code should have a value or none
619 -- should have a value.
620 -- As sic codes are NULL, therefore Nullify sic_code_type.
621 set_hz_dnb_invalid_data(
622 p_column_name => 'SIC_CODE_TYPE',
623 p_dnb_value => p_interface_rec.sic_code_type,
624 p_tca_value => NULL);
625 p_interface_rec.sic_code_type := NULL;
626 ELSE
627 p_sic_code_substrb_flag := TRUE;
628 END IF;
629 END IF;
630 ELSE
631 IF (
632 p_interface_rec.sic_code1 IS NOT NULL OR
633 p_interface_rec.sic_code2 IS NOT NULL OR
634 p_interface_rec.sic_code3 IS NOT NULL OR
635 p_interface_rec.sic_code4 IS NOT NULL OR
636 p_interface_rec.sic_code5 IS NOT NULL OR
637 p_interface_rec.sic_code6 IS NOT NULL
638 )
639 THEN
640 -- Set default value of sic_code_type.
641 p_interface_rec.sic_code_type := '1987 SIC';
642 p_sic_code_substrb_flag := TRUE;
643 END IF;
644 END IF;
645 IF p_sic_code_substrb_flag = TRUE THEN
646 -- Need to modify this when a decision on enhancement request 3848373 is done.
647 p_interface_rec.sic_code1 := SUBSTRB(REPLACE(p_interface_rec.sic_code1,' ',''),1,4);
648 p_interface_rec.sic_code2 := SUBSTRB(REPLACE(p_interface_rec.sic_code2,' ',''),1,4);
649 p_interface_rec.sic_code3 := SUBSTRB(REPLACE(p_interface_rec.sic_code3,' ',''),1,4);
650 p_interface_rec.sic_code4 := SUBSTRB(REPLACE(p_interface_rec.sic_code4,' ',''),1,4);
651 p_interface_rec.sic_code5 := SUBSTRB(REPLACE(p_interface_rec.sic_code5,' ',''),1,4);
652 p_interface_rec.sic_code6 := SUBSTRB(REPLACE(p_interface_rec.sic_code6,' ',''),1,4);
653 END IF;
654 END;
655
656 /*---------------------------------------------------------------------*/
657 -- Columns which are validated against Y/N are changed to 'N' if the
658 -- value is something other than 'Y'/'N'.
659 --
660 -- Such columns include:
661 -- ~ ANNUAL_SALES_CONSOL_IND ~ AUDIT_IND ~ BANKRUPTCY_IND
662 -- ~ BRANCH_FLAG ~ CLAIMS_IND ~ CONSOLIDATED_IND
663 -- ~ CRIMINAL_PROCEEDING_IND ~ DET_HISTORY_IND ~ DISADV_8A_IND
664 -- ~ DISASTER_IND ~ ESTIMATED_IND ~ EXPORT_IND
665 -- ~ FINAL_IND ~ FINCL_EMBT_IND ~ FINCL_LGL_EVENT_IND
666 -- ~ FISCAL_IND ~ FORECAST_IND ~ IMPORT_IND
667 -- ~ JUDGEMENT_IND ~ LABOR_SURPLUS_IND ~ LIEN_IND
668 -- ~ MINORITY_OWNED_IND ~ NO_TRADE_IND ~ OOB_IND
669 -- ~ OPENING_IND ~ OPRG_SPEC_EVNT_IND ~ OTHER_SPEC_EVNT_IND
670 -- ~ PARENT_SUB_IND ~ PRNT_HQ_BKCY_IND ~ PROFORMA_IND
671 -- ~ QUALIFIED_IND ~ RESTATED_IND ~ SECURED_FLNG_IND
672 -- ~ SIGNED_BY_PRINCIPALS_IND ~ SMALL_BUS_IND ~ SUIT_IND
673 -- ~ TRIAL_BALANCE_IND ~ UNBALANCED_IND ~ WOMAN_OWNED_IND
674 /*---------------------------------------------------------------------*/
675 IF p_interface_rec.annual_sales_consol_ind NOT IN ('Y' ,'N') THEN
676 set_hz_dnb_invalid_data( p_column_name => 'ANNUAL_SALES_CONSOL_IND',
677 p_dnb_value => p_interface_rec.annual_sales_consol_ind,
678 p_tca_value => 'N');
679 p_interface_rec.annual_sales_consol_ind := 'N';
680 END IF;
681
682 IF p_interface_rec.audit_ind NOT IN ('Y' ,'N') THEN
683 set_hz_dnb_invalid_data( p_column_name => 'AUDIT_IND',
684 p_dnb_value => p_interface_rec.audit_ind,
685 p_tca_value => 'N');
686 p_interface_rec.audit_ind := 'N';
687 END IF;
688
689 IF p_interface_rec.bankruptcy_ind IS NULL THEN
690 p_interface_rec.bankruptcy_ind := 'N';
691 ELSIF p_interface_rec.bankruptcy_ind = 'B' THEN
692 p_interface_rec.bankruptcy_ind := 'Y';
693 ELSIF p_interface_rec.bankruptcy_ind NOT IN ('Y','N') THEN
694 set_hz_dnb_invalid_data( p_column_name => 'BANKRUPTCY_IND',
695 p_dnb_value => p_interface_rec.bankruptcy_ind,
696 p_tca_value => 'N');
697 p_interface_rec.bankruptcy_ind := 'N';
698 END IF;
699
700 IF p_interface_rec.branch_flag NOT IN ('Y','N') THEN
701 set_hz_dnb_invalid_data( p_column_name => 'BRANCH_FLAG',
702 p_dnb_value => p_interface_rec.branch_flag,
703 p_tca_value => 'N');
704 p_interface_rec.branch_flag := 'N';
705 END IF;
706
707 IF p_interface_rec.claims_ind NOT IN ('Y','N') THEN
708 set_hz_dnb_invalid_data( p_column_name => 'CLAIMS_IND',
709 p_dnb_value => p_interface_rec.claims_ind,
710 p_tca_value => 'N');
711 p_interface_rec.claims_ind := 'N';
712 END IF;
713
714 IF p_interface_rec.consolidated_ind = 'C' THEN
715 p_interface_rec.consolidated_ind := 'Y';
716 ELSIF p_interface_rec.consolidated_ind NOT IN ('Y','N') THEN
717 set_hz_dnb_invalid_data( p_column_name => 'CONSOLIDATED_IND',
718 p_dnb_value => p_interface_rec.consolidated_ind,
719 p_tca_value => 'N');
720 p_interface_rec.consolidated_ind := 'N';
721 END IF;
722
723 IF p_interface_rec.criminal_proceeding_ind NOT IN ('Y','N') THEN
724 set_hz_dnb_invalid_data( p_column_name => 'CRIMINAL_PROCEEDING_IND',
725 p_dnb_value => p_interface_rec.criminal_proceeding_ind,
726 p_tca_value => 'N');
727 p_interface_rec.criminal_proceeding_ind := 'N';
728 END IF;
729
730 --bug 3107162: commented validation of det_history_ind for the present.
731 /* IF p_interface_rec.det_history_ind NOT IN ('Y','N') THEN
732 set_hz_dnb_invalid_data( p_column_name => 'DET_HISTORY_IND',
733 p_dnb_value => p_interface_rec.det_history_ind,
734 p_tca_value => 'N');
735 p_interface_rec.det_history_ind := 'N';
736 END IF;*/
737
738 IF p_interface_rec.disadv_8a_ind NOT IN ( 'Y','N') THEN
739 set_hz_dnb_invalid_data( p_column_name => 'DISADV_8A_IND',
740 p_dnb_value => p_interface_rec.disadv_8a_ind,
741 p_tca_value => 'N');
742 p_interface_rec.disadv_8a_ind := 'N';
743 END IF;
744
745 IF p_interface_rec.disaster_ind NOT IN ('Y','N') THEN
746 set_hz_dnb_invalid_data( p_column_name => 'DISASTER_IND',
747 p_dnb_value => p_interface_rec.disaster_ind,
748 p_tca_value => 'N');
749 p_interface_rec.disaster_ind := 'N';
750 END IF;
751
752 IF p_interface_rec.estimated_ind NOT IN ('Y','N') THEN
753 set_hz_dnb_invalid_data( p_column_name => 'ESTIMATED_IND',
754 p_dnb_value => p_interface_rec.estimated_ind,
755 p_tca_value => 'N');
756 p_interface_rec.estimated_ind := 'N';
757 END IF;
758
759 IF p_interface_rec.export_ind NOT IN ('Y','N') THEN
760 set_hz_dnb_invalid_data( p_column_name => 'EXPORT_IND',
761 p_dnb_value => p_interface_rec.export_ind,
762 p_tca_value => 'N');
763 p_interface_rec.export_ind := 'N';
764 END IF;
765
766 IF p_interface_rec.final_ind NOT IN ('Y','N') THEN
767 set_hz_dnb_invalid_data( p_column_name => 'FINAL_IND',
768 p_dnb_value => p_interface_rec.final_ind,
769 p_tca_value => 'N');
770 p_interface_rec.final_ind := 'N';
771 END IF;
772
773 IF p_interface_rec.fincl_embt_ind NOT IN ('Y','N') THEN
774 set_hz_dnb_invalid_data( p_column_name => 'FINCL_EMBT_IND',
775 p_dnb_value => p_interface_rec.fincl_embt_ind,
776 p_tca_value => 'N');
777 p_interface_rec.fincl_embt_ind := 'N';
778 END IF;
779
780 IF p_interface_rec.fincl_lgl_event_ind NOT IN ('Y','N') THEN
781 set_hz_dnb_invalid_data( p_column_name => 'FINCL_LGL_EVETN_IND',
782 p_dnb_value => p_interface_rec.fincl_lgl_event_ind,
783 p_tca_value => 'N');
784 p_interface_rec.fincl_lgl_event_ind := 'N';
785 END IF;
786
787 IF p_interface_rec.fiscal_ind NOT IN ('Y','N') THEN
788 set_hz_dnb_invalid_data( p_column_name => 'FISCAL_IND',
789 p_dnb_value => p_interface_rec.fiscal_ind,
790 p_tca_value => 'N');
791 p_interface_rec.fiscal_ind := 'N';
792 END IF;
793
794 IF p_interface_rec.forecast_ind NOT IN ('Y','N') THEN
795 set_hz_dnb_invalid_data( p_column_name => 'FORECAST_IND',
796 p_dnb_value => p_interface_rec.forecast_ind,
797 p_tca_value => 'N');
798 p_interface_rec.forecast_ind := 'N';
799 END IF;
800
801 IF p_interface_rec.import_ind NOT IN ('Y','N') THEN
802 set_hz_dnb_invalid_data( p_column_name => 'IMPORT_IND',
803 p_dnb_value => p_interface_rec.import_ind,
804 p_tca_value => 'N');
805 p_interface_rec.import_ind := 'N';
806 END IF;
807
808 IF p_interface_rec.judgement_ind IS NULL THEN
809 p_interface_rec.judgement_ind := 'N';
810 ELSIF p_interface_rec.judgement_ind = 'J' THEN
811 p_interface_rec.judgement_ind := 'Y';
812 ELSIF p_interface_rec.judgement_ind NOT IN ('Y','N') THEN
813 set_hz_dnb_invalid_data( p_column_name => 'JUDGEMENT_IND',
814 p_dnb_value => p_interface_rec.judgement_ind,
815 p_tca_value => 'N');
816 p_interface_rec.judgement_ind := 'N';
817 END IF;
818
819 IF p_interface_rec.labor_surplus_ind NOT IN ('Y','N') THEN
820 set_hz_dnb_invalid_data( p_column_name => 'LABOR_SURPLUS_IND',
821 p_dnb_value => p_interface_rec.labor_surplus_ind,
822 p_tca_value => 'N');
823 p_interface_rec.labor_surplus_ind := 'N';
824 END IF;
825
826 IF p_interface_rec.lien_ind IS NULL THEN
827 p_interface_rec.lien_ind := 'N';
828 ELSIF p_interface_rec.lien_ind = 'L' THEN
829 p_interface_rec.lien_ind := 'Y';
830 ELSIF p_interface_rec.lien_ind NOT IN ('Y','N') THEN
831 set_hz_dnb_invalid_data( p_column_name => 'LIEN_IND',
832 p_dnb_value => p_interface_rec.lien_ind,
833 p_tca_value => 'N');
834 p_interface_rec.lien_ind := 'N';
835 END IF;
836
837 IF p_interface_rec.minority_owned_ind NOT IN ('Y','N') THEN
838 set_hz_dnb_invalid_data( p_column_name => 'MINORITY_OWNED_IND',
839 p_dnb_value => p_interface_rec.minority_owned_ind,
840 p_tca_value => 'N');
841 p_interface_rec.minority_owned_ind := 'N';
842 END IF;
843
844 IF p_interface_rec.no_trade_ind IS NULL THEN
845 p_interface_rec.no_trade_ind := 'Y';
846 ELSIF p_interface_rec.no_trade_ind NOT IN ('Y','N') THEN
847 set_hz_dnb_invalid_data( p_column_name => 'NO_TRADE_IND',
848 p_dnb_value => p_interface_rec.no_trade_ind,
849 p_tca_value => 'N');
850 p_interface_rec.no_trade_ind := 'N';
851 END IF;
852
853 IF p_interface_rec.oob_ind = 'OB' THEN
854 p_interface_rec.oob_ind := 'Y';
855 ELSIF p_interface_rec.oob_ind NOT IN ('Y','N') THEN
856 set_hz_dnb_invalid_data( p_column_name => 'OOB_IND',
857 p_dnb_value => p_interface_rec.oob_ind,
858 p_tca_value => 'N');
859 p_interface_rec.oob_ind := 'N';
860 END IF;
861
862 IF p_interface_rec.opening_ind NOT IN ('Y','N') THEN
863 set_hz_dnb_invalid_data( p_column_name => 'OPENING_IND',
864 p_dnb_value => p_interface_rec.opening_ind,
865 p_tca_value => 'N');
866 p_interface_rec.opening_ind := 'N';
867 END IF;
868
869 IF p_interface_rec.oprg_spec_evnt_ind NOT IN ('Y','N') THEN
870 set_hz_dnb_invalid_data( p_column_name => 'OPRG_SPEC_EVNT_IND',
871 p_dnb_value => p_interface_rec.oprg_spec_evnt_ind,
872 p_tca_value => 'N');
873 p_interface_rec.oprg_spec_evnt_ind := 'N';
874 END IF;
875
876 IF p_interface_rec.other_spec_evnt_ind NOT IN ('Y','N') THEN
877 set_hz_dnb_invalid_data( p_column_name => 'OTHER_SPEC_EVNT_IND',
878 p_dnb_value => p_interface_rec.other_spec_evnt_ind,
879 p_tca_value => 'N');
880 p_interface_rec.other_spec_evnt_ind := 'N';
881 END IF;
882
883 IF p_interface_rec.parent_sub_ind NOT IN ('Y','N') THEN
884 set_hz_dnb_invalid_data( p_column_name => 'PARENT_SUB_IND',
885 p_dnb_value => p_interface_rec.parent_sub_ind,
886 p_tca_value => 'N');
887 p_interface_rec.parent_sub_ind := 'N';
888 END IF;
889
890 IF p_interface_rec.prnt_hq_bkcy_ind NOT IN ('Y','N') THEN
891 set_hz_dnb_invalid_data( p_column_name => 'PRNT_HQ_BKCY_IND',
892 p_dnb_value => p_interface_rec.prnt_hq_bkcy_ind,
893 p_tca_value => 'N');
894 p_interface_rec.prnt_hq_bkcy_ind := 'N';
895 END IF;
896
897 IF p_interface_rec.proforma_ind IS NULL THEN
898 p_interface_rec.proforma_ind := 'N';
899 ELSIF p_interface_rec.proforma_ind NOT IN ('Y','N') THEN
900 set_hz_dnb_invalid_data( p_column_name => 'PROFORMA_IND',
901 p_dnb_value => p_interface_rec.proforma_ind,
902 p_tca_value => 'N');
903 p_interface_rec.proforma_ind := 'N';
904 END IF;
905
906 IF p_interface_rec.qualified_ind NOT IN ('Y','N') THEN
907 set_hz_dnb_invalid_data( p_column_name => 'QUALIFIED_IND',
908 p_dnb_value => p_interface_rec.qualified_ind,
909 p_tca_value => 'N');
910 p_interface_rec.qualified_ind := 'N';
911 END IF;
912
913 IF p_interface_rec.restated_ind NOT IN ('Y','N') THEN
914 set_hz_dnb_invalid_data( p_column_name => 'RESTATED_IND',
915 p_dnb_value => p_interface_rec.restated_ind,
916 p_tca_value => 'N');
917 p_interface_rec.restated_ind := 'N';
918 END IF;
919
920 IF p_interface_rec.secured_flng_ind NOT IN ('Y','N') THEN
921 set_hz_dnb_invalid_data( p_column_name => 'SECURED_FLNG_IND',
922 p_dnb_value => p_interface_rec.secured_flng_ind,
923 p_tca_value => 'N');
924 p_interface_rec.secured_flng_ind := 'N';
925 END IF;
926
927 IF p_interface_rec.signed_by_principals_ind NOT IN ('Y','N') THEN
928 set_hz_dnb_invalid_data( p_column_name => 'SIGNED_BY_PRINCIPALS_IND',
929 p_dnb_value => p_interface_rec.signed_by_principals_ind,
930 p_tca_value => 'N');
931 p_interface_rec.signed_by_principals_ind := 'N';
932 END IF;
933
934 IF p_interface_rec.small_bus_ind NOT IN ('Y','N') THEN
935 set_hz_dnb_invalid_data( p_column_name => 'SMALL_BUS_IND',
936 p_dnb_value => p_interface_rec.small_bus_ind,
937 p_tca_value => 'N');
938 p_interface_rec.small_bus_ind := 'N';
939 END IF;
940
941 IF p_interface_rec.suit_ind IS NULL THEN
942 p_interface_rec.suit_ind := 'N';
943 ELSIF p_interface_rec.suit_ind = 'S' THEN
944 p_interface_rec.suit_ind := 'Y';
945 ELSIF p_interface_rec.suit_ind NOT IN ('Y','N') THEN
946 set_hz_dnb_invalid_data( p_column_name => 'SUIT_IND',
947 p_dnb_value => p_interface_rec.suit_ind,
948 p_tca_value => 'N');
949 p_interface_rec.suit_ind := 'N';
950 END IF;
951
952 IF p_interface_rec.trial_balance_ind NOT IN ('Y','N') THEN
953 set_hz_dnb_invalid_data( p_column_name => 'TRIAL_BALANCE_IND',
954 p_dnb_value => p_interface_rec.trial_balance_ind,
955 p_tca_value =>'N');
956 p_interface_rec.trial_balance_ind := 'N';
957 END IF;
958
959 IF p_interface_rec.unbalanced_ind NOT IN ('Y','N') THEN
960 set_hz_dnb_invalid_data( p_column_name => 'UNBALANCED_IND',
961 p_dnb_value => p_interface_rec.unbalanced_ind,
962 p_tca_value =>'N');
963 p_interface_rec.unbalanced_ind := 'N';
964 END IF;
965
966 IF p_interface_rec.woman_owned_ind NOT IN ('Y','N') THEN
967 set_hz_dnb_invalid_data( p_column_name => 'WOMAN_OWNED_IND',
968 p_dnb_value => p_interface_rec.woman_owned_ind,
969 p_tca_value =>'N');
970 p_interface_rec.woman_owned_ind := 'N';
971 END IF;
972
973 END rectify_error_fields;
974
975
976 procedure do_add_policy_function
977 IS
978
979 l_ar_schema VARCHAR2(30);
980 l_apps_schema VARCHAR2(30);
981 l_aol_schema VARCHAR2(30);
982 l_apps_mls_schema VARCHAR2(30);
983
984 l_status VARCHAR2(30);
985 l_industry VARCHAR2(30);
986 l_return_value BOOLEAN;
987
988 BEGIN
989
990 arp_util.debug('do_add_policy_function (+) ');
991
992 --Get ar and apps schema name
993 l_return_value := fnd_installation.get_app_info(
994 'AR', l_status, l_industry, l_ar_schema);
995
996 IF NOT l_return_value THEN
997 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
998 END IF;
999
1000 l_return_value := fnd_installation.get_app_info(
1001 'FND', l_status, l_industry, l_aol_schema);
1002
1003 IF NOT l_return_value THEN
1004 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1005 END IF;
1006
1007 system.ad_apps_private.get_apps_schema_name(
1008 1, l_aol_schema, l_apps_schema, l_apps_mls_schema);
1009
1010 --Add policy functions
1011 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_ORGANIZATION_PROFILES', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1012 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_PERSON_PROFILES', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1013
1014 /* SSM SST Integration and Extension
1015 * Policy functions will not be added to non-profile entities as the concept of
1016 * select/de-select data sources for other entities is obsoleted.
1017
1018 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_RELATIONSHIPS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1019 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_LOCATIONS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1020 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_CONTACT_POINTS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1021 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_CREDIT_RATINGS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1022 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_FINANCIAL_REPORTS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1023 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_FINANCIAL_NUMBERS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1024 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_CODE_ASSIGNMENTS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1025 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_ORGANIZATION_INDICATORS', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1026 FND_ACCESS_CONTROL_UTIL.ADD_POLICY(l_ar_schema, 'HZ_PARTY_SITES', 'content_source_type_sec', l_apps_schema, 'hz_common_pub.content_source_type_security');
1027 */
1028 arp_util.debug('do_add_policy_function (-) ');
1029
1030 END do_add_policy_function;
1031
1032 /*===========================================================================+
1033 | PROCEDURE
1034 | do_create_request_log
1035 |
1036 | DESCRIPTION
1037 | Insert the a corresponding record into requst log.
1038 |
1039 | SCOPE - PRIVATE
1040 |
1041 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
1042 |
1043 | ARGUMENTS : IN:
1044 | p_interface_rec
1045 | p_request_log_id
1046 | OUT:
1047 | IN/ OUT:
1048 |
1049 | RETURNS : NONE
1050 |
1051 | NOTES
1052 |
1053 | MODIFICATION HISTORY
1054 |
1055 +===========================================================================*/
1056
1057 procedure do_create_request_log(
1058 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
1059 l_request_log_id OUT NOCOPY NUMBER
1060 ) IS PRAGMA AUTONOMOUS_TRANSACTION;
1061
1062 l_party_interface_id NUMBER;
1063
1064 BEGIN
1065 INSERT INTO hz_dnb_request_log(
1066 REQUEST_ID,
1067 PARTY_ID,
1068 REQUESTED_PRODUCT,
1069 DUNS_NUMBER,
1070 CREATED_BY,
1071 CREATION_DATE,
1072 LAST_UPDATED_BY,
1073 LAST_UPDATE_DATE )
1074 VALUES(
1075 HZ_DNB_REQUEST_LOG_S.nextval,
1076 p_interface_rec.PARTY_ID,
1077 p_interface_rec.GDP_NAME,
1078 p_interface_rec.DUNS_NUMBER,
1079 hz_utility_v2pub.CREATED_BY,
1080 hz_utility_v2pub.CREATION_DATE,
1081 hz_utility_v2pub.LAST_UPDATED_BY,
1082 hz_utility_v2pub.LAST_UPDATE_DATE )
1083 RETURNING REQUEST_ID INTO l_request_log_id;
1084
1085 UPDATE hz_party_interface
1086 SET REQUEST_LOG_ID = l_request_log_id
1087 WHERE party_interface_id = p_interface_rec.party_interface_id;
1088
1089 COMMIT;
1090
1091 END do_create_request_log;
1092
1093 /*===========================================================================+
1094 | PROCEDURE
1095 | do_update_request_log
1096 |
1097 | DESCRIPTION
1098 | update the a corresponding record in requst log.
1099 |
1100 | SCOPE - PRIVATE
1101 |
1102 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
1103 |
1104 | ARGUMENTS : IN:
1105 | p_interface_rec
1106 | p_request_log_id
1107 | OUT:
1108 | IN/ OUT:
1109 |
1110 | RETURNS : NONE
1111 |
1112 | NOTES
1113 |
1114 | MODIFICATION HISTORY
1115 |
1116 +===========================================================================*/
1117 procedure do_update_request_log(
1118 p_request_log_id IN NUMBER,
1119 p_party_id IN NUMBER,
1120 p_status IN VARCHAR2
1121 ) IS PRAGMA AUTONOMOUS_TRANSACTION;
1122
1123 l_request_id NUMBER;
1124
1125 BEGIN
1126
1127 UPDATE hz_dnb_request_log
1128 SET PARTY_ID = p_party_id,
1129 STATUS = p_status,
1130 LAST_UPDATED_BY = hz_utility_v2pub.LAST_UPDATED_BY,
1131 LAST_UPDATE_DATE = hz_utility_v2pub.LAST_UPDATE_DATE,
1132 LAST_UPDATE_LOGIN = hz_utility_v2pub.LAST_UPDATE_LOGIN
1133 WHERE REQUEST_ID = p_request_log_id;
1134
1135 COMMIT;
1136
1137 END do_update_request_log;
1138
1139 /*===========================================================================+
1140 | PROCEDURE
1141 | map
1142 |
1143 | DESCRIPTION
1144 | Map DNB info. stored in party interface table into
1145 | HZ tables.
1146 |
1147 | SCOPE - PUBLIC
1148 |
1149 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
1150 |
1151 | ARGUMENTS : IN:
1152 | p_api_version
1153 | p_init_msg_list
1154 | p_commit
1155 | p_group_id
1156 | p_validation_level
1157 | OUT:
1158 | x_return_status
1159 | x_msg_count
1160 | x_msg_data
1161 | IN/OUT:
1162 |
1163 | RETURNS : NONE
1164 |
1165 | NOTES
1166 | DUNS and ENQUIRY DUNS (see DNB Content HLD)
1167 | In countries outside of North America, DNB does not keep
1168 | information abt a Branch location. If the user requests for
1169 | a party which is a Branch it actually reurns back data for
1170 | its HQ. In such a case, DUNS has the HQ DUNS and the
1171 | ENQUIRY DUNS has the DUNS of the party (Branch that you
1172 | requested). In North America, DUNS and ENQUIRY DUNS have
1173 | the same values as DNB has Branch info. as well.
1174 |
1175 | So party interface stores:
1176 | o Origianl info. of the asking duns if DUNS = ENQUIRY DUNS
1177 | o HQ info. of the asking duns if DUNS <> ENQUIRY DUNS.
1178 | and ENQUIRY DUNS stores the asking duns.
1179 |
1180 | When DUNS = ENQUIRY DUNS, we need to use the current row in
1181 | party interface table to:
1182 | o If it is a new party, we create 'USER_ENTERED' and 'DNB'
1183 | organization profiles and party sites (through DNB
1184 | location). We also need to create other DNB related info.
1185 | like credit ratings, financial reports etc.
1186 | o If it is an existing party, update corresponding 'DNB'
1187 | info. for this party.
1188 |
1189 | When DUNS <> ENQUIRY DUNS, we need to use the current row in
1190 | party interface table to:
1191 | o Create/update HQ party. We create 'USER_ENTERED' and 'DNB'
1192 | organization profiles and party sites (through DNB location)
1193 | and other DNB stuff if HQ party do not exist. Otherwise, we
1194 | update HQ DNB info.
1195 | o Create/update BRANCH party. We create 'USER_ENTERED' and
1196 | 'DNB' organization profiles.
1197 | o Create/update party relationship between HQ and BRANCH.
1198 |
1199 | MODIFICATION HISTORY
1200 |
1201 | 19-AUG-2004 Rajib Ranjan Borah o Bug 3107162. Added call to
1202 | rectify_error_fields
1203 | o Status in HZ_PARTY_INTERFACE will
1204 | be set to W1 and not P1 if any column
1205 | value passed by DNB is invalid.
1206 | o IF G_ERROR_FLAG = 'Y', push message
1207 | HZ_DNB_INVALID_NULL to stack.
1208 | 14-OCT-2004 Sravanthi A o Bug 3107162: Added local variable to store
1209 | p_inactivate_flag and make it 'Y' if
1210 | passed value is NULL.
1211 +===========================================================================*/
1212
1213 procedure map(
1214 p_api_version IN NUMBER,
1215 p_init_msg_list IN VARCHAR2:= FND_API.G_FALSE,
1216 p_commit IN VARCHAR2:= FND_API.G_FALSE,
1217 p_group_id IN NUMBER := NULL,
1218 x_return_status OUT NOCOPY VARCHAR2,
1219 x_msg_count OUT NOCOPY NUMBER,
1220 x_msg_data OUT NOCOPY VARCHAR2,
1221 p_inactivate_flag IN VARCHAR2, --4227564 := 'Y',
1222 p_validation_level IN NUMBER:= FND_API.G_VALID_LEVEL_FULL
1223
1224 ) IS
1225 l_api_name CONSTANT VARCHAR2(30) := 'map';
1226 l_api_version CONSTANT NUMBER := 1.0;
1227
1228 CURSOR c1 IS
1229 SELECT * FROM
1230 HZ_PARTY_INTERFACE
1231 WHERE NVL(group_id, FND_API.G_MISS_NUM) = NVL(p_group_id, FND_API.G_MISS_NUM)
1232 AND status = 'N';
1233
1234 l_interface_rec HZ_PARTY_INTERFACE%ROWTYPE;
1235 l_organization_rec HZ_PARTY_V2PUB.organization_rec_type;
1236 l_party_rel_rec HZ_RELATIONSHIP_V2PUB.relationship_rec_type;
1237 l_location_rec HZ_LOCATION_V2PUB.location_rec_type;
1238
1239 l_displayed_duns_party_id NUMBER := NULL;
1240 l_party_id NUMBER := NULL;
1241 l_original_party_id NUMBER;
1242 l_final_party_id NUMBER;
1243 l_count NUMBER;
1244 l_duns_number VARCHAR2(30);
1245 num_of_rec NUMBER := 0;
1246
1247 l_organization_profile_id NUMBER;
1248
1249 l_policy_exist VARCHAR2(10);
1250 l_exist VARCHAR2(1);
1251 l_result BOOLEAN;
1252 l_relationship_exist BOOLEAN := FALSE;
1253 l_orig_system_reference VARCHAR2(240);
1254 -- l_update_third_party VARCHAR2(1);
1255 l_mixnmatch_global_id NUMBER;
1256 l_user_data_creation_rule_id varchar2(100);
1257
1258 --bug 3107162: local variable to store p_inactivate_flag
1259 l_inactivate_flag VARCHAR2(1) := p_inactivate_flag;
1260 l_any_rectification_in_batch BOOLEAN:= FALSE;
1261 BEGIN
1262 --Bug 3107162: When null is passed for p_inactivate_flag make it 'Y'
1263 --4227564 commented this code
1264 /*IF p_inactivate_flag IS NULL
1265 THEN
1266 l_inactivate_flag := 'Y';
1267 END IF;*/
1268 --end of bug 3107162
1269
1270 --Bug 1772241: Add policies if this is the
1271 --first time user uses DNB
1272
1273 l_policy_exist := FND_PROFILE.VALUE_WNPS('HZ_DNB_POLICY_EXIST');
1274 IF l_policy_exist IS NULL OR l_policy_exist <> 'Y' THEN
1275 do_add_policy_function;
1276
1277 l_result := FND_PROFILE.SAVE('HZ_DNB_POLICY_EXIST', 'Y', 'SITE');
1278 IF NOT l_result THEN
1279 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1280 END IF;
1281
1282 --Cache profile in current session
1283 l_policy_exist := FND_PROFILE.VALUE('HZ_DNB_POLICY_EXIST');
1284
1285 END IF;
1286
1287 hz_common_pub.disable_cont_source_security;
1288 -- l_update_third_party := NVL(FND_PROFILE.value('HZ_UPDATE_THIRD_PARTY_DATA'), 'N');
1289 -- set the profile to allow dnb data updatable
1290 -- FND_PROFILE.put('HZ_UPDATE_THIRD_PARTY_DATA', 'Y');
1291
1292 -- disable user data creation rule
1293 l_user_data_creation_rule_id := fnd_profile.value('HZ_USER_DATA_CREATION_RULE');
1294 if l_user_data_creation_rule_id is not null then
1295 fnd_profile.put('HZ_USER_DATA_CREATION_RULE',null);
1296 end if;
1297
1298 -- isMixNMatchEnabled := HZ_MIXNM_UTILITY.isMixNMatchEnabled('HZ_ORGANIZATION_PROFILES', l_mixnmatch_global_id);
1299 -- arp_util.debug('isMixNMatchEnabled=' || isMixNMatchEnabled);
1300
1301 arp_util.debug('HZ_MAP_PARTY_PUB.MAP (+) ');
1302
1303 --Standard call to check for call compatibility.
1304 IF NOT FND_API.Compatible_API_Call(
1305 l_api_version,
1306 p_api_version,
1307 l_api_name,
1308 G_PKG_NAME)
1309 THEN
1310 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1311 END IF;
1312
1313 --Initialize message list if p_init_msg_list is set to TRUE.
1314 IF FND_API.to_Boolean(p_init_msg_list) THEN
1315 FND_MSG_PUB.initialize;
1316 END IF;
1317
1318 --Initialize API return status to success.
1319 x_return_status := FND_API.G_RET_STS_SUCCESS;
1320
1321 --
1322 --Process records one by one.
1323 --
1324
1325 OPEN c1;
1326 LOOP
1327 BEGIN
1328 FETCH c1 INTO l_interface_rec;
1329 EXIT WHEN c1%NOTFOUND;
1330
1331
1332 num_of_rec := num_of_rec + 1;
1333 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: fetched record from cursor: num_of_rec = '|| to_char(num_of_rec));
1334 -- Bug 3220024 : Donot reset session related variables inside the cursor
1335
1336 l_displayed_duns_party_id := NULL;
1337 l_party_id := NULL;
1338 l_original_party_id := NULL;
1339 l_final_party_id := NULL;
1340 l_duns_number := NULL;
1341 l_organization_profile_id := NULL;
1342 -- l_policy_exist := NULL;
1343 l_exist := NULL;
1344 -- l_result := NULL;
1345 l_relationship_exist := FALSE;
1346 --l_orig_system_reference := NULL;
1347 -- l_update_third_party := NULL;
1348 -- l_mixnmatch_global_id := NULL;
1349 -- l_user_data_creation_rule_id := NULL;
1350
1351 --Set SAVEPOINT.
1352 SAVEPOINT map_pub;
1353
1354 --MOSR Changes
1355 --If p_inactivate_flag is 'Y' then in activate Source System mapping
1356 -- for HZ_PARTIES, HZ_PARTY_SITES and HZ_CONTACT_POINTS
1357 --bug 3107162: Passed local variable l_inactivate flag instead of p_inactivate_flag
1358 --bug 4287144: pass enquiry duns
1359 check_mosr_mapping (
1360 lpad(to_char(nvl(l_interface_rec.enquiry_duns,l_interface_rec.duns_number)),9,'0'),
1361 l_interface_rec.party_id,
1362 --p_inactivate_flag,
1363 l_inactivate_flag,
1364 x_return_status,
1365 x_msg_count,
1366 x_msg_data
1367 );
1368
1369 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1370 RAISE FND_API.G_EXC_ERROR;
1371 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1372 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1373 END IF;
1374 --
1375 --Create a row in hz_dnb_request_log if request_log_id is NULL
1376 --
1377
1378 IF l_interface_rec.request_log_id IS NULL THEN
1379
1380 do_create_request_log(l_interface_rec,
1381 l_interface_rec.request_log_id );
1382 END IF;
1383
1384 -- Bug 3107162
1385 rectify_error_fields(l_interface_rec);
1386
1387 --Bug 2802598: verify whether the lookups sent by DNB are correct. Call create_dynamic_lookups
1388 create_dynamic_lookups(
1389 p_party_interface_rec => l_interface_rec,
1390 x_return_status => x_return_status
1391 );
1392
1393 --store original party id. The party id will be used to update
1394 --hz_dnb_request_log
1395 --store original and final party id.
1396 l_original_party_id := l_interface_rec.party_id;
1397 l_final_party_id := l_original_party_id;
1398
1399 --Decide if the data in party interface is for HQ or is real data we want.
1400 --
1401 IF l_interface_rec.DUNS_NUMBER = l_interface_rec.ENQUIRY_DUNS
1402 OR l_interface_rec.ENQUIRY_DUNS IS NULL
1403 THEN
1404
1405 --DNB has provided original party's data
1406 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: DUNS = ENQUIRY_DUNS');
1407
1408 --Create DNB data
1409 --Create USER_ENTERED data if the party doesn't exist
1410
1411 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: create DNB data, create USER_ENTERED data if party not exist');
1412 do_map(
1413 l_interface_rec,
1414 x_return_status
1415 );
1416 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1417 RAISE FND_API.G_EXC_ERROR;
1418 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1419 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1420 END IF;
1421
1422 IF l_final_party_id IS NULL THEN
1423 l_final_party_id := l_interface_rec.party_id;
1424
1425 update hz_party_interface set party_id = l_final_party_id
1426 where party_interface_id = l_interface_rec.party_interface_id;
1427 END IF;
1428
1429 ELSE
1430
1431 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: DUNS <> ENQUIRY_DUNS');
1432 --Party requested is a Branch location. DNB has provided HQ's data.
1433
1434 --Since this is a HQ, store it as HQ.
1435 l_interface_rec.HQ_BRANCH_IND := 'HQ';
1436
1437 --Check if party with DUNS as HQ's DUNS exists.
1438 --Need to check the DUNS in the latest record because
1439 --DUNS might have changed over time.
1440
1441 BEGIN
1442 SELECT 'Y' INTO l_exist
1443 FROM hz_organization_profiles
1444 -- Bug 4956756 : use DUNS_NUMBER_C
1445 WHERE DUNS_NUMBER_C = lpad(to_char(l_interface_rec.DUNS_NUMBER), 9, '0')
1446 AND actual_content_source = l_interface_rec.content_source_type
1447 AND (SYSDATE BETWEEN effective_start_date
1448 AND NVL(effective_end_date, to_date('12/31/4712','MM/DD/YYYY')))
1449 AND ROWNUM=1;
1450
1451 EXCEPTION
1452
1453 WHEN NO_DATA_FOUND THEN
1454 l_exist := 'N';
1455 END;
1456
1457 IF l_exist = 'N' THEN
1458 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: DUNS <> ENQUIRY_DUNS: no party exists for HQs DUNS');
1459
1460 --no party exists with DUNS as HQ's DUNS.
1461 --create new party for HQ DUNS. And organization profiles with
1462 -- USER_ENTERED
1463 -- DNB
1464
1465 l_interface_rec.party_id := null;
1466 l_organization_rec.party_rec.orig_system_reference := l_interface_rec.orig_system_reference;
1467 --l_interface_rec.orig_system_reference := NULL;
1468
1469 --Create new party and do mapping.
1470 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: create DNB and USER_ENTERED data for HQ (+)');
1471 do_map(
1472 l_interface_rec,
1473 x_return_status
1474 );
1475
1476 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1477 RAISE FND_API.G_EXC_ERROR;
1478 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1479 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1480 END IF;
1481
1482 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: create DNB and USER_ENTERED data for HQ (-)');
1483
1484 l_displayed_duns_party_id := l_interface_rec.party_id;
1485 ELSE
1486 --party exists with DUNS as HQ's DUNS.
1487
1488 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: DUNS <> ENQUIRY_DUNS: party exists for HQs DUNS (+)');
1489
1490 IF l_original_party_id IS NOT NULL THEN /*Branch party exists. */
1491
1492 --Branch party exists.
1493 BEGIN
1494
1495 SELECT displayed_duns_party_id
1496 INTO l_displayed_duns_party_id
1497 FROM hz_organization_profiles
1498 WHERE party_id = l_original_party_id
1499 AND actual_content_source = l_interface_rec.content_source_type
1500 AND (SYSDATE BETWEEN effective_start_date
1501 AND NVL(effective_end_date, to_date('12/31/4712','MM/DD/YYYY')));
1502
1503 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: party exists for HQs DUNS: org profile for Branch exists');
1504
1505 --DNB org profile for Branch exists. Check if HQ DUNS = DUNS of
1506 --Branch's displayed_duns_party_id.
1507
1508 IF l_displayed_duns_party_id IS NOT NULL THEN
1509
1510 SELECT duns_number_c INTO l_duns_number
1511 FROM hz_organization_profiles
1512 WHERE party_id = l_displayed_duns_party_id
1513 AND actual_content_source = l_interface_rec.content_source_type
1514 AND (SYSDATE BETWEEN effective_start_date
1515 AND NVL(effective_end_date, to_date('12/31/4712','MM/DD/YYYY')));
1516
1517 IF lpad(to_char(l_interface_rec.DUNS_NUMBER),9,'0') = l_duns_number THEN
1518 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: branchs DISPLAYED_DUNS_NUMBER = HQs DUNS_NUMBER');
1519 l_relationship_exist := TRUE;
1520 ELSE
1521 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: branchs DISPLAYED_DUNS_NUMBER <> HQs DUNS_NUMBER ');
1522 l_displayed_duns_party_id := NULL;
1523
1524 --don't need to check in party rel for HQ because it
1525 --should give the same record as l_displayed_duns_party_id.
1526 END IF;
1527
1528 END IF;
1529
1530 EXCEPTION
1531
1532 WHEN NO_DATA_FOUND THEN
1533 --org profile does not exist. i.e.
1534 --DNB data does not exist, so partyrel also will not exist.
1535
1536 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: party exists for HQs DUNS: org profile for Branch does not exist');
1537
1538 l_displayed_duns_party_id := NULL;
1539 END;
1540
1541 END IF; /*Branch party exists. */
1542
1543 IF l_displayed_duns_party_id IS NULL THEN
1544
1545 --
1546 --We had confirmed earlier that party exists with DUNS as HQ's DUNS.
1547 --get party_id having DUNS as HQ DUNS having max(last_update_date)
1548 --as there may be multiple such parties.
1549
1550 SELECT party_id
1551 INTO l_displayed_duns_party_id
1552 FROM hz_organization_profiles
1553 -- Bug 4956756 : use DUNS_NUMBER_C
1554 WHERE DUNS_NUMBER_C = lpad(to_char(l_interface_rec.DUNS_NUMBER), 9, '0')
1555 AND actual_content_source = l_interface_rec.content_source_type
1556 AND ( SYSDATE BETWEEN effective_start_date
1557 AND NVL(effective_end_date, to_date('12/31/4712','MM/DD/YYYY')))
1558 AND last_update_date = (
1559 SELECT max(last_update_date)
1560 FROM hz_organization_profiles
1561 -- Bug 4956756 : use DUNS_NUMBER_C
1562 WHERE DUNS_NUMBER_C = lpad(to_char(l_interface_rec.DUNS_NUMBER), 9, '0')
1563 AND actual_content_source = l_interface_rec.content_source_type
1564 AND (SYSDATE BETWEEN effective_start_date
1565 AND NVL(effective_end_date, to_date('12/31/4712','MM/DD/YYYY'))))
1566 AND ROWNUM = 1;
1567
1568 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: new l_displayed_duns_party_id=' || l_displayed_duns_party_id);
1569 END IF;
1570
1571 --bug 4287144: call check mosr_mapping for duns_number when duns<>enquiry_duns
1572
1573 check_mosr_mapping (
1574 lpad(to_char(l_interface_rec.duns_number),9,'0'),
1575 l_displayed_duns_party_id,
1576 --p_inactivate_flag,
1577 l_inactivate_flag,
1578 x_return_status,
1579 x_msg_count,
1580 x_msg_data
1581 );
1582
1583 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1584 RAISE FND_API.G_EXC_ERROR;
1585 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1586 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1587 END IF;
1588
1589 --Update HQ's DNB info.
1590 l_interface_rec.party_id := l_displayed_duns_party_id;
1591 l_orig_system_reference := l_interface_rec.orig_system_reference;
1592 --l_interface_rec.orig_system_reference := NULL;
1593
1594 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: update DNB for HQs');
1595
1596 do_map(
1597 l_interface_rec,
1598 x_return_status
1599 );
1600
1601 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1602 RAISE FND_API.G_EXC_ERROR;
1603 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1604 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1605 END IF;
1606
1607 l_interface_rec.orig_system_reference := l_orig_system_reference;
1608
1609 END IF; /*party exists with DUNS as HQ's DUNS. */
1610
1611 --create/ update party/ org profile for the branch party.
1612 --We need to create org profile as actual_content_source =
1613 -- USER_ENTERED
1614 -- DNB
1615
1616 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: DUNS <> ENQUIRY_DUNS: create/ update party/org profile for the original party');
1617
1618 l_organization_rec.party_rec.party_id := l_original_party_id;
1619 --bug 4287144: pass padded duns_number to make it 9 in length
1620 --l_organization_rec.DUNS_NUMBER_C := l_interface_rec.ENQUIRY_DUNS;
1621 l_organization_rec.DUNS_NUMBER_C := lpad(to_char(l_interface_rec.ENQUIRY_DUNS),9,'0');
1622 l_organization_rec.DISPLAYED_DUNS_PARTY_ID := l_displayed_duns_party_id;
1623 l_organization_rec.organization_name := l_interface_rec.party_name;
1624 l_organization_rec.party_rec.orig_system_reference := l_interface_rec.orig_system_reference;
1625 l_organization_rec.actual_content_source := l_interface_rec.content_source_type;
1626 l_organization_rec.created_by_module := 'TCA_DNB_MAPPING';
1627 l_organization_rec.party_rec.party_number := null;
1628
1629 store_org(
1630 l_organization_rec,
1631 l_organization_profile_id,
1632 x_return_status
1633 );
1634
1635 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1636 RAISE FND_API.G_EXC_ERROR;
1637 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1638 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1639 END IF;
1640
1641 l_final_party_id := l_organization_rec.party_rec.party_id;
1642
1643 --bug 4287144
1644 IF l_original_party_id is not null THEN
1645 check_new_duns(l_organization_rec,x_return_status);
1646 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1647 return;
1648 END IF;
1649 END IF;
1650
1651 IF NOT l_relationship_exist THEN
1652
1653 --create party rel b/w the new party (HQ) and original party.
1654 --Require this because through GDPs, we may not get back Family Tree.
1655
1656 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: DUNS <> ENQUIRY_DUNS: create party rel b/w the new party (HQ) and original party');
1657
1658 l_party_rel_rec.subject_id := l_displayed_duns_party_id;
1659 l_party_rel_rec.object_id := l_final_party_id;
1660 l_party_rel_rec.relationship_type := 'HEADQUARTERS/DIVISION';
1661 l_party_rel_rec.relationship_code := 'HEADQUARTERS_OF';
1662 l_party_rel_rec.actual_content_source := l_interface_rec.content_source_type;
1663 l_party_rel_rec.subject_type := 'ORGANIZATION';
1664 l_party_rel_rec.object_type := 'ORGANIZATION';
1665 l_party_rel_rec.subject_table_name := 'HZ_PARTIES';
1666 l_party_rel_rec.object_table_name := 'HZ_PARTIES';
1667 l_party_rel_rec.created_by_module := 'TCA_DNB_MAPPING';
1668
1669 store_party_rel(
1670 l_party_rel_rec,
1671 x_return_status
1672 );
1673
1674 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1675 RAISE FND_API.G_EXC_ERROR;
1676 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1677 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
1678 END IF;
1679
1680 END IF;
1681
1682 END IF;
1683
1684 -- Bug 5554518
1685 IF l_interface_rec.ENQUIRY_DUNS IS NOT NULL
1686 AND l_interface_rec.DUNS_NUMBER <> l_interface_rec.ENQUIRY_DUNS
1687 THEN
1688 l_final_party_id := l_displayed_duns_party_id;
1689 END IF;
1690
1691
1692 --
1693 --Check return status.
1694 --
1695
1696 IF x_return_status = 'S' THEN
1697 IF G_ERROR_FLAG = 'N' THEN -- Bug 3107162
1698 UPDATE hz_party_interface
1699 SET status = 'P1',
1700 party_id = l_final_party_id -- Bug 5440525
1701 WHERE party_interface_id = l_interface_rec.party_interface_id;
1702 ELSE
1703 UPDATE hz_party_interface
1704 SET status = 'W1',
1705 party_id = l_final_party_id -- Bug 5440525
1706 WHERE party_interface_id = l_interface_rec.party_interface_id;
1707 l_any_rectification_in_batch := TRUE;
1708 END IF;
1709
1710 do_update_request_log(
1711 l_interface_rec.request_log_id,
1712 l_interface_rec.party_id,
1713 'S1' );
1714 IF FND_API.to_Boolean(p_commit) THEN
1715 commit;
1716 END IF;
1717
1718 ELSE
1719 ROLLBACK to map_pub;
1720 -- need to rollback the successful transactions for this record prior to failure.
1721
1722 do_update_request_log(
1723 l_interface_rec.request_log_id,
1724 l_original_party_id,
1725 'E1' );
1726
1727 store_error(
1728 p_status => 'E1',
1729 p_party_interface_id => l_interface_rec.party_interface_id);
1730
1731 END IF;
1732
1733 EXCEPTION
1734 WHEN FND_API.G_EXC_ERROR THEN
1735
1736 ROLLBACK TO map_pub;
1737 x_return_status := FND_API.G_RET_STS_ERROR;
1738
1739 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: FND_API.G_EXC_ERROR');
1740
1741 do_update_request_log(
1742 l_interface_rec.request_log_id,
1743 l_original_party_id,
1744 'E1' );
1745
1746 store_error(
1747 p_status => 'E1',
1748 p_party_interface_id => l_interface_rec.party_interface_id);
1749
1750 FND_MSG_PUB.Count_And_Get(
1751 p_encoded => FND_API.G_FALSE,
1752 p_count => x_msg_count,
1753 p_data => x_msg_data);
1754
1755 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1756
1757 ROLLBACK TO map_pub;
1758 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1759
1760 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: G_EXC_UNEXPECTED_ERROR');
1761
1762 do_update_request_log(
1763 l_interface_rec.request_log_id,
1764 l_original_party_id,
1765 'E1' );
1766
1767 store_error(
1768 p_status => 'E1',
1769 p_party_interface_id => l_interface_rec.party_interface_id);
1770
1771 FND_MSG_PUB.Count_And_Get(
1772 p_encoded => FND_API.G_FALSE,
1773 p_count => x_msg_count,
1774 p_data => x_msg_data);
1775
1776 WHEN OTHERS THEN
1777
1778 ROLLBACK TO map_pub;
1779 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1780
1781 arp_util.debug('HZ_MAP_PARTY_PUB.MAP: OTHERS EXCEPTION');
1782
1783 FND_MESSAGE.SET_NAME('AR', 'HZ_API_OTHERS_EXCEP');
1784 FND_MESSAGE.SET_TOKEN('ERROR' ,SQLERRM);
1785 FND_MSG_PUB.ADD;
1786
1787 do_update_request_log(
1788 l_interface_rec.request_log_id,
1789 l_original_party_id,
1790 'E1' );
1791
1792 store_error(
1793 p_status => 'E1',
1794 p_party_interface_id => l_interface_rec.party_interface_id);
1795
1796 FND_MSG_PUB.Count_And_Get(
1797 p_encoded => FND_API.G_FALSE,
1798 p_count => x_msg_count,
1799 p_data => x_msg_data);
1800
1801 END;
1802
1803 END LOOP;
1804 CLOSE c1;
1805
1806
1807
1808 --
1809 -- Store Related DUNS.
1810 --
1811
1812 store_related_duns( p_commit,
1813 p_group_id,
1814 x_return_status);
1815
1816
1817 -- Bug 3107162
1818
1819 IF l_any_rectification_in_batch THEN
1820 FND_MESSAGE.SET_NAME('AR','HZ_DNB_INVALID_NULL');
1821 FND_MSG_PUB.ADD;
1822 END IF;
1823
1824 --Standard call to get message count and if count is 1, get message info.
1825 FND_MSG_PUB.Count_And_Get(
1826 p_encoded => FND_API.G_FALSE,
1827 p_count => x_msg_count,
1828 p_data => x_msg_data);
1829 arp_util.debug('HZ_MAP_PARTY_PUB.MAP (-)');
1830
1831 hz_common_pub.enable_cont_source_security;
1832 --FND_PROFILE.put('HZ_UPDATE_THIRD_PARTY_DATA', l_update_third_party);
1833
1834 if l_user_data_creation_rule_id is not null then
1835 fnd_profile.put('HZ_USER_DATA_CREATION_RULE',l_user_data_creation_rule_id);
1836 end if;
1837
1838
1839 END map;
1840
1841
1842 procedure check_mosr_mapping (
1843 p_duns_number_c IN VARCHAR2,
1844 p_party_id IN VARCHAR2,
1845 p_inactivate_flag IN VARCHAR2,
1846 x_return_status IN OUT NOCOPY VARCHAR2,
1847 x_msg_count OUT NOCOPY NUMBER,
1848 x_msg_data OUT NOCOPY VARCHAR2
1849 ) IS
1850 l_orig_sys_reference_rec HZ_ORIG_SYSTEM_REF_PUB.orig_sys_reference_rec_type;
1851 l_orig_system_ref_id NUMBER;
1852 l_object_version_number NUMBER;
1853 l_start_date_active date;
1854 l_orig_system HZ_ORIG_SYS_REFERENCES.orig_system%type;
1855 l_orig_system_reference HZ_ORIG_SYS_REFERENCES.orig_system_reference%type;
1856 l_owner_table_name HZ_ORIG_SYS_REFERENCES.owner_table_name%type;
1857 l_status varchar2(1);
1858
1859 --MOSR Changes
1860 --4227564: Modified the cursors to check for records of other parties having same
1861 --orig_system_reference.
1862 CURSOR c_check_party_mapping
1863 IS
1864 SELECT hosr.orig_system_ref_id,
1865 hosr.object_version_number,
1866 hosr.start_date_active,
1867 hosr.orig_system,
1868 hosr.orig_system_reference,
1869 hosr.owner_table_name
1870 FROM -- hz_organization_profiles org_pro,
1871 hz_orig_sys_references hosr
1872 WHERE -- nvl(org_pro.party_id, '-999') = hosr.owner_table_id AND
1873 hosr.orig_system = 'DNB'
1874 AND hosr.owner_table_name = 'HZ_PARTIES'
1875 AND trunc(nvl(hosr.end_date_active, sysdate)) >= trunc(sysdate)
1876 AND hosr.status='A'
1877 AND hosr.orig_system_reference = p_duns_number_c
1878 AND hosr.party_id <> nvl(p_party_id,-1);
1879 --4227564
1880
1881 CURSOR c_check_party_site_mapping
1882 IS
1883 SELECT hosr.orig_system_ref_id,
1884 hosr.object_version_number,
1885 hosr.start_date_active,
1886 hosr.orig_system,
1887 hosr.orig_system_reference,
1888 hosr.owner_table_name
1889 FROM --hz_party_sites ps,
1890 hz_orig_sys_references hosr
1891 WHERE --nvl(ps.party_site_id, '-999') = hosr.owner_table_id
1892 --AND ps.status = 'A' AND
1893 hosr.orig_system = 'DNB'
1894 AND hosr.owner_table_name = 'HZ_PARTY_SITES'
1895 AND trunc(nvl(hosr.end_date_active, sysdate)) >= trunc(sysdate)
1896 AND hosr.status='A'
1897 AND hosr.orig_system_reference like p_duns_number_c || '%'
1898 AND hosr.party_id <> nvl(p_party_id,-1);
1899 --4227564
1900
1901 CURSOR c_check_contact_point_mapping
1902 IS
1903 SELECT hosr.orig_system_ref_id,
1904 hosr.object_version_number,
1905 hosr.start_date_active,
1906 hosr.orig_system,
1907 hosr.orig_system_reference,
1908 hosr.owner_table_name
1909 FROM -- hz_contact_points cp,
1910 hz_orig_sys_references hosr
1911 WHERE --nvl(cp.contact_point_id, '-999') = hosr.owner_table_id
1912 -- AND cp.status = 'A' AND
1913 hosr.orig_system = 'DNB'
1914 AND hosr.owner_table_name = 'HZ_CONTACT_POINTS'
1915 AND trunc(nvl(hosr.end_date_active, sysdate)) >= trunc(sysdate)
1916 AND hosr.status='A'
1917 AND hosr.orig_system_reference like p_duns_number_c || '%'
1918 AND hosr.party_id <> nvl(p_party_id,-1);
1919 --4227564
1920 BEGIN
1921 --Inactivate HZ_PARTIES records
1922 BEGIN
1923 OPEN c_check_party_mapping;
1924
1925 FETCH c_check_party_mapping INTO l_orig_system_ref_id, l_object_version_number, l_start_date_active,
1926 l_orig_system, l_orig_system_reference, l_owner_table_name;
1927 IF c_check_party_mapping%FOUND THEN
1928 --4227564
1929 -- IF p_inactivate_flag = 'Y' THEN
1930 l_orig_sys_reference_rec.ORIG_SYSTEM_REF_ID := l_orig_system_ref_id;
1931 l_orig_sys_reference_rec.orig_system := l_orig_system;
1932 l_orig_sys_reference_rec.orig_system_reference := l_orig_system_reference;
1933 l_orig_sys_reference_rec.owner_table_name := l_owner_table_name;
1934 l_orig_sys_reference_rec.start_date_active := l_start_date_active;
1935 l_orig_sys_reference_rec.END_DATE_ACTIVE := sysdate;
1936 l_orig_sys_reference_rec.status := 'I';
1937
1938 HZ_ORIG_SYSTEM_REF_PUB.update_orig_system_reference(
1939 p_init_msg_list => 'T',
1940 p_orig_sys_reference_rec => l_orig_sys_reference_rec,
1941 p_object_version_number => l_object_version_number,
1942 x_return_status => x_return_status,
1943 x_msg_count => x_msg_count,
1944 x_msg_data => x_msg_data
1945 );
1946
1947 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1948 RETURN;
1949 END IF;
1950 -- END IF;
1951 END IF;
1952 CLOSE c_check_party_mapping;
1953 EXCEPTION
1954 WHEN FND_API.G_EXC_ERROR THEN
1955 x_return_status := FND_API.G_RET_STS_ERROR;
1956 RETURN;
1957 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1958 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1959 RETURN;
1960 END;
1961
1962
1963 --Inactivate HZ_PARTY_SITES records
1964 BEGIN
1965
1966 OPEN c_check_party_site_mapping;
1967 LOOP
1968 FETCH c_check_party_site_mapping INTO l_orig_system_ref_id, l_object_version_number, l_start_date_active,
1969 l_orig_system, l_orig_system_reference, l_owner_table_name;
1970
1971 EXIT WHEN c_check_party_site_mapping%NOTFOUND;
1972 --4227564
1973 -- IF p_inactivate_flag = 'Y' THEN
1974 l_orig_sys_reference_rec.ORIG_SYSTEM_REF_ID := l_orig_system_ref_id;
1975 l_orig_sys_reference_rec.orig_system := l_orig_system;
1976 l_orig_sys_reference_rec.orig_system_reference := l_orig_system_reference;
1977 l_orig_sys_reference_rec.owner_table_name := l_owner_table_name;
1978 l_orig_sys_reference_rec.start_date_active := l_start_date_active;
1979 l_orig_sys_reference_rec.END_DATE_ACTIVE := sysdate;
1980 l_orig_sys_reference_rec.status := 'I';
1981
1982 HZ_ORIG_SYSTEM_REF_PUB.update_orig_system_reference(
1983 p_init_msg_list => 'T',
1984 p_orig_sys_reference_rec => l_orig_sys_reference_rec,
1985 p_object_version_number => l_object_version_number,
1986 x_return_status => x_return_status,
1987 x_msg_count => x_msg_count,
1988 x_msg_data => x_msg_data
1989 );
1990
1991 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1992 RETURN;
1993 END IF;
1994
1995 -- END IF;
1996 END LOOP;
1997 CLOSE c_check_party_site_mapping;
1998 EXCEPTION
1999 WHEN FND_API.G_EXC_ERROR THEN
2000 x_return_status := FND_API.G_RET_STS_ERROR;
2001 RETURN;
2002 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2003 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2004 RETURN;
2005 END;
2006
2007 --Inactivate HZ_CONTACT_POINTS records
2008 BEGIN
2009 OPEN c_check_contact_point_mapping;
2010 LOOP
2011 FETCH c_check_contact_point_mapping INTO l_orig_system_ref_id, l_object_version_number, l_start_date_active,
2012 l_orig_system, l_orig_system_reference, l_owner_table_name;
2013
2014 EXIT WHEN c_check_contact_point_mapping%NOTFOUND;
2015 --4227564
2016 -- IF p_inactivate_flag = 'Y' THEN
2017 l_orig_sys_reference_rec.ORIG_SYSTEM_REF_ID := l_orig_system_ref_id;
2018 l_orig_sys_reference_rec.orig_system := l_orig_system;
2019 l_orig_sys_reference_rec.orig_system_reference := l_orig_system_reference;
2020 l_orig_sys_reference_rec.owner_table_name := l_owner_table_name;
2021 l_orig_sys_reference_rec.start_date_active := l_start_date_active;
2022 l_orig_sys_reference_rec.END_DATE_ACTIVE := sysdate;
2023 l_orig_sys_reference_rec.status := 'I';
2024
2025 HZ_ORIG_SYSTEM_REF_PUB.update_orig_system_reference(
2026 p_init_msg_list => 'T',
2027 p_orig_sys_reference_rec => l_orig_sys_reference_rec,
2028 p_object_version_number => l_object_version_number,
2029 x_return_status => x_return_status,
2030 x_msg_count => x_msg_count,
2031 x_msg_data => x_msg_data
2032 );
2033
2034 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2035 RETURN;
2036 END IF;
2037 -- END IF;
2038 END LOOP;
2039 CLOSE c_check_contact_point_mapping;
2040 EXCEPTION
2041 WHEN FND_API.G_EXC_ERROR THEN
2042 x_return_status := FND_API.G_RET_STS_ERROR;
2043 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2044 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2045 END;
2046
2047 EXCEPTION
2048 WHEN FND_API.G_EXC_ERROR THEN
2049 x_return_status := FND_API.G_RET_STS_ERROR;
2050 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2051 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2052 END check_mosr_mapping;
2053
2054 -- Bug 3223595 : Added new procedure check_new_duns
2055
2056 PROCEDURE check_new_duns(
2057 p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE,
2058 x_return_status OUT NOCOPY VARCHAR2
2059 ) IS
2060
2061 l_orig_sys_reference_rec HZ_ORIG_SYSTEM_REF_PUB.orig_sys_reference_rec_type;
2062 l_orig_system_ref_id NUMBER;
2063 l_object_version_number NUMBER;
2064 l_start_date_active date;
2065 l_orig_system HZ_ORIG_SYS_REFERENCES.orig_system%type;
2066 l_orig_system_reference HZ_ORIG_SYS_REFERENCES.orig_system_reference%type;
2067 l_orig_system_reference_p HZ_ORIG_SYS_REFERENCES.orig_system_reference%type;
2068 l_owner_table_name HZ_ORIG_SYS_REFERENCES.owner_table_name%type;
2069 l_owner_table_id HZ_ORIG_SYS_REFERENCES.owner_table_id%type;
2070 l_msg_count NUMBER;
2071 l_msg_data VARCHAR2(2000);
2072 p_duns_number_c VARCHAR2(10);
2073 --MOSR Changes
2074 CURSOR c_check_party_mapping
2075 IS
2076 SELECT hosr.orig_system_ref_id,
2077 hosr.object_version_number,
2078 hosr.start_date_active,
2079 hosr.orig_system,
2080 hosr.orig_system_reference,
2081 hosr.owner_table_name,
2082 hosr.owner_table_id
2083 FROM
2084 --hz_organization_profiles org_pro,
2085 hz_orig_sys_references hosr
2086 WHERE
2087 --nvl(org_pro.party_id, '-999') = hosr.owner_table_id AND
2088 hosr.orig_system = 'DNB'
2089 AND hosr.owner_table_name = 'HZ_PARTIES'
2090 -- AND trunc(nvl(hosr.end_date_active, sysdate)) >= trunc(sysdate)
2091 AND hosr.status='A'
2092 AND hosr.orig_system_reference <> p_duns_number_c
2093 AND hosr.owner_table_id = p_organization_rec.party_rec.party_id;
2094
2095 CURSOR c_check_party_site_mapping
2096 IS
2097 SELECT hosr.orig_system_ref_id,
2098 hosr.object_version_number,
2099 hosr.start_date_active,
2100 hosr.orig_system,
2101 hosr.orig_system_reference,
2102 hosr.owner_table_name,
2103 hosr.owner_table_id
2104 FROM
2105 --hz_party_sites ps,
2106 hz_orig_sys_references hosr
2107 WHERE
2108 --nvl(ps.party_site_id, '-999') = hosr.owner_table_id AND
2109 hosr.orig_system = 'DNB'
2110 AND hosr.owner_table_name = 'HZ_PARTY_SITES'
2111 -- AND trunc(nvl(hosr.end_date_active, sysdate)) >= trunc(sysdate)
2112 AND hosr.status='A'
2113 AND hosr.party_id = p_organization_rec.party_rec.party_id
2114 AND hosr.orig_system_reference not like p_duns_number_c || '%';
2115
2116 CURSOR c_check_contact_point_mapping
2117 IS
2118 SELECT hosr.orig_system_ref_id,
2119 hosr.object_version_number,
2120 hosr.start_date_active,
2121 hosr.orig_system,
2122 hosr.orig_system_reference,
2123 hosr.owner_table_name,
2124 hosr.owner_table_id
2125 FROM
2126 --hz_contact_points cp,
2127 hz_orig_sys_references hosr
2128 WHERE
2129 --nvl(cp.contact_point_id, '-999') = hosr.owner_table_id AND
2130 hosr.orig_system = 'DNB'
2131 AND hosr.owner_table_name = 'HZ_CONTACT_POINTS'
2132 -- AND trunc(nvl(hosr.end_date_active, sysdate)) >= trunc(sysdate)
2133 AND hosr.status='A'
2134 AND hosr.party_id = p_organization_rec.party_rec.party_id
2135 AND hosr.orig_system_reference not like p_duns_number_c || '%';
2136
2137 BEGIN
2138 --bug 4287144
2139 x_return_status := FND_API.G_RET_STS_SUCCESS;
2140
2141 --Inactivate HZ_PARTIES records
2142 BEGIN
2143 p_duns_number_c := p_organization_rec.duns_number_c;
2144
2145 OPEN c_check_party_mapping;
2146
2147 FETCH c_check_party_mapping INTO l_orig_system_ref_id, l_object_version_number, l_start_date_active,
2148 l_orig_system, l_orig_system_reference_p, l_owner_table_name,l_owner_table_id;
2149 IF c_check_party_mapping%FOUND THEN
2150
2151 l_orig_sys_reference_rec.orig_system := l_orig_system;
2152 l_orig_sys_reference_rec.ORIG_SYSTEM_REF_ID := null;
2153 l_orig_sys_reference_rec.orig_system_reference := p_duns_number_c;
2154 l_orig_sys_reference_rec.owner_table_name := l_owner_table_name;
2155 l_orig_sys_reference_rec.owner_table_id := l_owner_table_id;
2156 l_orig_sys_reference_rec.start_date_active := sysdate;
2157 l_orig_sys_reference_rec.END_DATE_ACTIVE := NULL;
2158 l_orig_sys_reference_rec.party_id := p_organization_rec.party_rec.party_id;
2159 l_orig_sys_reference_rec.status := 'A';
2160 l_orig_sys_reference_rec.created_by_module := 'TCA_DNB_MAPPING';
2161 l_orig_sys_reference_rec.old_orig_system_reference := l_orig_system_reference_p;
2162
2163 hz_orig_system_ref_pub.create_orig_system_reference(
2164 FND_API.G_FALSE,
2165 l_orig_sys_reference_rec,
2166 x_return_status,
2167 l_msg_count,
2168 l_msg_data);
2169
2170 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2171 RETURN;
2172 END IF;
2173
2174 --Inactivate HZ_PARTY_SITES records
2175 BEGIN
2176 OPEN c_check_party_site_mapping;
2177 LOOP
2178 FETCH c_check_party_site_mapping INTO l_orig_system_ref_id, l_object_version_number, l_start_date_active,
2179 l_orig_system, l_orig_system_reference, l_owner_table_name, l_owner_table_id;
2180
2181 EXIT WHEN c_check_party_site_mapping%NOTFOUND;
2182
2183 l_orig_sys_reference_rec.orig_system := l_orig_system;
2184 l_orig_sys_reference_rec.ORIG_SYSTEM_REF_ID := null;
2185 l_orig_sys_reference_rec.orig_system_reference := p_duns_number_c||substr(l_orig_system_reference, length(l_orig_system_reference_p)+1);
2186 l_orig_sys_reference_rec.owner_table_name := l_owner_table_name;
2187 l_orig_sys_reference_rec.owner_table_id := l_owner_table_id;
2188 l_orig_sys_reference_rec.start_date_active := sysdate;
2189 l_orig_sys_reference_rec.END_DATE_ACTIVE := NULL;
2190 l_orig_sys_reference_rec.party_id := p_organization_rec.party_rec.party_id;
2191 l_orig_sys_reference_rec.status := 'A';
2192 l_orig_sys_reference_rec.created_by_module := 'TCA_DNB_MAPPING';
2193
2194 l_orig_sys_reference_rec.old_orig_system_reference := l_orig_system_reference;
2195 hz_orig_system_ref_pub.create_orig_system_reference(
2196 FND_API.G_FALSE,
2197 l_orig_sys_reference_rec,
2198 x_return_status,
2199 l_msg_count,
2200 l_msg_data);
2201
2202 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2203 RETURN;
2204 END IF;
2205 END LOOP;
2206 CLOSE c_check_party_site_mapping;
2207 EXCEPTION
2208 WHEN FND_API.G_EXC_ERROR THEN
2209 x_return_status := FND_API.G_RET_STS_ERROR;
2210 RETURN;
2211 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2212 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2213 RETURN;
2214 END;
2215
2216 --Inactivate HZ_CONTACT_POINTS records
2217 BEGIN
2218 OPEN c_check_contact_point_mapping;
2219 LOOP
2220 FETCH c_check_contact_point_mapping INTO l_orig_system_ref_id, l_object_version_number, l_start_date_active,
2221 l_orig_system, l_orig_system_reference, l_owner_table_name,l_owner_table_id;
2222
2223 EXIT WHEN c_check_contact_point_mapping%NOTFOUND;
2224 l_orig_sys_reference_rec.orig_system := l_orig_system;
2225 l_orig_sys_reference_rec.ORIG_SYSTEM_REF_ID := null;
2226 l_orig_sys_reference_rec.orig_system_reference := p_duns_number_c||substr(l_orig_system_reference, length(l_orig_system_reference_p)+1);
2227 l_orig_sys_reference_rec.owner_table_name := l_owner_table_name;
2228 l_orig_sys_reference_rec.owner_table_id := l_owner_table_id;
2229 l_orig_sys_reference_rec.start_date_active := sysdate;
2230 l_orig_sys_reference_rec.END_DATE_ACTIVE := NULL;
2231 l_orig_sys_reference_rec.party_id := p_organization_rec.party_rec.party_id;
2232 l_orig_sys_reference_rec.status := 'A';
2233 l_orig_sys_reference_rec.created_by_module := 'TCA_DNB_MAPPING';
2234 l_orig_sys_reference_rec.old_orig_system_reference := l_orig_system_reference;
2235 hz_orig_system_ref_pub.create_orig_system_reference(
2236 FND_API.G_FALSE,
2237 l_orig_sys_reference_rec,
2238 x_return_status,
2239 l_msg_count,
2240 l_msg_data);
2241
2242 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2243 RETURN;
2244 END IF;
2245 END LOOP;
2246 CLOSE c_check_contact_point_mapping;
2247 EXCEPTION
2248 WHEN FND_API.G_EXC_ERROR THEN
2249 x_return_status := FND_API.G_RET_STS_ERROR;
2250 RETURN;
2251 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2252 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2253 RETURN;
2254 END;
2255 END IF;
2256 CLOSE c_check_party_mapping;
2257 EXCEPTION
2258 WHEN FND_API.G_EXC_ERROR THEN
2259 x_return_status := FND_API.G_RET_STS_ERROR;
2260 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2261 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2262 END;
2263
2264
2265 EXCEPTION
2266 WHEN FND_API.G_EXC_ERROR THEN
2267 x_return_status := FND_API.G_RET_STS_ERROR;
2268 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2269 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2270 end check_new_duns;
2271
2272
2273 /*===========================================================================+
2274 | PROCEDURE
2275 | do_map
2276 |
2277 | DESCRIPTION
2278 | Create necessary USER_ENTERED/DNB data for new party and
2279 | map DNB data for this party.
2280 |
2281 | SCOPE - PRIVATE
2282 |
2283 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
2284 |
2285 | ARGUMENTS : IN:
2286 | p_content_source_type
2287 | p_store_orig_system_ref
2288 | OUT:
2289 | IN/ OUT:
2290 | p_interface_rec
2291 | x_return_status
2292 |
2293 | RETURNS : NONE
2294 |
2295 | NOTES
2296 |
2297 | MODIFICATION HISTORY
2298 |
2299 +===========================================================================*/
2300
2301 procedure do_map(
2302 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
2303 x_return_status IN OUT NOCOPY VARCHAR2
2304 ) IS
2305 l_organization_rec HZ_PARTY_V2PUB.organization_rec_type;
2306 l_location_rec hz_location_v2pub.location_rec_type;
2307 --l_credit_ratings_rec hz_party_info_pub.credit_ratings_rec_type;
2308 l_credit_ratings_rec hz_party_info_v2pub.credit_rating_rec_type;
2309 --l_fin_rep_rec hz_org_info_pub.financial_reports_rec_type;
2310 l_fin_rep_rec HZ_ORGANIZATION_INFO_V2PUB.financial_report_rec_type;
2311 --l_fin_num_rec hz_org_info_pub.financial_numbers_rec_type;
2312 l_fin_num_rec HZ_ORGANIZATION_INFO_V2PUB.financial_number_rec_type;
2313 l_contact_points_rec hz_contact_point_v2pub.contact_point_rec_type;
2314 l_phone_rec hz_contact_point_v2pub.phone_rec_type := HZ_CONTACT_POINT_V2PUB.G_MISS_PHONE_REC;
2315 l_code_assignment_rec hz_classification_v2pub.code_assignment_rec_type;
2316 l_organization_profile_id NUMBER;
2317 l_is_new_party BOOLEAN := FALSE;
2318 x_new_fin_report VARCHAR2(1);
2319
2320 -- Bug 3223595 : Added local variable
2321 l_exist VARCHAR2(1);
2322
2323 -- Bug 3492084 : Added orig_sys_reference_rec
2324 l_orig_sys_reference_rec HZ_ORIG_SYSTEM_REF_PUB.orig_sys_reference_rec_type;
2325 l_msg_count NUMBER;
2326 l_msg_data VARCHAR2(2000);
2327 l_orig_sys_ref_id NUMBER;
2328
2329 BEGIN
2330
2331 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP (+) ');
2332
2333 --
2334 -- Create party.
2335 --
2336
2337 do_assign_org_record(
2338 p_interface_rec,
2339 l_organization_rec);
2340
2341 store_org(l_organization_rec,
2342 l_organization_profile_id,
2343 x_return_status);
2344
2345 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2346 RETURN;
2347 END IF;
2348
2349 --
2350 --get back party_id from org rec
2351 --
2352
2353 IF p_interface_rec.party_id IS NULL THEN
2354 p_interface_rec.party_id := l_organization_rec.party_rec.party_id;
2355 l_is_new_party := TRUE;
2356 END IF;
2357
2358
2359 -- Bug 3223595 : Check if the party is enriched or it is new party
2360 -- If it is update party, call check_new_duns to check
2361 -- whether the duns number has changed and do MOSR table modifications.
2362 -- START OF CODE
2363
2364 if(l_is_new_party = FALSE) THEN
2365 check_new_duns(l_organization_rec, x_return_status);
2366 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2367 return;
2368 end if;
2369 end if;
2370
2371 -- END OF CODE FOR BUG 3223595
2372
2373 -- Bug 3492084 : While enriching a party, if there is no enrty in SSM table for
2374 -- this party, create an entry with passed duns_number.
2375
2376 if(l_is_new_party = FALSE) THEN
2377 BEGIN
2378 SELECT hosr.orig_system_ref_id INTO l_orig_sys_ref_id
2379 FROM hz_orig_sys_references hosr
2380 WHERE hosr.orig_system = 'DNB'
2381 AND hosr.owner_table_name = 'HZ_PARTIES'
2382 AND hosr.status='A'
2383 AND hosr.owner_table_id = l_organization_rec.party_rec.party_id;
2384 EXCEPTION
2385 WHEN NO_DATA_FOUND THEN
2386
2387 l_orig_sys_reference_rec.orig_system := 'DNB';
2388 l_orig_sys_reference_rec.orig_system_reference := l_organization_rec.duns_number_c;
2389 l_orig_sys_reference_rec.owner_table_name := 'HZ_PARTIES';
2390 l_orig_sys_reference_rec.owner_table_id := l_organization_rec.party_rec.party_id;
2391 l_orig_sys_reference_rec.start_date_active := sysdate;
2392 l_orig_sys_reference_rec.party_id := l_organization_rec.party_rec.party_id;
2393 l_orig_sys_reference_rec.status := 'A';
2394 l_orig_sys_reference_rec.created_by_module := 'TCA_DNB_MAPPING';
2395
2396
2397 hz_orig_system_ref_pub.create_orig_system_reference(
2398 FND_API.G_FALSE,
2399 l_orig_sys_reference_rec,
2400 x_return_status,
2401 l_msg_count,
2402 l_msg_data);
2403 if x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2404 RETURN;
2405 end if;
2406 END;
2407 end if;
2408 populate_to_classification(
2409 p_code_assignment_rec => l_code_assignment_rec,
2410 p_interface_rec => p_interface_rec,
2411 -- p_is_new_party => l_is_new_party,
2412 x_return_status => x_return_status
2413 );
2414
2415 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2416 RETURN;
2417 END IF;
2418
2419
2420 --
2421 -- Store Business Information Report.
2422 --
2423
2424 IF p_interface_rec.GDP_NAME = 'BIR' THEN
2425
2426 store_business_report(
2427 l_organization_profile_id,
2428 p_interface_rec.business_report
2429 );
2430
2431 END IF;
2432
2433
2434 --
2435 -- Create Location.
2436 --
2437
2438 do_assign_location_record(
2439 p_interface_rec,
2440 l_location_rec);
2441
2442 -- store actual_content_source = 'DNB'
2443
2444 --MOSR Changes. Create MOSR mapping for Party_site
2445 l_location_rec.orig_system_reference := l_organization_rec.duns_number_c;
2446 -- Bug 3417357 : pass l_is_new_party to store_location. l_is_new_party = TRUE
2447 -- for new parties
2448 store_location( l_location_rec,
2449 p_interface_rec.party_id,
2450 l_is_new_party,
2451 x_return_status);
2452
2453 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2454 RETURN;
2455 END IF;
2456 -- Bug 3070330 : Comment the code to store location for USER_ENTERED
2457 /*
2458 IF l_is_new_party THEN
2459 -- store actual_content_source = 'USER ENTERED'
2460 l_location_rec.location_id := NULL;
2461 l_location_rec.actual_content_source := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
2462 --MOSR Changes. Create MOSR mapping for Party_site
2463 l_location_rec.orig_system_reference := l_organization_rec.duns_number_c;
2464 store_location( l_location_rec,
2465 p_interface_rec.party_id,
2466 x_return_status);
2467
2468 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2469 RETURN;
2470 END IF;
2471 END IF;
2472 */
2473 --
2474 -- Create contact points.
2475 --
2476
2477 l_contact_points_rec.owner_table_id := l_organization_rec.party_rec.party_id;
2478 l_phone_rec.PHONE_COUNTRY_CODE := LTRIM(p_interface_rec.PHONE_COUNTRY_CODE, '0');
2479
2480 --MOSR Changes. Create MOSR mapping for contact_points
2481 l_contact_points_rec.ORIG_SYSTEM_REFERENCE := l_organization_rec.DUNS_NUMBER_C;
2482
2483 --
2484 -- Create Phone.
2485 --
2486
2487 --Don't need to check if l_phone_rec.RAW_PHONE_NUMBER is NULL here. This is being checked in store_contact_point. If this is null, and if it existed in database, needs to be updated to NULL.
2488
2489
2490 IF p_interface_rec.GDP_NAME <> 'BIR' THEN
2491
2492 IF p_interface_rec.TELEPHONE_NUMBER IS NOT NULL THEN
2493 l_phone_rec.PHONE_LINE_TYPE := 'GEN';
2494
2495 -- actual_content_source = 'DNB'
2496 l_contact_points_rec.actual_content_source := p_interface_rec.content_source_type;
2497 l_phone_rec.RAW_PHONE_NUMBER := p_interface_rec.TELEPHONE_NUMBER ;
2498 l_contact_points_rec.created_by_module := 'TCA_DNB_MAPPING';
2499
2500 store_contact_point (
2501 l_contact_points_rec,
2502 l_phone_rec,
2503 x_return_status);
2504
2505 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2506 RETURN;
2507 END IF;
2508 END IF;
2509
2510 --
2511 -- Create Fax.
2512 --
2513 IF p_interface_rec.FAX_NUMBER IS NOT NULL THEN
2514
2515 l_phone_rec.PHONE_LINE_TYPE := 'FAX';
2516
2517 -- actual_content_source = 'DNB'
2518 l_contact_points_rec.contact_point_id := NULL;
2519 l_contact_points_rec.ORIG_SYSTEM_REFERENCE := l_organization_rec.DUNS_NUMBER_C; /* Bug 6129275 */
2520 l_contact_points_rec.actual_content_source := p_interface_rec.content_source_type;
2521 l_phone_rec.RAW_PHONE_NUMBER := p_interface_rec.FAX_NUMBER ;
2522 l_phone_rec.PHONE_NUMBER := NULL;
2523 l_contact_points_rec.created_by_module := 'TCA_DNB_MAPPING';
2524
2525 store_contact_point (
2526 l_contact_points_rec,
2527 l_phone_rec,
2528 x_return_status);
2529
2530 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2531 RETURN;
2532 END IF;
2533
2534 END IF;
2535
2536 --
2537 -- Create credit ratings.
2538 --
2539
2540 --Bug 1674651: Business Verification Product provide Credit Ratings.
2541 --Need to remove 'BIZ_VER' from NOT IN list.
2542
2543 do_assign_credit_ratings(
2544 p_interface_rec => p_interface_rec,
2545 p_organization_rec => l_organization_rec,
2546 l_credit_ratings_rec => l_credit_ratings_rec
2547 );
2548
2549 -- actual_content_source = 'DNB'
2550 l_credit_ratings_rec.actual_content_source := p_interface_rec.content_source_type;
2551
2552 store_credit_ratings(
2553 l_credit_ratings_rec,
2554 x_return_status);
2555
2556 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2557 RETURN;
2558 END IF;
2559
2560 END IF; -- END IF p_interface_rec.GDP_NAME <> 'BIR'
2561
2562
2563 --
2564 -- Create Financial Reports.
2565 --
2566
2567 IF p_interface_rec.GDP_NAME NOT IN ('BIZ_VER', 'BIR') THEN
2568
2569 --Business Verification Product does not provide Financial info.
2570
2571 do_assign_financial_report(
2572 p_interface_rec => p_interface_rec,
2573 l_fin_rep_rec => l_fin_rep_reC,
2574 p_type_of_financial_report => 'BALANCE_SHEET');
2575
2576 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: BALANCE_SHEET');
2577
2578 -- actual_content_source = 'DNB'
2579
2580 store_financial_report(
2581 l_fin_rep_rec,
2582 p_interface_rec,
2583 x_return_status);
2584
2585 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2586 RETURN;
2587 END IF;
2588 END IF;
2589
2590
2591 --IF figures not null
2592 --Sales
2593 --Previous Sales
2594 --Cost of Sales
2595 --Gross Income
2596 --Profit Before Tax
2597 --Net Income
2598 --Dividends
2599
2600 IF
2601 ( p_interface_rec.SALES IS NOT NULL
2602 OR p_interface_rec.PREVIOUS_SALES IS NOT NULL
2603 OR p_interface_rec.COST_OF_SALES IS NOT NULL
2604 OR p_interface_rec.GROSS_INCOME IS NOT NULL
2605 OR p_interface_rec.PROFIT_BEFORE_TAX IS NOT NULL
2606 OR p_interface_rec.NET_INCOME IS NOT NULL
2607 OR p_interface_rec.DIVIDENDS IS NOT NULL)
2608 THEN
2609
2610 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: INCOME_STATEMENT');
2611
2612 do_assign_financial_report(
2613 p_interface_rec => p_interface_rec,
2614 l_fin_rep_rec => l_fin_rep_reC,
2615 p_type_of_financial_report => 'INCOME_STATEMENT');
2616
2617 -- actual_content_source = 'DNB'
2618 store_financial_report(
2619 l_fin_rep_rec,
2620 p_interface_rec,
2621 x_return_status);
2622
2623 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2624 RETURN;
2625 END IF;
2626 END IF;
2627
2628
2629 IF p_interface_rec.TANGIBLE_NET_WORTH IS NOT NULL THEN
2630
2631 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: TANGIBLE_NET_WORTH');
2632
2633 do_assign_financial_report(
2634 p_interface_rec => p_interface_rec,
2635 l_fin_rep_rec => l_fin_rep_reC,
2636 p_type_of_financial_report => 'TANGIBLE_NET_WORTH');
2637
2638 -- actual_content_source = 'DNB'
2639 store_financial_report(
2640 l_fin_rep_rec,
2641 p_interface_rec,
2642 x_return_status);
2643
2644 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2645 RETURN;
2646 END IF;
2647 END IF;
2648
2649
2650 IF p_interface_rec.ANNUAL_SALES_VOLUME IS NOT NULL THEN
2651
2652 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: ANNUAL_SALES_VOLUME');
2653
2654 do_assign_financial_report(
2655 p_interface_rec => p_interface_rec,
2656 l_fin_rep_rec => l_fin_rep_reC,
2657 p_type_of_financial_report => 'ANNUAL_SALES_VOLUME');
2658
2659 -- actual_content_source = 'DNB'
2660 store_financial_report(
2661 l_fin_rep_rec,
2662 p_interface_rec,
2663 x_return_status);
2664
2665 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2666 RETURN;
2667 END IF;
2668 END IF;
2669
2670 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP (-)');
2671
2672 END do_map;
2673
2674
2675 /*===========================================================================+
2676 | PROCEDURE
2677 | do_assign_org_record
2678 |
2679 | DESCRIPTION
2680 | assign interface data to org record.
2681 |
2682 | SCOPE - PRIVATE
2683 |
2684 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
2685 |
2686 | ARGUMENTS : IN:
2687 | p_interface_rec
2688 | OUT:
2689 | l_organization_rec
2690 | IN/ OUT:
2691 |
2692 | RETURNS : NONE
2693 |
2694 | NOTES
2695 |
2696 | MODIFICATION HISTORY
2697 |
2698 +===========================================================================*/
2699
2700 procedure do_assign_org_record(
2701 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
2702 l_organization_rec OUT NOCOPY HZ_PARTY_V2PUB.organization_rec_type
2703 ) IS
2704 BEGIN
2705
2706 -- set default value to SIC_CODE_TYPE when purchase 'Commercial Credit Score' GDP
2707 /* Bug 3107162. This is handled in rectify_error_fields
2708 IF p_interface_rec.GDP_NAME = 'COMM_CREDIT_SCORE' AND
2709 ( p_interface_rec.SIC_CODE1 is not null or
2710 p_interface_rec.SIC_CODE2 is not null or
2711 p_interface_rec.SIC_CODE3 is not null or
2712 p_interface_rec.SIC_CODE4 is not null or
2713 p_interface_rec.SIC_CODE5 is not null or
2714 p_interface_rec.SIC_CODE6 is not null ) AND
2715 p_interface_rec.SIC_CODE_TYPE is null
2716 THEN
2717 p_interface_rec.SIC_CODE_TYPE := '1987 SIC';
2718 p_interface_rec.SIC_CODE1 := SUBSTRB(replace(p_interface_rec.SIC_CODE1, ' ', ''), 1, 4);
2719 p_interface_rec.SIC_CODE2 := SUBSTRB(replace(p_interface_rec.SIC_CODE2, ' ', ''), 1, 4);
2720 p_interface_rec.SIC_CODE3 := SUBSTRB(replace(p_interface_rec.SIC_CODE3, ' ', ''), 1, 4);
2721 p_interface_rec.SIC_CODE4 := SUBSTRB(replace(p_interface_rec.SIC_CODE4, ' ', ''), 1, 4);
2722 p_interface_rec.SIC_CODE5 := SUBSTRB(replace(p_interface_rec.SIC_CODE5, ' ', ''), 1, 4);
2723 p_interface_rec.SIC_CODE6 := SUBSTRB(replace(p_interface_rec.SIC_CODE6, ' ', ''), 1, 4);
2724
2725 END IF;
2726 */
2727 l_organization_rec.party_rec.party_id := p_interface_rec.party_id;
2728 IF l_organization_rec.displayed_duns_party_id = FND_API.G_MISS_NUM OR
2729 l_organization_rec.displayed_duns_party_id = NULL THEN
2730 l_organization_rec.displayed_duns_party_id := l_organization_rec.party_rec.party_id;
2731 END IF;
2732 l_organization_rec.DUNS_NUMBER_C := lpad(to_char(p_interface_rec.DUNS_NUMBER),9,'0');
2733 l_organization_rec.ORGANIZATION_NAME := p_interface_rec.PARTY_NAME;
2734 l_organization_rec.KNOWN_AS := p_interface_rec.KNOWN_AS1;
2735 l_organization_rec.KNOWN_AS2 := p_interface_rec.KNOWN_AS2;
2736 l_organization_rec.KNOWN_AS3 := p_interface_rec.KNOWN_AS3;
2737 l_organization_rec.KNOWN_AS4 := p_interface_rec.KNOWN_AS4;
2738 l_organization_rec.KNOWN_AS5 := p_interface_rec.KNOWN_AS5;
2739 l_organization_rec.LOCAL_BUS_IDENTIFIER := p_interface_rec.LOCAL_BUS_IDENTIFIER;
2740 l_organization_rec.LOCAL_BUS_IDEN_TYPE := p_interface_rec.LOCAL_BUS_IDEN_TYPE;
2741 l_organization_rec.PREF_FUNCTIONAL_CURRENCY := p_interface_rec.PREF_FUNCTIONAL_CURRENCY;
2742 l_organization_rec.CONTROL_YR := p_interface_rec.CONTROL_YR;
2743 l_organization_rec.INCORP_YEAR := p_interface_rec.INCORP_YEAR;
2744 l_organization_rec.YEAR_ESTABLISHED := p_interface_rec.YEAR_ESTABLISHED;
2745 l_organization_rec.EMPLOYEES_TOTAL := p_interface_rec.EMPLOYEES_TOTAL;
2746 l_organization_rec.TOTAL_EMPLOYEES_TEXT := p_interface_rec.TOTAL_EMPLOYEES_TEXT;
2747 l_organization_rec.TOTAL_EMPLOYEES_IND := p_interface_rec.TOTAL_EMPLOYEES_IND;
2748 l_organization_rec.TOTAL_EMP_EST_IND := p_interface_rec.TOTAL_EMP_EST_IND;
2749 l_organization_rec.TOTAL_EMP_MIN_IND := p_interface_rec.TOTAL_EMP_MIN_IND;
2750 l_organization_rec.EMP_AT_PRIMARY_ADR := p_interface_rec.EMP_AT_PRIMARY_ADR;
2751 l_organization_rec.EMP_AT_PRIMARY_ADR_TEXT := p_interface_rec.EMP_AT_PRIMARY_ADR_TEXT;
2752 l_organization_rec.EMP_AT_PRIMARY_ADR_EST_IND := p_interface_rec.EMP_AT_PRIMARY_ADR_EST_IND;
2753 l_organization_rec.EMP_AT_PRIMARY_ADR_MIN_IND := p_interface_rec.EMP_AT_PRIMARY_ADR_MIN_IND;
2754
2755 l_organization_rec.SIC_CODE_TYPE := p_interface_rec.SIC_CODE_TYPE;
2756 l_organization_rec.SIC_CODE := p_interface_rec.SIC_CODE1;
2757
2758
2759 /* Bug 3107162
2760 IF p_interface_rec.SIC_CODE_TYPE IN ('1972', '1977', '1987') THEN
2761 l_organization_rec.SIC_CODE_TYPE := p_interface_rec.SIC_CODE_TYPE || ' SIC';
2762 END IF;
2763
2764
2765 IF l_organization_rec.SIC_CODE_TYPE IN ('1972 SIC', '1977 SIC', '1987 SIC') THEN
2766 l_organization_rec.SIC_CODE := SUBSTRB(replace(p_interface_rec.SIC_CODE1, ' ', ''), 1, 4);
2767 END IF;
2768 */
2769 l_organization_rec.LOCAL_ACTIVITY_CODE := p_interface_rec.LOCAL_ACTIVITY_CODE;
2770 l_organization_rec.LOCAL_ACTIVITY_CODE_TYPE := p_interface_rec.LOCAL_ACTIVITY_CODE_TYPE;
2771 l_organization_rec.LINE_OF_BUSINESS := p_interface_rec.LINE_OF_BUSINESS;
2772 l_organization_rec.PARENT_SUB_IND := p_interface_rec.PARENT_SUB_IND;
2773 l_organization_rec.HQ_BRANCH_IND := p_interface_rec.HQ_BRANCH_IND;
2774 /* Bug 3107162
2775 IF p_interface_rec.GDP_NAME = 'COMM_CREDIT_SCORE' THEN
2776 IF l_organization_rec.HQ_BRANCH_IND = 'H' THEN
2777 l_organization_rec.HQ_BRANCH_IND := 'HQ';
2778 ELSIF l_organization_rec.HQ_BRANCH_IND = 'B' THEN
2779 l_organization_rec.HQ_BRANCH_IND := 'BR';
2780 ELSIF l_organization_rec.HQ_BRANCH_IND = 'S' THEN
2781 l_organization_rec.HQ_BRANCH_IND := 'SL';
2782 END IF;
2783 END IF;
2784 */
2785 l_organization_rec.LEGAL_STATUS := p_interface_rec.LEGAL_STATUS;
2786 l_organization_rec.REGISTRATION_TYPE := p_interface_rec.REGISTRATION_TYPE;
2787 l_organization_rec.RENT_OWN_IND := p_interface_rec.RENT_OWN_IND;
2788 l_organization_rec.CEO_NAME := p_interface_rec.CEO_NAME;
2789 l_organization_rec.CEO_TITLE := p_interface_rec.CEO_TITLE;
2790 l_organization_rec.PRINCIPAL_TITLE := p_interface_rec.PRINCIPAL_TITLE;
2791 l_organization_rec.PRINCIPAL_NAME := p_interface_rec.PRINCIPAL_NAME;
2792 l_organization_rec.TOTAL_PAYMENTS := p_interface_rec.TOTAL_PAYMENTS;
2793 l_organization_rec.OOB_IND := p_interface_rec.OOB_IND;
2794 /* Bug 3107162
2795 IF l_organization_rec.OOB_IND = 'OB' THEN
2796 l_organization_rec.OOB_IND := 'Y';
2797 END IF;
2798 */
2799 l_organization_rec.IMPORT_IND := p_interface_rec.IMPORT_IND;
2800 l_organization_rec.EXPORT_IND := p_interface_rec.EXPORT_IND;
2801 l_organization_rec.BRANCH_FLAG := p_interface_rec.BRANCH_FLAG;
2802 l_organization_rec.PARENT_SUB_IND := p_interface_rec.PARENT_SUB_IND;
2803 l_organization_rec.CONG_DIST_CODE := p_interface_rec.CONG_DIST_CODE1;
2804 l_organization_rec.LABOR_SURPLUS_IND := p_interface_rec.LABOR_SURPLUS_IND;
2805 l_organization_rec.SMALL_BUS_IND := p_interface_rec.SMALL_BUS_IND;
2806 l_organization_rec.WOMAN_OWNED_IND := p_interface_rec.WOMAN_OWNED_IND;
2807 l_organization_rec.MINORITY_OWNED_IND := p_interface_rec.MINORITY_OWNED_IND;
2808 l_organization_rec.DISADV_8A_IND := p_interface_rec.DISADV_8A_IND;
2809 l_organization_rec.party_rec.ORIG_SYSTEM_REFERENCE := p_interface_rec.ORIG_SYSTEM_REFERENCE;
2810 l_organization_rec.DO_NOT_CONFUSE_WITH := p_interface_rec.DO_NOT_CONFUSE_WITH;
2811
2812 -- the following column has been moved to credit rating. but we keep supporting these column
2813 -- so do not populate to credit rating record directly
2814 l_organization_rec.DB_RATING := p_interface_rec.DB_RATING;
2815 l_organization_rec.AVG_HIGH_CREDIT := p_interface_rec.AVG_HIGH_CREDIT;
2816 l_organization_rec.CREDIT_SCORE := p_interface_rec.CREDIT_SCORE;
2817 l_organization_rec.CREDIT_SCORE_AGE := p_interface_rec.CREDIT_SCORE_AGE;
2818 l_organization_rec.CREDIT_SCORE_CLASS := p_interface_rec.CREDIT_SCORE_CLASS;
2819 l_organization_rec.CREDIT_SCORE_COMMENTARY := p_interface_rec.CREDIT_SCORE_COMMENTARY1;
2820 l_organization_rec.CREDIT_SCORE_COMMENTARY2 := p_interface_rec.CREDIT_SCORE_COMMENTARY2;
2821 l_organization_rec.CREDIT_SCORE_COMMENTARY3 := p_interface_rec.CREDIT_SCORE_COMMENTARY3;
2822 l_organization_rec.CREDIT_SCORE_COMMENTARY4 := p_interface_rec.CREDIT_SCORE_COMMENTARY4;
2823 l_organization_rec.CREDIT_SCORE_COMMENTARY5 := p_interface_rec.CREDIT_SCORE_COMMENTARY5;
2824 l_organization_rec.CREDIT_SCORE_COMMENTARY6 := p_interface_rec.CREDIT_SCORE_COMMENTARY6;
2825 l_organization_rec.CREDIT_SCORE_COMMENTARY7 := p_interface_rec.CREDIT_SCORE_COMMENTARY7;
2826 l_organization_rec.CREDIT_SCORE_COMMENTARY8 := p_interface_rec.CREDIT_SCORE_COMMENTARY8;
2827 l_organization_rec.CREDIT_SCORE_COMMENTARY9 := p_interface_rec.CREDIT_SCORE_COMMENTARY9;
2828 l_organization_rec.CREDIT_SCORE_COMMENTARY10 := p_interface_rec.CREDIT_SCORE_COMMENTARY10;
2829 l_organization_rec.CREDIT_SCORE_DATE := p_interface_rec.CREDIT_SCORE_DATE;
2830 l_organization_rec.CREDIT_SCORE_INCD_DEFAULT := p_interface_rec.CREDIT_SCORE_INCD_DEFAULT;
2831 l_organization_rec.CREDIT_SCORE_NATL_PERCENTILE := p_interface_rec.CREDIT_SCORE_NATL_PERCENTILE;
2832 l_organization_rec.FAILURE_SCORE := p_interface_rec.FAILURE_SCORE;
2833 l_organization_rec.FAILURE_SCORE_COMMENTARY := p_interface_rec.FAILURE_SCORE_COMMENTARY1;
2834 l_organization_rec.FAILURE_SCORE_COMMENTARY2 := p_interface_rec.FAILURE_SCORE_COMMENTARY2;
2835 l_organization_rec.FAILURE_SCORE_COMMENTARY3 := p_interface_rec.FAILURE_SCORE_COMMENTARY3;
2836 l_organization_rec.FAILURE_SCORE_COMMENTARY4 := p_interface_rec.FAILURE_SCORE_COMMENTARY4;
2837 l_organization_rec.FAILURE_SCORE_COMMENTARY5 := p_interface_rec.FAILURE_SCORE_COMMENTARY5;
2838 l_organization_rec.FAILURE_SCORE_COMMENTARY6 := p_interface_rec.FAILURE_SCORE_COMMENTARY6;
2839 l_organization_rec.FAILURE_SCORE_COMMENTARY7 := p_interface_rec.FAILURE_SCORE_COMMENTARY7;
2840 l_organization_rec.FAILURE_SCORE_COMMENTARY8 := p_interface_rec.FAILURE_SCORE_COMMENTARY8;
2841 l_organization_rec.FAILURE_SCORE_COMMENTARY9 := p_interface_rec.FAILURE_SCORE_COMMENTARY9;
2842 l_organization_rec.FAILURE_SCORE_COMMENTARY10 := p_interface_rec.FAILURE_SCORE_COMMENTARY10;
2843 l_organization_rec.FAILURE_SCORE_CLASS := p_interface_rec.FAILURE_SCORE_CLASS;
2844 l_organization_rec.FAILURE_SCORE_NATNL_PERCENTILE := p_interface_rec.FAILURE_SCORE_NATL_PERCENTILE;
2845 l_organization_rec.FAILURE_SCORE_INCD_DEFAULT := p_interface_rec.FAILURE_SCORE_INCD_DEFAULT;
2846 l_organization_rec.FAILURE_SCORE_AGE := p_interface_rec.FAILURE_SCORE_AGE;
2847 l_organization_rec.FAILURE_SCORE_OVERRIDE_CODE := p_interface_rec.FAILURE_SCORE_OVERRIDE_CODE;
2848 l_organization_rec.FAILURE_SCORE_DATE := p_interface_rec.FAILURE_SCORE_DATE;
2849 l_organization_rec.GLOBAL_FAILURE_SCORE := p_interface_rec.GLOBAL_FAILURE_SCORE;
2850 l_organization_rec.DEBARMENTS_COUNT := p_interface_rec.DEBARMENTS_COUNT;
2851 l_organization_rec.DEBARMENTS_DATE := p_interface_rec.DEBARMENTS_DATE;
2852 l_organization_rec.HIGH_CREDIT := p_interface_rec.HIGH_CREDIT;
2853 l_organization_rec.MAXIMUM_CREDIT_CURRENCY_CODE := p_interface_rec.MAX_CREDIT_CURRENCY;
2854 l_organization_rec.MAXIMUM_CREDIT_RECOMMENDATION := p_interface_rec.MAX_CREDIT_RECOMMEND;
2855 l_organization_rec.PAYDEX_NORM := p_interface_rec.PAYDEX_NORM;
2856 l_organization_rec.PAYDEX_SCORE := p_interface_rec.PAYDEX_SCORE;
2857 l_organization_rec.PAYDEX_THREE_MONTHS_AGO := p_interface_rec.PAYDEX_THREE_MONTHS_AGO;
2858
2859
2860 l_organization_rec.CONTENT_SOURCE_NUMBER := to_char(p_interface_rec.DUNS_NUMBER);
2861 l_organization_rec.ACTUAL_CONTENT_SOURCE := p_interface_rec.CONTENT_SOURCE_TYPE;
2862 l_organization_rec.created_by_module := 'TCA_DNB_MAPPING';
2863 --bug 4161092
2864 IF p_interface_rec.SALES IS NOT NULL THEN
2865 l_organization_rec.CURR_FY_POTENTIAL_REVENUE := p_interface_rec.SALES;
2866 ELSE
2867 --Bug 3770469 . Map annual_sales_volume passed by DNB to CURR_FY_POTENTIAL_REVENUE
2868 l_organization_rec.CURR_FY_POTENTIAL_REVENUE := p_interface_rec.ANNUAL_SALES_VOLUME;
2869 -- end of bug 3770469
2870 END IF;
2871
2872 END do_assign_org_record;
2873
2874
2875 procedure do_assign_location_record(
2876 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
2877 l_location_rec OUT NOCOPY hz_location_v2pub.location_rec_type
2878 ) IS
2879 BEGIN
2880
2881 l_location_rec.ADDRESS1 := NVL(p_interface_rec.ADDRESS1, 'Not provided by DNB');
2882 l_location_rec.ADDRESS2 := NVL(p_interface_rec.ADDRESS2, FND_API.G_MISS_CHAR);
2883 l_location_rec.ADDRESS3 := NVL(p_interface_rec.ADDRESS3, FND_API.G_MISS_CHAR);
2884 l_location_rec.ADDRESS4 := NVL(p_interface_rec.ADDRESS4, FND_API.G_MISS_CHAR);
2885 l_location_rec.CITY := NVL(p_interface_rec.CITY, FND_API.G_MISS_CHAR);
2886 l_location_rec.STATE := NVL(p_interface_rec.STATE, FND_API.G_MISS_CHAR);
2887 l_location_rec.COUNTY := NVL(p_interface_rec.COUNTY, FND_API.G_MISS_CHAR);
2888 l_location_rec.POSTAL_CODE := NVL(p_interface_rec.POSTAL_CODE, FND_API.G_MISS_CHAR);
2889
2890 --Bug 1736056: Default country to 'US' if it is NULL. Convert
2891 --lower case to upper case.
2892 l_location_rec.COUNTRY := NVL(UPPER(p_interface_rec.COUNTRY), G_DEFAULT_COUNTRY_CODE);
2893
2894 l_location_rec.PROVINCE := NVL(p_interface_rec.PROVINCE, FND_API.G_MISS_CHAR);
2895 l_location_rec.orig_system_reference := p_interface_rec.orig_system_reference;
2896 l_location_rec.actual_content_source := p_interface_rec.content_source_type;
2897 l_location_rec.created_by_module := 'TCA_DNB_MAPPING';
2898
2899 END do_assign_location_record;
2900
2901 procedure do_assign_credit_ratings(
2902 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
2903 p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE,
2904 --l_credit_ratings_rec OUT NOCOPY HZ_PARTY_INFO_PUB.CREDIT_RATINGS_REC_TYPE
2905 l_credit_ratings_rec OUT NOCOPY HZ_PARTY_INFO_V2PUB.CREDIT_RATING_REC_TYPE
2906 ) IS
2907 BEGIN
2908 arp_util.debug('HZ_MAP_PARTY_PUB.do_assign_credit_ratings (+) ');
2909 l_credit_ratings_rec.PARTY_ID := p_organization_rec.party_rec.party_id;
2910 l_credit_ratings_rec.RATED_AS_OF_DATE := sysdate;
2911 l_credit_ratings_rec.RATING_ORGANIZATION := 'DNB';
2912 l_credit_ratings_rec.FINCL_EMBT_IND := p_interface_rec.FINCL_EMBT_IND;
2913 l_credit_ratings_rec.FINCL_LGL_EVENT_IND := p_interface_rec.FINCL_LGL_EVENT_IND;
2914 l_credit_ratings_rec.OPRG_SPEC_EVNT_IND := p_interface_rec.OPRG_SPEC_EVNT_IND;
2915 l_credit_ratings_rec.OTHER_SPEC_EVNT_IND := p_interface_rec.OTHER_SPEC_EVNT_IND;
2916 l_credit_ratings_rec.DET_HISTORY_IND := p_interface_rec.DET_HISTORY_IND;
2917 -- obsolete SUIT_JUDGE_IND
2918 -- l_credit_ratings_rec.SUIT_JUDGE_IND := p_interface_rec.SUIT_JUDGE_IND;
2919 l_credit_ratings_rec.CLAIMS_IND := p_interface_rec.CLAIMS_IND;
2920 l_credit_ratings_rec.SECURED_FLNG_IND := p_interface_rec.SECURED_FLNG_IND;
2921 l_credit_ratings_rec.CRIMINAL_PROCEEDING_IND := p_interface_rec.CRIMINAL_PROCEEDING_IND;
2922 l_credit_ratings_rec.DISASTER_IND := p_interface_rec.DISASTER_IND;
2923 l_credit_ratings_rec.ACTUAL_CONTENT_SOURCE := p_interface_rec.CONTENT_SOURCE_TYPE;
2924
2925 -- the follow columns are migrated from org profile
2926 l_credit_ratings_rec.RATING := p_interface_rec.DB_RATING;
2927 l_credit_ratings_rec.AVG_HIGH_CREDIT := p_interface_rec.AVG_HIGH_CREDIT;
2928 l_credit_ratings_rec.CREDIT_SCORE := p_interface_rec.CREDIT_SCORE;
2929 l_credit_ratings_rec.CREDIT_SCORE_AGE := p_interface_rec.CREDIT_SCORE_AGE;
2930 l_credit_ratings_rec.CREDIT_SCORE_CLASS := p_interface_rec.CREDIT_SCORE_CLASS;
2931 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY := p_interface_rec.CREDIT_SCORE_COMMENTARY1;
2932 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY2 := p_interface_rec.CREDIT_SCORE_COMMENTARY2;
2933 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY3 := p_interface_rec.CREDIT_SCORE_COMMENTARY3;
2934 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY4 := p_interface_rec.CREDIT_SCORE_COMMENTARY4;
2935 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY5 := p_interface_rec.CREDIT_SCORE_COMMENTARY5;
2936 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY6 := p_interface_rec.CREDIT_SCORE_COMMENTARY6;
2937 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY7 := p_interface_rec.CREDIT_SCORE_COMMENTARY7;
2938 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY8 := p_interface_rec.CREDIT_SCORE_COMMENTARY8;
2939 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY9 := p_interface_rec.CREDIT_SCORE_COMMENTARY9;
2940 l_credit_ratings_rec.CREDIT_SCORE_COMMENTARY10 := p_interface_rec.CREDIT_SCORE_COMMENTARY10;
2941 l_credit_ratings_rec.CREDIT_SCORE_DATE := p_interface_rec.CREDIT_SCORE_DATE;
2942 l_credit_ratings_rec.CREDIT_SCORE_INCD_DEFAULT := p_interface_rec.CREDIT_SCORE_INCD_DEFAULT;
2943 l_credit_ratings_rec.CREDIT_SCORE_NATL_PERCENTILE := p_interface_rec.CREDIT_SCORE_NATL_PERCENTILE;
2944 l_credit_ratings_rec.FAILURE_SCORE := p_interface_rec.FAILURE_SCORE;
2945 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY := p_interface_rec.FAILURE_SCORE_COMMENTARY1;
2946 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY2 := p_interface_rec.FAILURE_SCORE_COMMENTARY2;
2947 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY3 := p_interface_rec.FAILURE_SCORE_COMMENTARY3;
2948 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY4 := p_interface_rec.FAILURE_SCORE_COMMENTARY4;
2949 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY5 := p_interface_rec.FAILURE_SCORE_COMMENTARY5;
2950 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY6 := p_interface_rec.FAILURE_SCORE_COMMENTARY6;
2951 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY7 := p_interface_rec.FAILURE_SCORE_COMMENTARY7;
2952 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY8 := p_interface_rec.FAILURE_SCORE_COMMENTARY8;
2953 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY9 := p_interface_rec.FAILURE_SCORE_COMMENTARY9;
2954 l_credit_ratings_rec.FAILURE_SCORE_COMMENTARY10 := p_interface_rec.FAILURE_SCORE_COMMENTARY10;
2955 l_credit_ratings_rec.FAILURE_SCORE_CLASS := p_interface_rec.FAILURE_SCORE_CLASS;
2956 l_credit_ratings_rec.FAILURE_SCORE_NATNL_PERCENTILE := p_interface_rec.FAILURE_SCORE_NATL_PERCENTILE;
2957 l_credit_ratings_rec.FAILURE_SCORE_INCD_DEFAULT := p_interface_rec.FAILURE_SCORE_INCD_DEFAULT;
2958 l_credit_ratings_rec.FAILURE_SCORE_AGE := p_interface_rec.FAILURE_SCORE_AGE;
2959 l_credit_ratings_rec.FAILURE_SCORE_OVERRIDE_CODE := p_interface_rec.FAILURE_SCORE_OVERRIDE_CODE;
2960 l_credit_ratings_rec.FAILURE_SCORE_DATE := p_interface_rec.FAILURE_SCORE_DATE;
2961 l_credit_ratings_rec.GLOBAL_FAILURE_SCORE := p_interface_rec.GLOBAL_FAILURE_SCORE;
2962 l_credit_ratings_rec.DEBARMENTS_COUNT := p_interface_rec.DEBARMENTS_COUNT;
2963 l_credit_ratings_rec.DEBARMENTS_DATE := p_interface_rec.DEBARMENTS_DATE;
2964 l_credit_ratings_rec.HIGH_CREDIT := p_interface_rec.HIGH_CREDIT;
2965 l_credit_ratings_rec.MAXIMUM_CREDIT_CURRENCY_CODE := p_interface_rec.MAX_CREDIT_CURRENCY;
2966 l_credit_ratings_rec.MAXIMUM_CREDIT_RCMD := p_interface_rec.MAX_CREDIT_RECOMMEND;
2967 l_credit_ratings_rec.PAYDEX_NORM := p_interface_rec.PAYDEX_NORM;
2968 l_credit_ratings_rec.PAYDEX_SCORE := p_interface_rec.PAYDEX_SCORE;
2969 l_credit_ratings_rec.PAYDEX_THREE_MONTHS_AGO := p_interface_rec.PAYDEX_THREE_MONTHS_AGO;
2970 -- end of column from org profile
2971
2972 l_credit_ratings_rec.CREDIT_SCORE_OVERRIDE_CODE := p_interface_rec.CREDIT_SCORE_OVERRIDE_CODE;
2973 l_credit_ratings_rec.CR_SCR_CLAS_EXPL := p_interface_rec.CR_SCR_CLAS_EXPL;
2974 l_credit_ratings_rec.LOW_RNG_DELQ_SCR := p_interface_rec.LOW_RNG_DELQ_SCR;
2975 l_credit_ratings_rec.HIGH_RNG_DELQ_SCR := p_interface_rec.HIGH_RNG_DELQ_SCR;
2976 l_credit_ratings_rec.DELQ_PMT_RNG_PRCNT := p_interface_rec.DELQ_PMT_RNG_PRCNT;
2977 l_credit_ratings_rec.DELQ_PMT_PCTG_FOR_ALL_FIRMS := p_interface_rec.DELQ_PMT_PCTG_FOR_ALL_FIRMS;
2978 l_credit_ratings_rec.NUM_TRADE_EXPERIENCES := p_interface_rec.NUM_TRADE_EXPERIENCES;
2979 l_credit_ratings_rec.PAYDEX_FIRM_DAYS := p_interface_rec.PAYDEX_FIRM_DAYS;
2980 l_credit_ratings_rec.PAYDEX_FIRM_COMMENT := p_interface_rec.PAYDEX_FIRM_COMMENT;
2981 l_credit_ratings_rec.PAYDEX_INDUSTRY_DAYS := p_interface_rec.PAYDEX_INDUSTRY_DAYS;
2982 l_credit_ratings_rec.PAYDEX_INDUSTRY_COMMENT := p_interface_rec.PAYDEX_INDUSTRY_COMMENT;
2983 l_credit_ratings_rec.PAYDEX_COMMENT := p_interface_rec.PAYDEX_COMMENT;
2984 l_credit_ratings_rec.SUIT_IND := p_interface_rec.SUIT_IND;
2985 l_credit_ratings_rec.LIEN_IND := p_interface_rec.LIEN_IND;
2986 l_credit_ratings_rec.JUDGEMENT_IND := p_interface_rec.JUDGEMENT_IND;
2987 l_credit_ratings_rec.BANKRUPTCY_IND := p_interface_rec.BANKRUPTCY_IND;
2988 l_credit_ratings_rec.NO_TRADE_IND := p_interface_rec.NO_TRADE_IND;
2989 l_credit_ratings_rec.PRNT_HQ_BKCY_IND := p_interface_rec.PRNT_HQ_BKCY_IND;
2990
2991 /* Bug 3107162
2992 IF p_interface_rec.GDP_NAME = 'COMM_CREDIT_SCORE' THEN
2993 IF l_credit_ratings_rec.SUIT_IND is null THEN
2994 l_credit_ratings_rec.SUIT_IND := 'N';
2995 ELSIF l_credit_ratings_rec.SUIT_IND = 'S' THEN
2996 l_credit_ratings_rec.SUIT_IND := 'Y';
2997 END IF;
2998
2999 IF l_credit_ratings_rec.LIEN_IND is null THEN
3000 l_credit_ratings_rec.LIEN_IND := 'N';
3001 ELSIF l_credit_ratings_rec.LIEN_IND = 'L' THEN
3002 l_credit_ratings_rec.LIEN_IND := 'Y';
3003 END IF;
3004
3005 IF l_credit_ratings_rec.JUDGEMENT_IND is null THEN
3006 l_credit_ratings_rec.JUDGEMENT_IND := 'N';
3007 ELSIF l_credit_ratings_rec.JUDGEMENT_IND = 'J' THEN
3008 l_credit_ratings_rec.JUDGEMENT_IND := 'Y';
3009 END IF;
3010
3011 IF l_credit_ratings_rec.BANKRUPTCY_IND is null THEN
3012 l_credit_ratings_rec.BANKRUPTCY_IND := 'N';
3013 ELSIF l_credit_ratings_rec.BANKRUPTCY_IND = 'B' THEN
3014 l_credit_ratings_rec.BANKRUPTCY_IND := 'Y';
3015 END IF;
3016
3017 IF l_credit_ratings_rec.NO_TRADE_IND is null THEN
3018 l_credit_ratings_rec.NO_TRADE_IND := 'Y';
3019 END IF;
3020
3021 IF l_credit_ratings_rec.PRNT_HQ_BKCY_IND is null THEN
3022 l_credit_ratings_rec.PRNT_HQ_BKCY_IND := 'N';
3023 END IF;
3024 END IF;*/
3025
3026 l_credit_ratings_rec.NUM_PRNT_BKCY_FILING := p_interface_rec.NUM_PRNT_BKCY_FILING;
3027 l_credit_ratings_rec.PRNT_BKCY_FILG_TYPE := p_interface_rec.PRNT_BKCY_FILG_TYPE;
3028 l_credit_ratings_rec.PRNT_BKCY_FILG_CHAPTER := p_interface_rec.PRNT_BKCY_FILG_CHAPTER;
3029 l_credit_ratings_rec.PRNT_BKCY_FILG_DATE := p_interface_rec.PRNT_BKCY_FILG_DATE;
3030 l_credit_ratings_rec.NUM_PRNT_BKCY_CONVS := p_interface_rec.NUM_PRNT_BKCY_CONVS;
3031 l_credit_ratings_rec.PRNT_BKCY_CONV_DATE := p_interface_rec.PRNT_BKCY_CONV_DATE;
3032 l_credit_ratings_rec.PRNT_BKCY_CHAPTER_CONV := p_interface_rec.PRNT_BKCY_CHAPTER_CONV;
3033 l_credit_ratings_rec.SLOW_TRADE_EXPL := p_interface_rec.SLOW_TRADE_EXPL;
3034 l_credit_ratings_rec.NEGV_PMT_EXPL := p_interface_rec.NEGV_PMT_EXPL;
3035 l_credit_ratings_rec.PUB_REC_EXPL := p_interface_rec.PUB_REC_EXPL;
3036 l_credit_ratings_rec.BUSINESS_DISCONTINUED := p_interface_rec.BUSINESS_DISCONTINUED;
3037 l_credit_ratings_rec.SPCL_EVENT_COMMENT := p_interface_rec.SPCL_EVENT_COMMENT;
3038 l_credit_ratings_rec.NUM_SPCL_EVENT := p_interface_rec.NUM_SPCL_EVENT;
3039 l_credit_ratings_rec.SPCL_EVENT_UPDATE_DATE := p_interface_rec.SPCL_EVENT_UPDATE_DATE;
3040 l_credit_ratings_rec.SPCL_EVNT_TXT := p_interface_rec.SPCL_EVNT_TXT;
3041
3042 END do_assign_credit_ratings;
3043
3044
3045 procedure do_assign_financial_report(
3046 p_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
3047 --l_fin_rep_rec IN OUT NOCOPY HZ_ORG_INFO_PUB.FINANCIAL_REPORTS_REC_TYPE,
3048 l_fin_rep_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_REPORT_REC_TYPE,
3049 p_type_of_financial_report IN HZ_FINANCIAL_REPORTS.TYPE_OF_FINANCIAL_REPORT%type
3050 ) IS
3051 BEGIN
3052
3053 l_fin_rep_rec.financial_report_id := NULL;
3054 l_fin_rep_rec.PARTY_ID := p_interface_rec.party_id;
3055
3056 /* Bug 3539597.Date_report_issued will always be set to NULL.
3057 -- bug 3200870
3058 l_fin_rep_rec.DATE_REPORT_ISSUED:= nvl(p_interface_rec.STATEMENT_DATE, sysdate);*/
3059
3060 l_fin_rep_rec.AUDIT_IND := p_interface_rec.AUDIT_IND;
3061 /* Bug 3107162
3062 IF p_interface_rec.CONSOLIDATED_IND = 'C' THEN
3063 l_fin_rep_rec.CONSOLIDATED_IND := 'Y';
3064 ELSIF p_interface_rec.CONSOLIDATED_IND = 'N' THEN
3065 l_fin_rep_rec.CONSOLIDATED_IND := 'N';
3066 END IF;
3067 */
3068 l_fin_rep_rec.CONSOLIDATED_IND := p_interface_rec.CONSOLIDATED_IND;
3069 l_fin_rep_rec.ESTIMATED_IND := p_interface_rec.ESTIMATED_IND;
3070 l_fin_rep_rec.FORECAST_IND := p_interface_rec.FORECAST_IND;
3071 l_fin_rep_rec.FISCAL_IND := p_interface_rec.FISCAL_IND;
3072 l_fin_rep_rec.FINAL_IND := p_interface_rec.FINAL_IND;
3073 l_fin_rep_rec.SIGNED_BY_PRINCIPALS_IND := p_interface_rec.SIGNED_BY_PRINCIPALS_IND;
3074 l_fin_rep_rec.RESTATED_IND := p_interface_rec.RESTATED_IND;
3075 l_fin_rep_rec.UNBALANCED_IND := p_interface_rec.UNBALANCED_IND;
3076 l_fin_rep_rec.QUALIFIED_IND := p_interface_rec.QUALIFIED_IND;
3077 l_fin_rep_rec.OPENING_IND := p_interface_rec.OPENING_IND;
3078 l_fin_rep_rec.PROFORMA_IND := p_interface_rec.PROFORMA_IND;
3079 l_fin_rep_rec.TRIAL_BALANCE_IND := p_interface_rec.TRIAL_BALANCE_IND;
3080 l_fin_rep_rec.ACTUAL_CONTENT_SOURCE := p_interface_rec.content_source_type;
3081
3082 IF p_type_of_financial_report = 'BALANCE_SHEET' THEN
3083 l_fin_rep_rec.type_of_financial_report := 'BALANCE_SHEET';
3084
3085 -- Bug 3539597.
3086 l_fin_rep_rec.REPORT_START_DATE := NULL;
3087 l_fin_rep_rec.REPORT_END_DATE := NULL;
3088 l_fin_rep_rec.ISSUED_PERIOD := NVL(TO_CHAR(p_interface_rec.STATEMENT_DATE),
3089 TO_CHAR(SYSDATE,'YYYY'));
3090
3091 ELSIF p_type_of_financial_report = 'INCOME_STATEMENT' THEN
3092 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: INCOME_STATEMENT');
3093 l_fin_rep_rec.type_of_financial_report := 'INCOME_STATEMENT';
3094
3095
3096 /* Bug 3539597.Replaced the previous mapping rules.
3097 | l_fin_rep_rec.REPORT_START_DATE := p_interface_rec.INCOME_STMT_START_DATE;
3098 | l_fin_rep_rec.REPORT_END_DATE := p_interface_rec.INCOME_STMT_END_DATE;
3099 |
3100 | --Bug 2995642: Modified do_assign_financial_report, such that DATE_REPORT_ISSUED should be
3101 | --INCOME_STMT_DATE. If this is null, then INCOME_STMT_END_DATE. If this is null, then
3102 | --INCOME_STMT_START_DATE. If this is also null, then STATEMENT_DATE.
3103 | --If one of INCOME_STMT_START_DATE or INCOME_STMT_END_DATE is null, then making the other null too.
3104 | --So, either pass both as null or both as 'not null'.
3105 |
3106 | IF p_interface_rec.INCOME_STMT_START_DATE IS NULL THEN
3107 | l_fin_rep_rec.REPORT_END_DATE := NULL;
3108 | END IF;
3109 | IF p_interface_rec.INCOME_STMT_END_DATE IS NULL THEN
3110 | l_fin_rep_rec.REPORT_START_DATE := NULL;
3111 | END IF;
3112 |
3113 |-- Bug 2995642 : Modified the assignment to DATE_REPORT_ISSUED.
3114 |-- bug 3200870 on top of 2995642
3115 |
3116 | l_fin_rep_rec.DATE_REPORT_ISSUED := nvl(
3117 | nvl(p_interface_rec.INCOME_STMT_DATE,
3118 | nvl(p_interface_rec.INCOME_STMT_END_DATE,
3119 | nvl(p_interface_rec.STATEMENT_DATE,
3120 | p_interface_rec.INCOME_STMT_START_DATE))), sysdate);
3121 |
3122 */
3123 IF p_interface_rec.INCOME_STMT_START_DATE IS NULL OR
3124 p_interface_rec.INCOME_STMT_START_DATE = FND_API.G_MISS_DATE OR
3125 p_interface_rec.INCOME_STMT_END_DATE IS NULL OR
3126 p_interface_rec.INCOME_STMT_END_DATE = FND_API.G_MISS_DATE
3127 THEN
3128 l_fin_rep_rec.REPORT_START_DATE := NULL;
3129 l_fin_rep_rec.REPORT_END_DATE := NULL;
3130 l_fin_rep_rec.ISSUED_PERIOD := NVL(
3131 NVL(
3132 TO_CHAR(p_interface_rec.INCOME_STMT_END_DATE),
3133 p_interface_rec.INCOME_STMT_DATE),
3134 TO_CHAR(SYSDATE,'YYYY') );
3135 ELSE
3136 l_fin_rep_rec.REPORT_START_DATE := p_interface_rec.INCOME_STMT_START_DATE;
3137 l_fin_rep_rec.REPORT_END_DATE := p_interface_rec.INCOME_STMT_END_DATE;
3138 l_fin_rep_rec.ISSUED_PERIOD := NULL;
3139 END IF;
3140
3141
3142
3143 ELSIF p_type_of_financial_report = 'TANGIBLE_NET_WORTH' THEN
3144 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: TANGIBLE_NET_WORTH');
3145 l_fin_rep_rec.type_of_financial_report := 'TANGIBLE_NET_WORTH';
3146
3147 IF p_interface_rec.TANGIBLE_NET_WORTH_IND = '1' THEN
3148 l_fin_rep_rec.ESTIMATED_IND := 'N';
3149 ELSIF p_interface_rec.TANGIBLE_NET_WORTH_IND = '2' THEN
3150 l_fin_rep_rec.ESTIMATED_IND := 'Y';
3151 END IF;
3152
3153 -- Bug 3539597.
3154 l_fin_rep_rec.REPORT_START_DATE := NULL;
3155 l_fin_rep_rec.REPORT_END_DATE := NULL;
3156 l_fin_rep_rec.ISSUED_PERIOD := NVL(TO_CHAR(p_interface_rec.STATEMENT_DATE),
3157 TO_CHAR(SYSDATE,'YYYY'));
3158
3159 ELSIF p_type_of_financial_report = 'ANNUAL_SALES_VOLUME' THEN
3160 arp_util.debug('HZ_MAP_PARTY_PUB.DO_MAP: ANNUAL_SALES_VOLUME');
3161 l_fin_rep_rec.type_of_financial_report := 'ANNUAL_SALES_VOLUME';
3162 l_fin_rep_rec.CONSOLIDATED_IND := p_interface_rec.ANNUAL_SALES_CONSOL_IND;
3163
3164 -- Bug 3539597.
3165 l_fin_rep_rec.REPORT_START_DATE := NULL;
3166 l_fin_rep_rec.REPORT_END_DATE := NULL;
3167 l_fin_rep_rec.ISSUED_PERIOD := NVL(TO_CHAR(p_interface_rec.STATEMENT_DATE),
3168 TO_CHAR(SYSDATE,'YYYY'));
3169
3170 END IF;
3171
3172
3173 /*Bug 3456205*/
3174 /* Commenting out changes made in initial fix for 3456205.
3175
3176 IF l_fin_rep_rec.REPORT_START_DATE is NULL
3177 OR l_fin_rep_rec.REPORT_START_DATE = FND_API.G_MISS_DATE
3178 THEN
3179 l_fin_rep_rec.REPORT_END_DATE := NULL;
3180 l_fin_rep_rec.ISSUED_PERIOD := 'Not Provided By DNB';
3181
3182 ELSIF l_fin_rep_rec.REPORT_END_DATE is NULL
3183 OR l_fin_rep_rec.REPORT_END_DATE = FND_API.G_MISS_DATE
3184 THEN
3185 l_fin_rep_rec.REPORT_START_DATE := NULL;
3186 l_fin_rep_rec.ISSUED_PERIOD := 'Not Provided By DNB';
3187
3188 ELSE
3189 l_fin_rep_rec.ISSUED_PERIOD := NULL;
3190 END IF;
3191 */
3192
3193 END do_assign_financial_report;
3194
3195 --
3196 -- Create party.
3197 --
3198 /*===========================================================================+
3199 | PROCEDURE
3200 | store_org
3201 |
3202 | DESCRIPTION
3203 | Store party and organization profile info.
3204 |
3205 | SCOPE - PRIVATE
3206 |
3207 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
3208 |
3209 | ARGUMENTS : IN:
3210 | OUT:
3211 | x_organization_profile_id
3212 | IN/ OUT:
3213 | p_organization_rec
3214 | x_return_status
3215 |
3216 | RETURNS : NONE
3217 |
3218 | NOTES
3219 |
3220 | MODIFICATION HISTORY
3221 |
3222 +===========================================================================*/
3223
3224 procedure store_org(
3225 p_organization_rec IN OUT NOCOPY HZ_PARTY_V2PUB.organization_rec_type,
3226 x_organization_profile_id OUT NOCOPY NUMBER,
3227 x_return_status IN OUT NOCOPY VARCHAR2
3228 ) IS
3229 l_msg_count NUMBER;
3230 l_msg_data VARCHAR2(2000);
3231 l_count NUMBER;
3232 l_object_version_number NUMBER;
3233
3234 l_profile VARCHAR2(1);
3235 l_exist VARCHAR2(1);
3236 l_mosr_mapping_exist VARCHAR2(1);
3237 l_ue_exist VARCHAR2(1);
3238 l_profile_obsolete_col VARCHAR2(1);
3239 l_party_id HZ_PARTIES.PARTY_ID%TYPE;
3240 l_party_number HZ_PARTIES.PARTY_NUMBER%TYPE;
3241
3242 CURSOR check_party_mosr_mapping (p_orig_system IN VARCHAR2,
3243 p_orig_system_ref IN VARCHAR2,
3244 p_owner_table_name IN VARCHAR2)
3245 IS
3246 select 'Y'
3247 from hz_orig_sys_references
3248 where orig_system = p_orig_system
3249 and orig_system_reference = p_orig_system_ref
3250 and owner_table_name = p_owner_table_name
3251 and status = 'A'
3252 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate);
3253
3254 BEGIN
3255
3256 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG (+) ');
3257
3258 IF p_organization_rec.party_rec.party_id IS NULL THEN
3259
3260 --
3261 --party does not exist. Create party.
3262 --
3263 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party does not exist');
3264
3265 l_exist := 'N';
3266 l_ue_exist := 'N';
3267
3268 ELSE
3269
3270 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party exists . party_id =' || to_char(p_organization_rec.party_rec.party_id));
3271
3272 BEGIN
3273
3274 SELECT 'Y' INTO l_ue_exist
3275 FROM hz_organization_profiles
3276 WHERE party_id = p_organization_rec.party_rec.party_id
3277 AND actual_content_source = HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE
3278 AND effective_end_date is null
3279 AND ROWNUM = 1;
3280
3281 EXCEPTION
3282 WHEN NO_DATA_FOUND THEN
3283 l_ue_exist := 'N';
3284 END;
3285
3286 BEGIN
3287
3288 SELECT 'Y' INTO l_exist
3289 FROM hz_organization_profiles
3290 WHERE party_id = p_organization_rec.party_rec.party_id
3291 AND actual_content_source = p_organization_rec.ACTUAL_CONTENT_SOURCE
3292 AND effective_end_date is null
3293 AND ROWNUM = 1;
3294
3295 EXCEPTION
3296 WHEN NO_DATA_FOUND THEN
3297 l_exist := 'N';
3298 END;
3299 END IF;
3300
3301 l_profile_obsolete_col := fnd_profile.value('HZ_API_ERR_ON_OBSOLETE_COLUMN');
3302 IF l_profile_obsolete_col = 'Y' THEN
3303 fnd_profile.put('HZ_API_ERR_ON_OBSOLETE_COLUMN', 'N');
3304 END IF;
3305
3306 IF l_exist = 'N' THEN
3307
3308 --
3309 --party exists. org profile does not. Create org profile
3310 --
3311
3312 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party exists, org profile does not exist ');
3313
3314 --Bug 1721094: generate party number by sequence.
3315 IF fnd_profile.value('HZ_GENERATE_PARTY_NUMBER') = 'N' THEN
3316 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'Y');
3317 l_profile := 'N';
3318 END IF;
3319
3320 p_organization_rec.application_id := 222;
3321 p_organization_rec.created_by_module := 'TCA_DNB_MAPPING';
3322 OPEN check_party_mosr_mapping ( 'DNB', p_organization_rec.DUNS_NUMBER_C, 'HZ_PARTIES');
3323 FETCH check_party_mosr_mapping into l_mosr_mapping_exist;
3324 IF l_mosr_mapping_exist = 'Y' THEN
3325 p_organization_rec.party_rec.orig_system := NULL;
3326 ELSE
3327 p_organization_rec.party_rec.orig_system := 'DNB';
3328 END IF;
3329 p_organization_rec.party_rec.orig_system_reference := p_organization_rec.DUNS_NUMBER_C;
3330
3331 HZ_PARTY_V2PUB.create_organization(
3332 'F',
3333 p_organization_rec,
3334 x_return_status,
3335 l_msg_count,
3336 l_msg_data,
3337 l_party_id,
3338 l_party_number,
3339 x_organization_profile_id);
3340 /* Bug Fix : 2770991 */
3341 IF l_party_id IS NOT NULL THEN
3342 p_organization_rec.party_rec.party_id := l_party_id;
3343 END IF;
3344 IF l_party_number IS NOT NULL THEN
3345 p_organization_rec.party_rec.party_number := l_party_number;
3346 END IF;
3347
3348 --Bug 1721094: reset profile option.
3349 IF l_profile = 'N' THEN
3350 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'N');
3351 END IF;
3352
3353 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party does not exist: created party with party_id =' || to_char(p_organization_rec.party_rec.party_id));
3354
3355 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3356 RETURN;
3357 END IF;
3358
3359 IF p_organization_rec.displayed_duns_party_id IS NULL THEN
3360 IF l_ue_exist = 'N' THEN
3361
3362 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party does not exist: update DNB and USER_ENTERED displayed_duns_party_id');
3363
3364 UPDATE hz_organization_profiles
3365 SET displayed_duns_party_id = p_organization_rec.party_rec.party_id
3366 WHERE party_id = p_organization_rec.party_rec.party_id AND
3367 effective_end_date is null;
3368 ELSE
3369 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party does not exist: update DNB displayed_duns_party_id');
3370 UPDATE hz_organization_profiles
3371 SET displayed_duns_party_id = p_organization_rec.party_rec.party_id
3372 WHERE party_id = p_organization_rec.party_rec.party_id AND
3373 actual_content_source = p_organization_rec.ACTUAL_CONTENT_SOURCE AND
3374 effective_end_date is null;
3375 END IF;
3376 END IF;
3377
3378 ELSE
3379
3380 --
3381 --party exists. org profile exists. Update it.
3382 --
3383
3384 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party exists, org profile exists ');
3385
3386 SELECT object_version_number INTO l_object_version_number
3387 FROM hz_parties
3388 WHERE party_id= p_organization_rec.party_rec.party_id;
3389 p_organization_rec.party_rec.orig_system := NULL;
3390 --p_organization_rec.party_rec.orig_system_reference := NULL;
3391 p_organization_rec.created_by_module := NULL;
3392 p_organization_rec.application_id := NULL;
3393
3394 HZ_PARTY_V2PUB.update_organization(
3395 'F',
3396 p_organization_rec,
3397 l_object_version_number,
3398 x_organization_profile_id,
3399 x_return_status,
3400 l_msg_count,
3401 l_msg_data);
3402
3403 END IF;
3404
3405 IF l_profile_obsolete_col = 'Y' THEN
3406 fnd_profile.put('HZ_API_ERR_ON_OBSOLETE_COLUMN', 'Y');
3407 END IF;
3408
3409 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG (-) ');
3410
3411 END store_org;
3412
3413
3414
3415 /*
3416 --
3417 -- populate to classification.
3418 --
3419 /*===========================================================================+
3420 | PROCEDURE
3421 | populate_to_classification
3422 |
3423 | DESCRIPTION
3424 | populate data to code assignment
3425 |
3426 |
3427 | SCOPE - PRIVATE
3428 |
3429 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
3430 |
3431 | ARGUMENTS : IN:
3432 |
3433 | OUT:
3434 | IN/ OUT:
3435 | p_code_assignment_rec
3436 | p_interface_rec
3437 | x_return_status
3438 |
3439 | RETURNS : NONE
3440 |
3441 | NOTES
3442 |
3443 | MODIFICATION HISTORY Kate Shan Created
3444 | 17-Feb-2004 Dhaval Mehta Bug 3346302 : Modified the class code assignment
3445 | for SIC type class categories.
3446 | 1. End date all those existing code assignments which
3447 | are not passed in updated data.
3448 | 2. If the existing primary class code is different
3449 | than sic_code1, make the existing one as non primary
3450 | and sic_code1 as primary.
3451 |
3452 +===========================================================================*/
3453
3454 procedure populate_to_classification(
3455 p_code_assignment_rec IN OUT NOCOPY hz_classification_v2pub.code_assignment_rec_type,
3456 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
3457 -- p_is_new_party IN BOOLEAN ,
3458 x_return_status IN OUT NOCOPY VARCHAR2
3459 ) IS
3460
3461 -- Bug 3397674 : Added local variables and cursor to pick existing code assignments for this party and sic_code_type.
3462
3463 l_msg_count NUMBER;
3464 l_msg_data VARCHAR2(2000);
3465 l_code_assignment_id NUMBER;
3466 l_object_version_number NUMBER;
3467
3468 CURSOR old_code_assignment IS
3469 select code_assignment_id, object_version_number
3470 from hz_code_assignments
3471 where
3472 owner_table_name = p_code_assignment_rec.owner_table_name AND
3473 owner_table_id = p_code_assignment_rec.owner_table_id AND
3474 class_category = p_code_assignment_rec.class_category AND
3475 --bug 4169070
3476 --content_source_type = p_code_assignment_rec.content_source_type AND
3477 actual_content_source = p_code_assignment_rec.actual_content_source AND
3478 class_code not in (
3479 /*nvl(SUBSTRB(replace(p_interface_rec.sic_code1, ' ', ''), 1, 4),FND_API.G_MISS_CHAR),
3480 nvl(SUBSTRB(replace(p_interface_rec.sic_code2, ' ', ''), 1, 4),FND_API.G_MISS_CHAR),
3481 nvl(SUBSTRB(replace(p_interface_rec.sic_code3, ' ', ''), 1, 4),FND_API.G_MISS_CHAR),
3482 nvl(SUBSTRB(replace(p_interface_rec.sic_code4, ' ', ''), 1, 4),FND_API.G_MISS_CHAR),
3483 nvl(SUBSTRB(replace(p_interface_rec.sic_code5, ' ', ''), 1, 4),FND_API.G_MISS_CHAR),
3484 nvl(SUBSTRB(replace(p_interface_rec.sic_code6, ' ', ''), 1, 4),FND_API.G_MISS_CHAR)
3485 */
3486 NVL(p_interface_rec.sic_code1,FND_API.G_MISS_CHAR),
3487 NVL(p_interface_rec.sic_code2,FND_API.G_MISS_CHAR),
3488 NVL(p_interface_rec.sic_code3,FND_API.G_MISS_CHAR),
3489 NVL(p_interface_rec.sic_code4,FND_API.G_MISS_CHAR),
3490 NVL(p_interface_rec.sic_code5,FND_API.G_MISS_CHAR),
3491 NVL(p_interface_rec.sic_code6,FND_API.G_MISS_CHAR)
3492 )
3493 AND
3494 -- (END_DATE_ACTIVE IS NULL OR (END_DATE_ACTIVE IS not NULL and trunc(END_DATE_ACTIVE) >= trunc(SYSDATE)));
3495 (END_DATE_ACTIVE IS NULL OR (END_DATE_ACTIVE IS not NULL and END_DATE_ACTIVE >= SYSDATE));
3496
3497 l_start_date date := sysdate + 1/(24*3600);
3498 l_end_date date := sysdate;
3499
3500 BEGIN
3501 --
3502 -- store classification
3503 --
3504 p_code_assignment_rec.code_assignment_id := null;
3505 p_code_assignment_rec.owner_table_name := 'HZ_PARTIES';
3506 p_code_assignment_rec.owner_table_id := p_interface_rec.party_id;
3507 p_code_assignment_rec.class_category := p_interface_rec.sic_code_type;
3508 --bug 4169070
3509 -- p_code_assignment_rec.content_source_type := NVL( p_interface_rec.content_source_type, HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE);
3510 p_code_assignment_rec.actual_content_source := NVL( p_interface_rec.content_source_type, HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE);
3511 p_code_assignment_rec.start_date_active := l_start_date;
3512 p_code_assignment_rec.primary_flag := 'N';
3513 p_code_assignment_rec.created_by_module := 'TCA_DNB_MAPPING';
3514
3515
3516 -- Change START for bug 3397674
3517
3518 IF p_code_assignment_rec.class_category IN ('1972', '1977', '1987') THEN
3519 p_code_assignment_rec.class_category := p_code_assignment_rec.class_category || ' SIC';
3520 END IF;
3521
3522
3523 IF p_code_assignment_rec.class_category IN ('1972 SIC', '1977 SIC', '1987 SIC') THEN
3524 p_code_assignment_rec.class_code := SUBSTRB(replace(p_code_assignment_rec.class_code, ' ', ''), 1, 4);
3525 END IF;
3526
3527 -- The below for loop will pick all code assignment records whose class code is
3528 -- not present in SIC_CODE1 to SIC_CODE6 in hz_party_interface for this party.
3529 -- It will end date all these code assignments because as per new data they
3530 -- are not valid and should not be active in TCA Registry.
3531
3532 FOR codes in old_code_assignment
3533 LOOP
3534 p_code_assignment_rec.code_assignment_id := codes.code_assignment_id;
3535 p_code_assignment_rec.primary_flag := NULL;
3536 p_code_assignment_rec.created_by_module := NULL;
3537 p_code_assignment_rec.application_id := NULL;
3538 p_code_assignment_rec.start_date_active := NULL;
3539 p_code_assignment_rec.end_date_active := l_end_date; -- sysdate - 1/(24*60*60); --bug4287144
3540 l_object_version_number := codes.object_version_number;
3541 HZ_CLASSIFICATION_V2PUB.update_code_assignment (
3542 p_code_assignment_rec => p_code_assignment_rec,
3543 p_object_version_number => l_object_version_number,
3544 x_return_status => x_return_status,
3545 x_msg_count => l_msg_count,
3546 x_msg_data => l_msg_data
3547 );
3548 END LOOP;
3549
3550 -- Below sql will check if the existing primary code for this party
3551 -- is same as SIC_CODE1 in hz_party_interface for this party.
3552 -- If the two codes are different, it will update the existing
3553 -- code assignment to Non-Primary as the party has another primary SIC code.
3554 BEGIN
3555 select code_assignment_id, object_version_number
3556 into l_code_assignment_id, l_object_version_number
3557 from hz_code_assignments
3558 where
3559 owner_table_name = p_code_assignment_rec.owner_table_name AND
3560 owner_table_id = p_code_assignment_rec.owner_table_id AND
3561 class_category = p_code_assignment_rec.class_category AND
3562 --bug 4169070
3563 --content_source_type = p_code_assignment_rec.content_source_type AND
3564 actual_content_source = p_code_assignment_rec.actual_content_source AND
3565 class_code <> nvl(p_interface_rec.sic_code1,FND_API.G_MISS_CHAR) AND
3566 primary_flag = 'Y' AND
3567 (END_DATE_ACTIVE IS NULL OR (END_DATE_ACTIVE IS not NULL and
3568 END_DATE_ACTIVE >= SYSDATE));
3569 --trunc(END_DATE_ACTIVE) >= trunc(SYSDATE))); --bug 4287144
3570
3571 p_code_assignment_rec.code_assignment_id := l_code_assignment_id;
3572 --p_code_assignment_rec.primary_flag := 'N';4287144
3573 p_code_assignment_rec.primary_flag := null;
3574 p_code_assignment_rec.created_by_module := NULL;
3575 p_code_assignment_rec.application_id := NULL;
3576 p_code_assignment_rec.start_date_active := NULL;
3577 --p_code_assignment_rec.end_date_active := NULL; 4287144
3578 p_code_assignment_rec.end_date_active := l_end_date; -- sysdate-1/(24*60*60);
3579
3580 HZ_CLASSIFICATION_V2PUB.update_code_assignment (
3581 p_code_assignment_rec => p_code_assignment_rec,
3582 p_object_version_number => l_object_version_number,
3583 x_return_status => x_return_status,
3584 x_msg_count => l_msg_count,
3585 x_msg_data => l_msg_data
3586 );
3587 EXCEPTION
3588 WHEN NO_DATA_FOUND THEN
3589 NULL;
3590 END;
3591
3592 -- Reinitialize the below columns before we process the SIC codes
3593 -- start_date_active should be sysdate
3594 -- primary flag should be 'Y'. It will be changed to 'N' for SIC_CODE2 to
3595 -- SIC_CODE6 if there is SIC_CODE1
3596 -- end_date_active should be null
3597 p_code_assignment_rec.start_date_active := l_start_date;
3598 p_code_assignment_rec.code_assignment_id := null;
3599 p_code_assignment_rec.primary_flag := 'Y';
3600 p_code_assignment_rec.end_date_active := NULL;
3601
3602 -- Change END for bug 3397674
3603
3604 IF p_interface_rec.sic_code1 IS NOT NULL AND
3605 p_interface_rec.content_source_type <> HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE THEN
3606
3607 p_code_assignment_rec.code_assignment_id := null;
3608 p_code_assignment_rec.class_code := p_interface_rec.sic_code1;
3609 p_code_assignment_rec.primary_flag := 'Y';
3610
3611 -- store content_source_type = 'DNB'
3612 --bug 4169070
3613 --p_code_assignment_rec.content_source_type := p_interface_rec.content_source_type;
3614 p_code_assignment_rec.actual_content_source := p_interface_rec.content_source_type;
3615 store_classification (
3616 p_code_assignment_rec => p_code_assignment_rec,
3617 x_return_status => x_return_status
3618 );
3619 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3620 RETURN;
3621 END IF;
3622
3623 /*
3624 IF p_is_new_party AND isMixNMatchEnabled = 'N' THEN
3625
3626 -- store content_source_type = 'USER ENTERED'
3627 p_code_assignment_rec.content_source_type := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
3628 store_classification (
3629 p_code_assignment_rec => p_code_assignment_rec,
3630 x_return_status => x_return_status
3631 );
3632 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3633 RETURN;
3634 END IF;
3635
3636 END IF;
3637 */
3638 END IF;
3639
3640
3641 IF p_interface_rec.sic_code2 IS NOT NULL THEN
3642
3643 p_code_assignment_rec.code_assignment_id := null;
3644 p_code_assignment_rec.class_code := p_interface_rec.sic_code2;
3645 IF p_interface_rec.sic_code1 IS NOT NULL THEN
3646 p_code_assignment_rec.primary_flag := 'N';
3647 END IF;
3648
3649 -- store content_source_type = 'DNB'
3650 --bug 4169070
3651 --p_code_assignment_rec.content_source_type := p_interface_rec.content_source_type;
3652 p_code_assignment_rec.actual_content_source := p_interface_rec.content_source_type;
3653 store_classification (
3654 p_code_assignment_rec => p_code_assignment_rec,
3655 x_return_status => x_return_status
3656 );
3657 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3658 RETURN;
3659 END IF;
3660 /*
3661 IF p_is_new_party AND isMixNMatchEnabled = 'N' THEN
3662
3663 -- store content_source_type = 'USER ENTERED'
3664 p_code_assignment_rec.content_source_type := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
3665 store_classification (
3666 p_code_assignment_rec => p_code_assignment_rec,
3667 x_return_status => x_return_status
3668 );
3669 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3670 RETURN;
3671 END IF;
3672 END IF;
3673 */
3674 END IF;
3675
3676 IF p_interface_rec.sic_code3 IS NOT NULL THEN
3677
3678 p_code_assignment_rec.code_assignment_id := null;
3679 p_code_assignment_rec.class_code := p_interface_rec.sic_code3;
3680 IF p_interface_rec.sic_code1 IS NOT NULL OR
3681 p_interface_rec.sic_code2 IS NOT NULL
3682 THEN
3683 p_code_assignment_rec.primary_flag := 'N';
3684 END IF;
3685
3686 -- store content_source_type = 'DNB'
3687 --bug 4169070
3688 --p_code_assignment_rec.content_source_type := p_interface_rec.content_source_type;
3689 p_code_assignment_rec.actual_content_source := p_interface_rec.content_source_type;
3690 store_classification (
3691 p_code_assignment_rec => p_code_assignment_rec,
3692 x_return_status => x_return_status
3693 );
3694 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3695 RETURN;
3696 END IF;
3697 /*
3698 IF p_is_new_party AND isMixNMatchEnabled = 'N' THEN
3699 -- store content_source_type = 'USER ENTERED'
3700 p_code_assignment_rec.content_source_type := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
3701 store_classification (
3702 p_code_assignment_rec => p_code_assignment_rec,
3703 x_return_status => x_return_status
3704 );
3705 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3706 RETURN;
3707 END IF;
3708 END IF;
3709 */
3710 END IF;
3711
3712 IF p_interface_rec.sic_code4 IS NOT NULL THEN
3713 p_code_assignment_rec.code_assignment_id := null;
3714 p_code_assignment_rec.class_code := p_interface_rec.sic_code4;
3715 IF p_interface_rec.sic_code1 IS NOT NULL OR
3716 p_interface_rec.sic_code2 IS NOT NULL OR
3717 p_interface_rec.sic_code3 IS NOT NULL
3718 THEN
3719 p_code_assignment_rec.primary_flag := 'N';
3720 END IF;
3721
3722 -- store content_source_type = 'DNB'
3723 --bug 4169070
3724 --p_code_assignment_rec.content_source_type := p_interface_rec.content_source_type;
3725 p_code_assignment_rec.actual_content_source := p_interface_rec.content_source_type;
3726 store_classification (
3727 p_code_assignment_rec => p_code_assignment_rec,
3728 x_return_status => x_return_status
3729 );
3730 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3731 RETURN;
3732 END IF;
3733 /*
3734 IF p_is_new_party AND isMixNMatchEnabled = 'N' THEN
3735 -- store content_source_type = 'USER ENTERED'
3736 p_code_assignment_rec.content_source_type := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
3737 store_classification (
3738 p_code_assignment_rec => p_code_assignment_rec,
3739 x_return_status => x_return_status
3740 );
3741 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3742 RETURN;
3743 END IF;
3744 END IF;
3745 */
3746 END IF;
3747
3748 IF p_interface_rec.sic_code5 IS NOT NULL THEN
3749 p_code_assignment_rec.code_assignment_id := null;
3750 p_code_assignment_rec.class_code := p_interface_rec.sic_code5;
3751 IF p_interface_rec.sic_code1 IS NOT NULL OR
3752 p_interface_rec.sic_code2 IS NOT NULL OR
3753 p_interface_rec.sic_code3 IS NOT NULL OR
3754 p_interface_rec.sic_code4 IS NOT NULL
3755 THEN
3756 p_code_assignment_rec.primary_flag := 'N';
3757 END IF;
3758
3759 -- store content_source_type = 'DNB'
3760 --bug 4169070
3761 --p_code_assignment_rec.content_source_type := p_interface_rec.content_source_type;
3762 p_code_assignment_rec.actual_content_source := p_interface_rec.content_source_type;
3763 store_classification (
3764 p_code_assignment_rec => p_code_assignment_rec,
3765 x_return_status => x_return_status
3766 );
3767 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3768 RETURN;
3769 END IF;
3770 /*
3771 IF p_is_new_party AND isMixNMatchEnabled = 'N' THEN
3772 -- store content_source_type = 'USER ENTERED'
3773 p_code_assignment_rec.content_source_type := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
3774 store_classification (
3775 p_code_assignment_rec => p_code_assignment_rec,
3776 x_return_status => x_return_status
3777 );
3778 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3779 RETURN;
3780 END IF;
3781 END IF;
3782 */
3783 END IF;
3784
3785
3786 IF p_interface_rec.sic_code6 IS NOT NULL THEN
3787 p_code_assignment_rec.code_assignment_id := null;
3788 p_code_assignment_rec.class_code := p_interface_rec.sic_code6;
3789 IF p_interface_rec.sic_code1 IS NOT NULL OR
3790 p_interface_rec.sic_code2 IS NOT NULL OR
3791 p_interface_rec.sic_code3 IS NOT NULL OR
3792 p_interface_rec.sic_code4 IS NOT NULL OR
3793 p_interface_rec.sic_code5 IS NOT NULL
3794 THEN
3795 p_code_assignment_rec.primary_flag := 'N';
3796 END IF;
3797
3798 -- store content_source_type = 'DNB'
3799 --bug 4169070
3800 --p_code_assignment_rec.content_source_type := p_interface_rec.content_source_type;
3801 p_code_assignment_rec.actual_content_source := p_interface_rec.content_source_type;
3802 store_classification (
3803 p_code_assignment_rec => p_code_assignment_rec,
3804 x_return_status => x_return_status
3805 );
3806 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3807 RETURN;
3808 END IF;
3809 /*
3810 IF p_is_new_party AND isMixNMatchEnabled = 'N' THEN
3811 -- store content_source_type = 'USER ENTERED'
3812 p_code_assignment_rec.content_source_type := HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE;
3813 store_classification (
3814 p_code_assignment_rec => p_code_assignment_rec,
3815 x_return_status => x_return_status
3816 );
3817 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3818 RETURN;
3819 END IF;
3820 END IF;
3821 */
3822 END IF;
3823 END populate_to_classification;
3824
3825 --
3826 -- create classification.
3827 --
3828 /*===========================================================================+
3829 | PROCEDURE
3830 | store_classification
3831 |
3832 | DESCRIPTION
3833 | create/update assignment code
3834 |
3835 |
3836 | SCOPE - PRIVATE
3837 |
3838 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
3839 |
3840 | ARGUMENTS : IN:
3841 |
3842 | OUT:
3843 | IN/ OUT:
3844 | p_code_assignment_rec
3845 | x_return_status
3846 |
3847 | RETURNS : NONE
3848 |
3849 | NOTES
3850 |
3851 | MODIFICATION HISTORY Kate Shan Created
3852 |
3853 +===========================================================================*/
3854
3855 procedure store_classification(
3856 p_code_assignment_rec IN OUT NOCOPY hz_classification_v2pub.code_assignment_rec_type,
3857 x_return_status IN OUT NOCOPY VARCHAR2
3858 ) IS
3859
3860 l_msg_count NUMBER;
3861 l_msg_data VARCHAR2(2000);
3862 l_code_assignment_id NUMBER;
3863 l_create BOOLEAN := FALSE;
3864 l_object_version_number NUMBER;
3865 l_code_assignment_rec hz_classification_v2pub.code_assignment_rec_type := p_code_assignment_rec;
3866 l_primary_flag VARCHAR2(1);
3867
3868
3869 BEGIN
3870
3871 /* update code assignment or create code assignment */
3872
3873 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION (+) ');
3874
3875 IF p_code_assignment_rec.class_category IN ('1972', '1977', '1987') THEN
3876 p_code_assignment_rec.class_category := p_code_assignment_rec.class_category || ' SIC';
3877 l_code_assignment_rec.class_category := p_code_assignment_rec.class_category;
3878 END IF;
3879
3880
3881 IF p_code_assignment_rec.class_category IN ('1972 SIC', '1977 SIC', '1987 SIC') THEN
3882 p_code_assignment_rec.class_code := SUBSTRB(replace(p_code_assignment_rec.class_code, ' ', ''), 1, 4);
3883 l_code_assignment_rec.class_code := p_code_assignment_rec.class_code;
3884 END IF;
3885
3886 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION : CONTENT_SOURCE_TYPE = ' || p_code_assignment_rec.CONTENT_SOURCE_TYPE);
3887 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION : l_code_assignment_rec.class_category = ' || l_code_assignment_rec.class_category);
3888 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION : l_code_assignment_rec.class_code = ' || l_code_assignment_rec.class_code);
3889 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION : l_code_assignment_rec.owner_table_id = ' || l_code_assignment_rec.owner_table_id);
3890
3891 BEGIN
3892 select code_assignment_id, object_version_number , primary_flag
3893 into l_code_assignment_id, l_object_version_number, l_primary_flag
3894 from hz_code_assignments
3895 where
3896 owner_table_name = l_code_assignment_rec.owner_table_name AND
3897 owner_table_id = l_code_assignment_rec.owner_table_id AND
3898 class_category = l_code_assignment_rec.class_category AND
3899 class_code = l_code_assignment_rec.class_code AND
3900 --bug 4169070
3901 --content_source_type = l_code_assignment_rec.content_source_type AND
3902 actual_content_source = l_code_assignment_rec.actual_content_source AND
3903 (END_DATE_ACTIVE IS NULL OR
3904 (END_DATE_ACTIVE IS not NULL and
3905 END_DATE_ACTIVE >= SYSDATE))
3906 --AND trunc(END_DATE_ACTIVE) >= trunc(SYSDATE)))
3907 AND rownum = 1; --bug 4287144: removed trunc
3908
3909 --
3910 --Code Assignment already exist. Only need to update Code Assignment
3911 --bug 4169070
3912 --IF p_code_assignment_rec.CONTENT_SOURCE_TYPE <> HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE THEN
3913
3914 --4287144
3915 --IF p_code_assignment_rec.CONTENT_SOURCE_TYPE <> HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE THEN
3916 IF (l_primary_flag <> p_code_assignment_rec.primary_flag) THEN
3917
3918 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION: Code Assignment already exist, code_assignment_id=' || to_char(l_code_assignment_id));
3919 l_code_assignment_rec.code_assignment_id := l_code_assignment_id;
3920 -- Bug 3397674 : the primary flag should be updated as per new data, instead
3921 -- of rataining it by l_primary_flag from above select statement.
3922 -- l_code_assignment_rec.primary_flag := l_primary_flag;
3923 --l_code_assignment_rec.primary_flag := p_code_assignment_rec.primary_flag;
3924 l_code_assignment_rec.primary_flag := null;
3925 l_code_assignment_rec.created_by_module := NULL;
3926 l_code_assignment_rec.application_id := NULL;
3927 -- Bug 3397674 : While updating, start_date_active should not be modified. make it NULL
3928 l_code_assignment_rec.start_date_active := NULL;
3929 l_code_assignment_rec.end_date_active := sysdate;
3930 HZ_CLASSIFICATION_V2PUB.update_code_assignment (
3931 p_code_assignment_rec => l_code_assignment_rec,
3932 p_object_version_number => l_object_version_number,
3933 x_return_status => x_return_status,
3934 x_msg_count => l_msg_count,
3935 x_msg_data => l_msg_data
3936 );
3937
3938 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3939 RETURN;
3940 END IF;
3941 l_create := TRUE;
3942 END IF;
3943 EXCEPTION
3944 WHEN NO_DATA_FOUND THEN
3945 l_create := TRUE;
3946 END;
3947
3948 IF l_create THEN
3949
3950 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CLASSIFICATION: No Code Assignment exists, create ' || p_code_assignment_rec.CONTENT_SOURCE_TYPE);
3951
3952 p_code_assignment_rec.application_id := 222;
3953 p_code_assignment_rec.created_by_module := 'TCA_DNB_MAPPING';
3954
3955 HZ_CLASSIFICATION_V2PUB.create_code_assignment(
3956 p_code_assignment_rec => p_code_assignment_rec,
3957 x_return_status => x_return_status,
3958 x_msg_count => l_msg_count,
3959 x_msg_data => l_msg_data,
3960 x_code_assignment_id => l_code_assignment_id
3961 );
3962
3963 END IF;
3964
3965 END store_classification;
3966
3967
3968
3969 --
3970 -- create location.
3971 --
3972 /*===========================================================================+
3973 | PROCEDURE
3974 | store_location
3975 |
3976 | DESCRIPTION
3977 | Update location or create/update party_site or
3978 | create location and party site
3979 |
3980 | SCOPE - PRIVATE
3981 |
3982 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
3983 |
3984 | ARGUMENTS : IN:
3985 | p_party_id
3986 | OUT:
3987 | IN/ OUT:
3988 | p_location_rec
3989 | x_return_status
3990 |
3991 | RETURNS : NONE
3992 |
3993 | NOTES
3994 |
3995 | MODIFICATION HISTORY
3996 |
3997 +===========================================================================*/
3998
3999 procedure store_location(
4000 p_location_rec IN OUT NOCOPY hz_location_v2pub.location_rec_type,
4001 p_party_id IN NUMBER,
4002 p_create_new IN BOOLEAN,
4003 x_return_status IN OUT NOCOPY VARCHAR2
4004 ) IS
4005 l_msg_count NUMBER;
4006 l_msg_data VARCHAR2(2000);
4007 l_object_version_number NUMBER;
4008 l_create BOOLEAN := FALSE;
4009 l_valid_tax_location VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
4010 l_party_site_id NUMBER;
4011
4012 -- Bug 2882305 : Local variable to store address1
4013
4014 l_address1 VARCHAR2(240);
4015 --4227564
4016 l_duns_number_c hz_organization_profiles.duns_number_c%type;
4017 l_orig_sys_reference_rec HZ_ORIG_SYSTEM_REF_PUB.orig_sys_reference_rec_type;
4018 l_count NUMBER;
4019 l_orig_sys_ref_id NUMBER;
4020 BEGIN
4021 --4227564
4022 l_duns_number_c := p_location_rec.orig_system_reference;
4023
4024 /* update location or create party_site or (create location and party site). */
4025
4026 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION (+) ');
4027 -- Bug 3417357 : if p_create_new = TRUE, we need to create new location
4028 IF p_create_new = TRUE or p_location_rec.actual_content_source = HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE THEN
4029 -- actual_content_source = "USER_ENTERED" , create new location and party site
4030 l_create := TRUE;
4031 ELSE
4032 -- actual_content_source = "DNB"
4033
4034 BEGIN
4035
4036 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION : actual_content_source = ' || p_location_rec.actual_content_source);
4037
4038 -- there is only one dnb party site record with end_date_active as null
4039
4040 -- Bug 2882305 : Add address1 to select statement
4041 SELECT ps.location_id, ps.party_site_id, loc.object_version_number,loc.address1
4042 INTO p_location_rec.location_id, l_party_site_id, l_object_version_number, l_address1
4043 FROM hz_party_sites ps, hz_locations loc
4044 WHERE ps.party_id = p_party_id
4045 AND ps.location_id = loc.location_id
4046 AND loc.actual_content_source = p_location_rec.actual_content_source
4047 AND ps.end_date_active is NULL
4048 -- Bug 3473497 : Added condition status='A' in where clause
4049 AND ps.status = 'A'
4050 AND rownum = 1;
4051
4052 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION: Location and party site already exist');
4053
4054 hz_registry_validate_v2pub.tax_location_validation(
4055 p_location_rec,
4056 'U',
4057 l_valid_tax_location );
4058 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION: l_valid_tax_location =' || l_valid_tax_location);
4059
4060 IF l_valid_tax_location <> fnd_api.g_ret_sts_error THEN
4061 -- if the existing location record has same taxable components, update this record
4062
4063 /* SELECT ps.location_id, loc.object_version_number
4064 INTO p_location_rec.location_id, l_object_version_number
4065 FROM hz_party_sites ps, hz_locations loc
4066 WHERE ps.party_id = p_party_id
4067 AND ps.location_id = loc.location_id
4068 AND loc.actual_content_source = p_location_rec.actual_content_source
4069 AND UPPER(loc.ADDRESS1 || loc.ADDRESS2 || loc.ADDRESS3 || loc.ADDRESS4 ||
4070 loc.CITY || loc.STATE || loc.COUNTY || loc.POSTAL_CODE || loc.PROVINCE) =
4071 UPPER( p_location_rec.ADDRESS1 || p_location_rec.ADDRESS2 || p_location_rec.ADDRESS3 || p_location_rec.ADDRESS4 ||
4072 p_location_rec.CITY || p_location_rec.STATE || p_location_rec.COUNTY ||
4073 p_location_rec.POSTAL_CODE || p_location_rec.PROVINCE )
4074 AND rownum =1;
4075 */
4076 --
4077 --Location and party site already exist. Only need to update location.
4078 --
4079
4080 --p_location_rec.orig_system_reference := NULL;
4081 p_location_rec.created_by_module := NULL;
4082 p_location_rec.application_id := NULL;
4083
4084
4085 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION: update Location and party site');
4086
4087 -- Bug 2882305 : Check if null is passed for address1, retain the previous address1.
4088
4089 if(p_location_rec.address1 = 'Not provided by DNB') then
4090 p_location_rec.address1 := l_address1;
4091 end if;
4092
4093 hz_location_v2pub.update_location(
4094 'F',
4095 p_location_rec,
4096 l_object_version_number,
4097 x_return_status,
4098 l_msg_count,
4099 l_msg_data);
4100
4101 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4102 RETURN;
4103 END IF;
4104 --4227564
4105 BEGIN
4106 SELECT hosr.orig_system_ref_id INTO l_orig_sys_ref_id
4107 FROM hz_orig_sys_references hosr
4108 WHERE hosr.orig_system = 'DNB'
4109 AND hosr.owner_table_name = 'HZ_PARTY_SITES'
4110 AND hosr.status='A'
4111 AND hosr.owner_table_id = l_party_site_id;
4112 EXCEPTION
4113 WHEN NO_DATA_FOUND THEN
4114 select count(1)
4115 into l_count
4116 from hz_orig_sys_references
4117 where owner_table_name = 'HZ_PARTY_SITES'
4118 and orig_system = 'DNB'
4119 and status = 'A'
4120 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate)
4121 and orig_system_reference like l_duns_number_c || '%';
4122 /* Bug Fix: 4305055 */
4123 l_orig_sys_reference_rec.orig_system_reference := l_duns_number_c || '-PS' || to_char(l_count + 1);
4124 l_orig_sys_reference_rec.orig_system := 'DNB';
4125 l_orig_sys_reference_rec.owner_table_name := 'HZ_PARTY_SITES';
4126 l_orig_sys_reference_rec.owner_table_id := l_party_site_id;
4127 l_orig_sys_reference_rec.start_date_active := sysdate;
4128 l_orig_sys_reference_rec.party_id := p_party_id;
4129 l_orig_sys_reference_rec.status := 'A';
4130 l_orig_sys_reference_rec.created_by_module := 'TCA_DNB_MAPPING';
4131
4132 hz_orig_system_ref_pub.create_orig_system_reference(
4133 FND_API.G_FALSE,
4134 l_orig_sys_reference_rec,
4135 x_return_status,
4136 l_msg_count,
4137 l_msg_data);
4138 if x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4139 RETURN;
4140 end if;
4141 END;
4142
4143 ELSE
4144 -- if the existing record has same taxable components, create a new location
4145 p_location_rec.location_id := null;
4146 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION: Location Tax Components changed, create new location');
4147 l_create := TRUE;
4148 END IF;
4149
4150 EXCEPTION
4151 WHEN NO_DATA_FOUND THEN
4152 l_create := TRUE;
4153 END;
4154 END IF;
4155
4156 IF l_create THEN
4157 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION: No party site exists for this party, create ' || p_location_rec.actual_content_source );
4158 -- Bug 3417357 : Pass p_create_new to do_store_location.
4159 do_store_location(
4160 p_location_rec,
4161 p_party_id,
4162 l_party_site_id,
4163 p_create_new,
4164 x_return_status
4165 );
4166 END IF;
4167
4168 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_LOCATION (-) ');
4169
4170
4171 END store_location; /* update location or create party_site or (create location and party site). */
4172
4173
4174 procedure do_store_location(
4175 p_location_rec IN OUT NOCOPY hz_location_v2pub.location_rec_type,
4176 p_party_id IN NUMBER,
4177 p_old_party_site_id IN NUMBER,
4178 p_create_new IN BOOLEAN,
4179 x_return_status IN OUT NOCOPY VARCHAR2
4180 ) IS
4181 l_party_site_rec HZ_PARTY_SITE_V2PUB.party_site_rec_type;
4182 l_msg_count NUMBER;
4183 l_msg_data VARCHAR2(2000);
4184 -- l_party_site_exist VARCHAR2(1) := 'N';
4185 l_location_id HZ_LOCATIONS.LOCATION_ID%TYPE;
4186
4187 BEGIN
4188 -- Bug 3417357 : If p_create_new = TRUE, its a new party. ALWAYS create a new
4189 -- location for new party. For party being enriched, if location is not chagned,
4190 -- donot do anything. Else update the location.
4191 IF p_create_new = TRUE THEN
4192 p_location_rec.application_id := 222;
4193 p_location_rec.created_by_module := 'TCA_DNB_MAPPING';
4194 /* Bug Fix : 2770991 */
4195 hz_location_v2pub.create_location(
4196 'F',
4197 p_location_rec,
4198 l_location_id,
4199 x_return_status,
4200 l_msg_count,
4201 l_msg_data
4202 );
4203 IF l_location_id IS NOT NULL THEN
4204 p_location_rec.location_id := l_location_id;
4205 END IF;
4206 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4207 RETURN;
4208 END IF;
4209 ELSE
4210 BEGIN
4211 --use decode function for address2, etc. because we already assigned
4212 --G_MISS_XXX to those columns.
4213 --select by UPPER(ADDRESS1) to prevent dulicate.
4214 SELECT location_id INTO p_location_rec.location_id
4215 FROM hz_locations
4216 WHERE UPPER(ADDRESS1) = UPPER(p_location_rec.ADDRESS1) AND
4217 UPPER(NVL(ADDRESS2, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.ADDRESS2, NULL, FND_API.G_MISS_CHAR, p_location_rec.ADDRESS2)) AND
4218 UPPER(NVL(ADDRESS3, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.ADDRESS3, NULL, FND_API.G_MISS_CHAR, p_location_rec.ADDRESS3)) AND
4219 UPPER(NVL(ADDRESS4, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.ADDRESS4, NULL, FND_API.G_MISS_CHAR, p_location_rec.ADDRESS4)) AND
4220 UPPER(NVL(CITY, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.CITY, NULL, FND_API.G_MISS_CHAR, p_location_rec.CITY)) AND
4221 UPPER(NVL(STATE, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.STATE, NULL, FND_API.G_MISS_CHAR, p_location_rec.STATE)) AND
4222 UPPER(NVL(COUNTY, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.COUNTY, NULL, FND_API.G_MISS_CHAR, p_location_rec.COUNTY)) AND
4223 UPPER(NVL(POSTAL_CODE, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.POSTAL_CODE, NULL, FND_API.G_MISS_CHAR, p_location_rec.POSTAL_CODE)) AND
4224 UPPER(COUNTRY) = UPPER(p_location_rec.COUNTRY) AND
4225 UPPER(NVL(PROVINCE, FND_API.G_MISS_CHAR)) = UPPER(decode(p_location_rec.PROVINCE, NULL, FND_API.G_MISS_CHAR, p_location_rec.PROVINCE)) AND
4226 actual_content_source = p_location_rec.actual_content_source AND
4227 rownum =1;
4228
4229 EXCEPTION WHEN NO_DATA_FOUND THEN
4230
4231 --
4232 --Location does not exist.
4233 --
4234
4235 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_LOCATION: No party site exists for this party: Location does not exist');
4236 --arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_LOCATION: p_location_rec.ORIG_SYSTEM_REFERENCE=' || p_location_rec.ORIG_SYSTEM_REFERENCE);
4237 --arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_LOCATION: p_location_rec.actual_content_source =' || p_location_rec.actual_content_source);
4238
4239 p_location_rec.application_id := 222;
4240 p_location_rec.created_by_module := 'TCA_DNB_MAPPING';
4241 /* Bug Fix : 2770991 */
4242 hz_location_v2pub.create_location(
4243 'F',
4244 p_location_rec,
4245 l_location_id,
4246 x_return_status,
4247 l_msg_count,
4248 l_msg_data
4249 );
4250 IF l_location_id IS NOT NULL THEN
4251 p_location_rec.location_id := l_location_id;
4252 END IF;
4253
4254 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_LOCATION: created location with location_id '|| to_char(p_location_rec.location_id));
4255
4256 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4257 RETURN;
4258 END IF;
4259
4260 END;
4261 END IF;
4262
4263 l_party_site_rec.party_id := p_party_id;
4264 l_party_site_rec.location_id := p_location_rec.location_id;
4265 l_party_site_rec.orig_system_reference := p_location_rec.orig_system_reference;
4266 l_party_site_rec.orig_system := 'DNB';
4267 /*
4268 BEGIN
4269
4270 SELECT 'Y' INTO l_party_site_exist
4271 FROM HZ_PARTY_SITES
4272 WHERE location_id = p_location_rec.location_id
4273 AND party_id = p_party_id
4274 AND actual_content_source = p_location_rec.actual_content_source
4275 AND status = 'A'
4276 AND (SYSDATE BETWEEN START_DATE_ACTIVE AND NVL(END_DATE_ACTIVE, to_date('12/31/4712','MM/DD/YYYY')))
4277 AND ROWNUM = 1;
4278
4279 arp_util.debug(' l_party_site_exist = '|| l_party_site_exist );
4280
4281 EXCEPTION WHEN NO_DATA_FOUND THEN
4282 */
4283 store_party_site(l_party_site_rec,
4284 x_return_status);
4285
4286 -- if there is old party site record, end it.
4287 IF p_old_party_site_id IS NOT NULL THEN
4288 UPDATE hz_party_sites SET END_DATE_ACTIVE = sysdate , status = 'I' WHERE party_site_id = p_old_party_site_id;
4289 END IF;
4290 -- END;
4291 END do_store_location;
4292
4293
4294
4295 procedure store_party_site(
4296 p_party_site_rec IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_rec_type,
4297 x_return_status IN OUT NOCOPY VARCHAR2
4298 ) IS
4299 l_msg_count NUMBER;
4300 l_msg_data VARCHAR2(2000);
4301
4302 l_profile VARCHAR2(1);
4303 l_mosr_mapping_exist VARCHAR2(1);
4304 l_party_site_id HZ_PARTY_SITES.PARTY_SITE_ID%TYPE;
4305 l_party_site_number HZ_PARTY_SITES.PARTY_SITE_NUMBER%TYPE;
4306 l_count NUMBER;
4307 l_duns_number_c hz_organization_profiles.duns_number_c%TYPE;
4308
4309 CURSOR check_party_site_mosr_mapping (p_orig_system IN VARCHAR2,
4310 p_orig_system_ref IN VARCHAR2,
4311 p_owner_table_name IN VARCHAR2)
4312 IS
4313 select 'Y'
4314 from hz_orig_sys_references
4315 where orig_system = p_orig_system
4316 and orig_system_reference = p_orig_system_ref
4317 and owner_table_name = p_owner_table_name
4318 and status = 'A'
4319 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate);
4320
4321 BEGIN
4322
4323 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_PARTY_SITE (+) ');
4324
4325 --Bug 1721094: generate party site number by sequence.
4326 IF fnd_profile.value('HZ_GENERATE_PARTY_SITE_NUMBER') = 'N' THEN
4327 fnd_profile.put('HZ_GENERATE_PARTY_SITE_NUMBER', 'Y');
4328 l_profile := 'N';
4329 END IF;
4330
4331 --MOSR changes
4332 --Increment the orig_system_reference counter
4333 IF ( instrb ( p_party_site_rec.orig_system_reference, 'PS', 1, 1) <> 0) THEN
4334 --get the duns_number_c from orig_system_reference
4335 l_duns_number_c :=
4336 substrb(p_party_site_rec.orig_system_reference, 0,
4337 instrb(p_party_site_rec.orig_system_reference, 'PS', 1 ,1)-1);
4338 ELSE
4339 l_duns_number_c := p_party_site_rec.orig_system_reference;
4340 END IF;
4341
4342 select count(1)
4343 into l_count
4344 from hz_orig_sys_references
4345 where owner_table_name = 'HZ_PARTY_SITES'
4346 and orig_system = 'DNB'
4347 and status = 'A'
4348 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate)
4349 and orig_system_reference like l_duns_number_c || '%';
4350 /* Bug Fix: 4305055 */
4351 p_party_site_rec.orig_system_reference := l_duns_number_c || '-PS' || to_char(l_count + 1);
4352
4353 open check_party_site_mosr_mapping ( 'DNB', p_party_site_rec.orig_system_reference, 'HZ_PARTY_SITES');
4354 FETCH check_party_site_mosr_mapping into l_mosr_mapping_exist;
4355 IF l_mosr_mapping_exist = 'Y' THEN
4356 p_party_site_rec.orig_system := NULL;
4357 ELSE
4358 p_party_site_rec.orig_system := 'DNB';
4359 END IF;
4360 p_party_site_rec.created_by_module := 'TCA_DNB_MAPPING';
4361 p_party_site_rec.application_id := 222;
4362 /* Bug Fix : 2770991 */
4363 HZ_PARTY_SITE_V2PUB.create_party_site(
4364 'F',
4365 p_party_site_rec,
4366 l_party_site_id,
4367 l_party_site_number,
4368 x_return_status,
4369 l_msg_count,
4370 l_msg_data
4371 );
4372 IF l_party_site_id IS NOT NULL THEN
4373 p_party_site_rec.party_site_id := l_party_site_id;
4374 END IF;
4375 IF l_party_site_number IS NOT NULL THEN
4376 p_party_site_rec.party_site_number := l_party_site_number;
4377 END IF;
4378
4379 --Bug 1721094: reset profile option.
4380 IF l_profile = 'N' THEN
4381 fnd_profile.put('HZ_GENERATE_PARTY_SITE_NUMBER', 'N');
4382 END IF;
4383
4384 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_PARTY_SITE: created party site with party_site_id '|| to_char(p_party_site_rec.party_site_id));
4385 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_PARTY_SITE (-) ');
4386
4387
4388 END store_party_site;
4389
4390
4391 --
4392 -- For Phone and Fax
4393 --
4394 /*===========================================================================+
4395 | PROCEDURE
4396 | store_contact_point
4397 |
4398 | DESCRIPTION
4399 | store contact point
4400 |
4401 | SCOPE - PRIVATE
4402 |
4403 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
4404 |
4405 | ARGUMENTS : IN:
4406 | OUT:
4407 | IN/ OUT:
4408 | p_contact_points_rec
4409 | p_phone_rec
4410 | x_return_status
4411 |
4412 | RETURNS : NONE
4413 |
4414 | NOTES
4415 |
4416 | MODIFICATION HISTORY
4417 |
4418 +===========================================================================*/
4419
4420 procedure store_contact_point(
4421 p_contact_points_rec IN OUT NOCOPY hz_contact_point_v2pub.contact_point_rec_type,
4422 p_phone_rec IN OUT NOCOPY hz_contact_point_v2pub.phone_rec_type,
4423 x_return_status IN OUT NOCOPY VARCHAR2
4424 ) IS
4425 l_edi_rec hz_contact_point_v2pub.edi_rec_type := HZ_CONTACT_POINT_v2PUB.G_MISS_EDI_REC;
4426 l_email_rec hz_contact_point_v2pub.email_rec_type := HZ_CONTACT_POINT_v2PUB.G_MISS_EMAIL_REC;
4427 l_telex_rec hz_contact_point_v2pub.telex_rec_type := HZ_CONTACT_POINT_v2PUB.G_MISS_TELEX_REC;
4428 l_web_rec hz_contact_point_v2pub.web_rec_type := HZ_CONTACT_POINT_v2PUB.G_MISS_WEB_REC;
4429
4430 l_mosr_mapping_exist VARCHAR2(1);
4431 l_msg_count NUMBER;
4432 l_msg_data VARCHAR2(2000);
4433 l_object_version_number NUMBER;
4434 l_contact_point_id NUMBER;
4435 l_create BOOLEAN := FALSE;
4436 l_count NUMBER;
4437 l_orig_system_reference hz_orig_sys_references.orig_system_reference%TYPE;
4438 l_duns_number_c hz_organization_profiles.duns_number_c%TYPE;
4439 --4227564
4440 l_orig_sys_reference_rec HZ_ORIG_SYSTEM_REF_PUB.orig_sys_reference_rec_type;
4441 l_orig_sys_ref_id NUMBER;
4442
4443 CURSOR check_cont_point_mosr_mapping (p_orig_system IN VARCHAR2,
4444 p_orig_system_ref IN VARCHAR2,
4445 p_owner_table_name IN VARCHAR2)
4446 IS
4447 select 'Y'
4448 from hz_orig_sys_references
4449 where orig_system = p_orig_system
4450 and orig_system_reference = p_orig_system_ref
4451 and owner_table_name = p_owner_table_name
4452 and status = 'A'
4453 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate);
4454 BEGIN
4455
4456 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT (+) ');
4457
4458 p_contact_points_rec.contact_point_type := 'PHONE';
4459 p_contact_points_rec.owner_table_name := 'HZ_PARTIES';
4460 p_contact_points_rec.contact_point_id := NULL; --Reset it.
4461
4462 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT: actual_content_source = ' || p_contact_points_rec.actual_content_source);
4463
4464 --4227564: initialize l_duns_number_c
4465 IF ( instrb ( p_contact_points_rec.orig_system_reference, 'CP', 1, 1) <> 0) THEN
4466 --get the duns_number_c from orig_system
4467 l_duns_number_c :=
4468 substrb(p_contact_points_rec.orig_system_reference, 0,
4469 instrb(p_contact_points_rec.orig_system_reference, '-CP', 1 ,1)-1);
4470 ELSE
4471 l_duns_number_c := p_contact_points_rec.orig_system_reference;
4472 END IF;
4473
4474 select count(1)
4475 into l_count
4476 from hz_orig_sys_references
4477 where owner_table_name = 'HZ_CONTACT_POINTS'
4478 and orig_system = 'DNB'
4479 and status = 'A'
4480 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate)
4481 and orig_system_reference like l_duns_number_c || '%';
4482
4483 BEGIN
4484 -- Bug 6002398. Modified query logic.
4485 SELECT contact_point_id, object_version_number, orig_system_reference
4486 INTO p_contact_points_rec.contact_point_id, l_object_version_number, l_orig_system_reference
4487 FROM
4488 ( SELECT contact_point_id, object_version_number, orig_system_reference,rank() over (
4489 partition by owner_table_id order by last_update_date desc,object_version_number desc,contact_point_id desc) r
4490 FROM hz_contact_points hcp
4491 WHERE owner_table_name = 'HZ_PARTIES'
4492 AND owner_table_id = p_contact_points_rec.owner_table_id
4493 AND contact_point_type = 'PHONE'
4494 AND phone_line_type = p_phone_rec.PHONE_LINE_TYPE
4495 AND actual_content_source = p_contact_points_rec.actual_content_source
4496 AND status = 'A'
4497 )
4498 WHERE r=1;
4499 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT: contact point exists, contact_point_id =' || to_char(p_contact_points_rec.contact_point_id));
4500
4501 IF p_contact_points_rec.actual_content_source <> HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE THEN
4502 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT: update contact point');
4503
4504 p_contact_points_rec.orig_system := NULL;
4505 p_contact_points_rec.orig_system_reference := l_orig_system_reference;
4506 p_contact_points_rec.created_by_module := NULL;
4507 p_contact_points_rec.application_id := NULL;
4508 hz_contact_point_v2pub.update_contact_point(
4509 'F',
4510 p_contact_points_rec,
4511 l_edi_rec,
4512 l_email_rec,
4513 p_phone_rec,
4514 l_telex_rec,
4515 l_web_rec,
4516 l_object_version_number,
4517 x_return_status,
4518 l_msg_count,
4519 l_msg_data);
4520
4521 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4522 RETURN;
4523 END IF;
4524 --4227564
4525 BEGIN
4526 SELECT hosr.orig_system_ref_id INTO l_orig_sys_ref_id
4527 FROM hz_orig_sys_references hosr
4528 WHERE hosr.orig_system = 'DNB'
4529 AND hosr.owner_table_name = 'HZ_CONTACT_POINTS'
4530 AND hosr.status='A'
4531 AND hosr.owner_table_id = p_contact_points_rec.contact_point_id;
4532 EXCEPTION
4533 WHEN NO_DATA_FOUND THEN
4534 /* Bug Fix: 4305055 */
4535 IF p_phone_rec.phone_line_type = 'GEN' THEN
4536 l_orig_sys_reference_rec.orig_system_reference := l_duns_number_c || '-CP-P'||to_char(l_count + 1);
4537 ELSE
4538 l_orig_sys_reference_rec.orig_system_reference := l_duns_number_c || '-CP-F'||to_char(l_count + 1);
4539 END IF;
4540 l_orig_sys_reference_rec.orig_system := 'DNB';
4541 l_orig_sys_reference_rec.owner_table_name := 'HZ_CONTACT_POINTS';
4542 l_orig_sys_reference_rec.owner_table_id := p_contact_points_rec.contact_point_id;
4543 l_orig_sys_reference_rec.start_date_active := sysdate;
4544 l_orig_sys_reference_rec.party_id := p_contact_points_rec.owner_table_id;
4545 l_orig_sys_reference_rec.status := 'A';
4546 l_orig_sys_reference_rec.created_by_module := 'TCA_DNB_MAPPING';
4547
4548
4549 hz_orig_system_ref_pub.create_orig_system_reference(
4550 FND_API.G_FALSE,
4551 l_orig_sys_reference_rec,
4552 x_return_status,
4553 l_msg_count,
4554 l_msg_data);
4555 if x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4556 RETURN;
4557 end if;
4558 END;
4559 END IF;
4560 EXCEPTION
4561 WHEN NO_DATA_FOUND THEN
4562 l_create := TRUE;
4563 END;
4564
4565 IF l_create THEN
4566 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT: contact point does not exist');
4567
4568 --MOSR Changes
4569 --Increment the orig_system_reference counter
4570 --4227564: Moved this code to beginning of the procedure.
4571 /*IF ( instrb ( p_contact_points_rec.orig_system_reference, 'CP', 1, 1) <> 0) THEN
4572 --get the duns_number_c from orig_system
4573 l_duns_number_c :=
4574 substrb(p_contact_points_rec.orig_system_reference, 0,
4575 instrb(p_contact_points_rec.orig_system_reference, 'CP', 1 ,1)-1);
4576 ELSE
4577 l_duns_number_c := p_contact_points_rec.orig_system_reference;
4578
4579 END IF;
4580
4581 select count(1)
4582 into l_count
4583 from hz_orig_sys_references
4584 where owner_table_name = 'HZ_CONTACT_POINTS'
4585 and orig_system = 'DNB'
4586 and status = 'A'
4587 and trunc(nvl(end_date_active, sysdate)) >= trunc(sysdate)
4588 and orig_system_reference like l_duns_number_c || '%';*/
4589
4590 IF p_phone_rec.PHONE_LINE_TYPE = 'GEN'
4591 THEN
4592 p_contact_points_rec.orig_system_reference := l_duns_number_c || '-CP' || '-P' || to_char(l_count + 1);
4593 ElSIF p_phone_rec.PHONE_LINE_TYPE = 'FAX' AND p_phone_rec.RAW_PHONE_NUMBER IS NOT NULL THEN
4594 p_contact_points_rec.orig_system_reference := l_duns_number_c || '-CP' || '-F' || to_char(l_count + 1);
4595 END IF;
4596
4597 open check_cont_point_mosr_mapping ( 'DNB', p_contact_points_rec.orig_system_reference, 'HZ_CONTACT_POINTS');
4598 fetch check_cont_point_mosr_mapping into l_mosr_mapping_exist;
4599 IF l_mosr_mapping_exist = 'Y' THEN
4600 p_contact_points_rec.orig_system := NULL;
4601 ELSE
4602 p_contact_points_rec.orig_system := 'DNB';
4603 END IF;
4604
4605 p_contact_points_rec.application_id := 222;
4606 p_contact_points_rec.created_by_module := 'TCA_DNB_MAPPING';
4607 hz_contact_point_v2pub.create_contact_point(
4608 'F',
4609 p_contact_points_rec,
4610 l_edi_rec,
4611 l_email_rec,
4612 p_phone_rec,
4613 l_telex_rec,
4614 l_web_rec,
4615 l_contact_point_id,
4616 x_return_status,
4617 l_msg_count,
4618 l_msg_data);
4619
4620 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4621 RETURN;
4622 END IF;
4623
4624 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT: created contact point, contact_point_id = ' || l_contact_point_id);
4625
4626 END IF;
4627
4628 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CONTACT_POINT (-) ');
4629
4630 END store_contact_point;
4631
4632
4633
4634 --
4635 -- Create credit ratings.
4636 --
4637 /*===========================================================================+
4638 | PROCEDURE
4639 | store_credit_ratings
4640 |
4641 | DESCRIPTION
4642 | store credit ratings
4643 |
4644 | SCOPE - PRIVATE
4645 |
4646 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
4647 |
4648 | ARGUMENTS : IN:
4649 | OUT:
4650 | IN/ OUT:
4651 | p_credit_ratings_rec
4652 | x_return_status
4653 |
4654 | RETURNS : NONE
4655 |
4656 | NOTES
4657 |
4658 | MODIFICATION HISTORY
4659 |
4660 +===========================================================================*/
4661
4662 procedure store_credit_ratings(
4663 --p_credit_ratings_rec IN OUT NOCOPY hz_party_info_pub.credit_ratings_rec_type,
4664 p_credit_ratings_rec IN OUT NOCOPY hz_party_info_v2pub.credit_rating_rec_type,
4665 x_return_status IN OUT NOCOPY VARCHAR2
4666 ) IS
4667 l_rated_as_of_date DATE;
4668 l_max_rated_as_of_date DATE;
4669 l_credit_rating_id NUMBER;
4670 l_msg_count NUMBER;
4671 l_msg_data VARCHAR2(2000);
4672 l_last_update_date1 DATE;
4673 l_create_credit_rating BOOLEAN := FALSE;
4674 l_ovn NUMBER;
4675
4676 BEGIN
4677
4678 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS (+) ' );
4679 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS actual_content_source = ' || p_credit_ratings_rec.actual_content_source );
4680 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS party_id = ' || p_credit_ratings_rec.party_id );
4681
4682 BEGIN
4683
4684 SELECT MAX(rated_as_of_date)
4685 INTO l_max_rated_as_of_date
4686 FROM hz_credit_ratings
4687 WHERE party_id = p_credit_ratings_rec.party_id
4688 AND actual_content_source = p_credit_ratings_rec.actual_content_source;
4689
4690 SELECT rated_as_of_date, credit_rating_id, last_update_date, object_version_number
4691 INTO l_rated_as_of_date, l_credit_rating_id, l_last_update_date1, l_ovn
4692 FROM hz_credit_ratings
4693 WHERE party_id = p_credit_ratings_rec.party_id
4694 AND actual_content_source = p_credit_ratings_rec.actual_content_source
4695 AND NVL(rated_as_of_date, TO_DATE('31-12-4712', 'DD-MM-YYYY'))=
4696 NVL(l_max_rated_as_of_date, TO_DATE('31-12-4712', 'DD-MM-YYYY'))
4697 AND rownum = 1;
4698
4699 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS: credit rating record exists');
4700
4701
4702 IF trunc(l_rated_as_of_date) = trunc(sysdate) THEN
4703
4704 p_credit_ratings_rec.credit_rating_id := l_credit_rating_id;
4705 -- p_credit_ratings_rec.actual_content_source := null;
4706
4707 p_credit_ratings_rec.created_by_module := NULL;
4708 HZ_PARTY_INFO_V2PUB.update_credit_rating(
4709 'F',
4710 p_credit_ratings_rec,
4711 l_ovn,
4712 x_return_status,
4713 l_msg_count,
4714 l_msg_data);
4715 /*
4716 hz_party_info_pub.update_credit_ratings(
4717 1,
4718 'F',
4719 'F',
4720 p_credit_ratings_rec,
4721 l_last_update_date1,
4722 x_return_status,
4723 l_msg_count,
4724 l_msg_data);
4725 */
4726
4727 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4728 RETURN;
4729 END IF;
4730
4731 ELSE
4732 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS: the existing credit rating record is not in the same day as the new one');
4733 l_create_credit_rating := TRUE;
4734 END IF;
4735
4736 EXCEPTION
4737 WHEN NO_DATA_FOUND THEN
4738 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS: credit rating record not exist');
4739 l_create_credit_rating := TRUE;
4740 END;
4741
4742 IF l_create_credit_rating THEN
4743 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS: creating credit rating record ');
4744
4745 p_credit_ratings_rec.created_by_module := 'TCA_DNB_MAPPING';
4746 HZ_PARTY_INFO_V2PUB.create_credit_rating(
4747 'F',
4748 p_credit_ratings_rec,
4749 p_credit_ratings_rec.credit_rating_id,
4750 x_return_status,
4751 l_msg_count,
4752 l_msg_data);
4753 /*
4754 hz_party_info_pub.create_credit_ratings(
4755 1,
4756 'F',
4757 'F',
4758 p_credit_ratings_rec,
4759 x_return_status,
4760 l_msg_count,
4761 l_msg_data,
4762 p_credit_ratings_rec.credit_rating_id);
4763 */
4764 END IF;
4765
4766 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_CREDIT_RATINGS (-) ');
4767
4768 END store_credit_ratings;
4769
4770 --
4771 -- Create Financial Reports.
4772 --
4773 /*===========================================================================+
4774 | PROCEDURE
4775 | do_store_financial_report
4776 |
4777 | DESCRIPTION
4778 | store financial report
4779 |
4780 | SCOPE - PRIVATE
4781 |
4782 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
4783 |
4784 | ARGUMENTS : IN:
4785 | OUT:
4786 | x_new_fin_report
4787 | IN/ OUT:
4788 | p_fin_rep_rec
4789 | x_return_status
4790 |
4791 | RETURNS : NONE
4792 |
4793 | NOTES
4794 |
4795 | MODIFICATION HISTORY
4796 |
4797 +===========================================================================*/
4798
4799 procedure do_store_financial_report(
4800 p_fin_rep_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.financial_report_rec_type,
4801 --p_fin_rep_rec IN OUT NOCOPY hz_org_info_pub.financial_reports_rec_type,
4802 x_new_fin_report OUT NOCOPY VARCHAR2,
4803 x_return_status IN OUT NOCOPY VARCHAR2
4804 ) IS
4805 l_msg_count NUMBER;
4806 l_msg_data VARCHAR2(2000);
4807 l_last_update_date1 DATE;
4808 l_create BOOLEAN := FALSE;
4809 l_ovn NUMBER;
4810 BEGIN
4811
4812 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_REPORT (+) ');
4813 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_REPORT actual_content_source = ' || p_fin_rep_rec.actual_content_source );
4814
4815
4816 BEGIN
4817 SELECT financial_report_id, last_update_date, object_version_number
4818 INTO p_fin_rep_rec.financial_report_id, l_last_update_date1, l_ovn
4819 FROM hz_financial_reports
4820 WHERE party_id = p_fin_rep_rec.party_id
4821 AND ACTUAL_CONTENT_SOURCE = p_fin_rep_rec.ACTUAL_CONTENT_SOURCE
4822
4823 -- Bug 3202840 : User trunc while checking for DATE_REPORT_ISSED so that if it is purchased on
4824 -- same day, the report gets updated.
4825 -- Bug 3223038 : Modify NVL conditions for columns DATE_REPORT_ISSUED, REPORT_START_DATE
4826 -- REPORT_END_DATE and ISSUED_PERIOD.
4827
4828 AND (NVL(trunc(DATE_REPORT_ISSUED), to_date('12/30/4712','MM/DD/YYYY'))
4829 = NVL(trunc(p_fin_rep_rec.DATE_REPORT_ISSUED), to_date('12/31/4712','MM/DD/YYYY'))
4830
4831 OR (NVL(REPORT_START_DATE, to_date('12/30/4712','MM/DD/YYYY'))
4832 = NVL(p_fin_rep_rec.REPORT_START_DATE, to_date('12/31/4712','MM/DD/YYYY'))
4833 AND NVL(REPORT_END_DATE, to_date('12/30/4712','MM/DD/YYYY'))
4834 = NVL(p_fin_rep_rec.REPORT_END_DATE, to_date('12/31/4712','MM/DD/YYYY')))
4835 OR NVL(ISSUED_PERIOD, 'Y') = NVL(p_fin_rep_rec.ISSUED_PERIOD, 'X'))
4836 AND NVL(TYPE_OF_FINANCIAL_REPORT, 'X') = NVL(p_fin_rep_rec.TYPE_OF_FINANCIAL_REPORT, 'X')
4837 AND rownum=1;
4838
4839 x_new_fin_report := 'N';
4840
4841 -- Bug 3223038 : Pass NULL for the non updatable columns while updating the report
4842 -- For relationships, V1 API is used, so pass G_MISS values when
4843 -- we want to retain the previous values.
4844
4845 /* Bug 4507494 : Pass NULL for non updatable columns
4846 p_fin_rep_rec.DATE_REPORT_ISSUED := FND_API.G_MISS_DATE;
4847 p_fin_rep_rec.REPORT_START_DATE := FND_API.G_MISS_DATE;
4848 p_fin_rep_rec.REPORT_END_DATE := FND_API.G_MISS_DATE;
4849 p_fin_rep_rec.ISSUED_PERIOD := FND_API.G_MISS_CHAR;
4850 */
4851 p_fin_rep_rec.DATE_REPORT_ISSUED := NULL;
4852 p_fin_rep_rec.REPORT_START_DATE := NULL;
4853 p_fin_rep_rec.REPORT_END_DATE := NULL;
4854 p_fin_rep_rec.ISSUED_PERIOD := NULL;
4855
4856 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_REPORT: Fin report already exists, contact_point_id =' || to_char(p_fin_rep_rec.financial_report_id));
4857
4858 IF p_fin_rep_rec.ACTUAL_CONTENT_SOURCE <> HZ_PARTY_V2PUB.G_MISS_CONTENT_SOURCE_TYPE THEN
4859 --
4860 --Fin report already exists. Update it.
4861 --
4862 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_REPORT: update financial report for DNB');
4863
4864 p_fin_rep_rec.created_by_module := NULL;
4865 HZ_ORGANIZATION_INFO_V2PUB.update_financial_report(
4866 'F',
4867 p_fin_rep_rec,
4868 l_ovn,
4869 x_return_status,
4870 l_msg_count,
4871 l_msg_data);
4872 /*
4873 hz_org_info_pub.update_financial_reports(
4874 1,
4875 'F',
4876 'F',
4877 p_fin_rep_rec,
4878 l_last_update_date1,
4879 x_return_status,
4880 l_msg_count,
4881 l_msg_data);
4882 */
4883
4884 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4885 RETURN;
4886 END IF;
4887 END IF;
4888 EXCEPTION WHEN NO_DATA_FOUND THEN
4889 l_create := TRUE;
4890 END;
4891
4892
4893 IF l_create THEN
4894
4895 --
4896 --Fin Report does not exist. Need to create a new one.
4897 --
4898
4899 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_REPORT: Fin report does not exist');
4900
4901 x_new_fin_report := 'Y';
4902
4903 p_fin_rep_rec.created_by_module := 'TCA_DNB_MAPPING';
4904 HZ_ORGANIZATION_INFO_V2PUB.create_financial_report(
4905 'F',
4906 p_fin_rep_rec,
4907 p_fin_rep_rec.financial_report_id,
4908 x_return_status,
4909 l_msg_count,
4910 l_msg_data);
4911 /*
4912 hz_org_info_pub.create_financial_reports(
4913 1,
4914 'F',
4915 'F',
4916 p_fin_rep_rec,
4917 x_return_status,
4918 l_msg_count,
4919 l_msg_data,
4920 p_fin_rep_rec.financial_report_id);
4921 */
4922
4923 END IF;
4924
4925 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_REPORT (-) ');
4926
4927 END do_store_financial_report;
4928
4929 /*===========================================================================+
4930 | PROCEDURE
4931 | store_financial_report
4932 |
4933 | DESCRIPTION
4934 | store financial report and financial numbers
4935 |
4936 | SCOPE - PRIVATE
4937 |
4938 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
4939 |
4940 | ARGUMENTS : IN:
4941 | OUT:
4942 | IN/ OUT:
4943 | p_fin_rep_rec
4944 | p_interface_rec
4945 | x_return_status
4946 |
4947 | RETURNS : NONE
4948 |
4949 | NOTES
4950 |
4951 | MODIFICATION HISTORY
4952 |
4953 +===========================================================================*/
4954
4955 procedure store_financial_report(
4956 --p_fin_rep_rec IN OUT NOCOPY hz_org_info_pub.financial_reports_rec_type,
4957 p_fin_rep_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.financial_report_rec_type,
4958 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
4959 x_return_status IN OUT NOCOPY VARCHAR2
4960 ) IS
4961 --l_fin_num_rec hz_org_info_pub.financial_numbers_rec_type;
4962 l_fin_num_rec HZ_ORGANIZATION_INFO_V2PUB.financial_number_rec_type;
4963 l_new_fin_report VARCHAR2(1);
4964 BEGIN
4965
4966
4967 do_store_financial_report(
4968 p_fin_rep_rec,
4969 l_new_fin_report,
4970 x_return_status);
4971
4972
4973 --
4974 -- Financial Numbers.
4975 --
4976
4977 IF x_return_status = 'S' THEN
4978 l_fin_num_rec.financial_report_id := p_fin_rep_rec.financial_report_id;
4979 --bug 3942332:l_fin_num_rec.content_source_type should be same as content_source_type in p_fin_rep_rec
4980 --l_fin_num_rec.CONTENT_SOURCE_TYPE := p_fin_rep_rec.ACTUAL_CONTENT_SOURCE;
4981 l_fin_num_rec.CONTENT_SOURCE_TYPE := 'USER_ENTERED';--p_fin_rep_rec.CONTENT_SOURCE_TYPE;
4982
4983 store_financial_number(
4984 p_interface_rec,
4985 l_fin_num_rec,
4986 l_new_fin_report,
4987 p_fin_rep_rec.type_of_financial_report,
4988 x_return_status
4989 );
4990 END IF;
4991
4992
4993 END store_financial_report;
4994
4995
4996 /*===========================================================================+
4997 | PROCEDURE
4998 | store_financial_number
4999 |
5000 | DESCRIPTION
5001 | store financial numbers
5002 |
5003 | SCOPE - PRIVATE
5004 |
5005 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
5006 |
5007 | ARGUMENTS : IN:
5008 | p_new_fin_report
5009 | p_type_of_financial_report
5010 | OUT:
5011 | IN/ OUT:
5012 | p_interface_rec
5013 | p_fin_num_rec
5014 | x_return_status
5015 |
5016 | RETURNS : NONE
5017 |
5018 | NOTES
5019 |
5020 | MODIFICATION HISTORY
5021 |
5022 +===========================================================================*/
5023
5024 procedure store_financial_number(
5025 p_interface_rec IN OUT NOCOPY HZ_PARTY_INTERFACE%ROWTYPE,
5026 --p_fin_num_rec IN OUT NOCOPY hz_org_info_pub.financial_numbers_rec_type,
5027 p_fin_num_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.financial_number_rec_type,
5028 p_new_fin_report IN VARCHAR2,
5029 p_type_of_financial_report IN VARCHAR2,
5030 x_return_status IN OUT NOCOPY VARCHAR2
5031 ) IS
5032 l_fin_num_tab fin_num_table;
5033 i NUMBER :=1;
5034
5035 CURSOR c1 IS
5036 SELECT *
5037 FROM hz_financial_numbers
5038 WHERE financial_report_id = p_fin_num_rec.financial_report_id;
5039 BEGIN
5040
5041 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER (+) ');
5042 --bug 3953178: in case financial_number_currecy is null use pref_functional_currency of interface record.
5043 IF p_interface_rec.FINANCIAL_NUMBER_CURRENCY IS NULL
5044 THEN
5045 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.PREF_FUNCTIONAL_CURRENCY;
5046 ELSE
5047 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.FINANCIAL_NUMBER_CURRENCY;
5048 END IF;
5049 -- end of bug 3953178
5050 IF p_new_fin_report = 'N' THEN
5051
5052 --
5053 --Fin report exists. fetch all fin num names.
5054 --
5055
5056 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER: Fin report exists. fetch all fin num names');
5057
5058 OPEN c1;
5059 LOOP
5060 FETCH c1 INTO l_fin_num_tab(i);
5061 i := i+1;
5062 EXIT WHEN c1%NOTFOUND;
5063 END LOOP;
5064 CLOSE c1;
5065 END IF;
5066
5067
5068 IF p_type_of_financial_report = 'BALANCE_SHEET' THEN
5069
5070 --
5071 --Balance Sheet
5072 --
5073
5074 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER: BALANCE_SHEET');
5075
5076 IF p_interface_rec.CURRENT_RATIO IS NOT NULL THEN
5077
5078 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'CURRENT_RATIO';
5079 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.CURRENT_RATIO;
5080
5081 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER:' || p_fin_num_rec.FINANCIAL_NUMBER_NAME);
5082
5083 do_store_financial_number(p_fin_num_rec,
5084 p_new_fin_report,
5085 l_fin_num_tab,
5086 x_return_status);
5087
5088 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5089 RETURN;
5090 END IF;
5091
5092 END IF;
5093
5094 IF p_interface_rec.CASH_LIQ_ASSETS IS NOT NULL THEN
5095 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'CASH_LIQ_ASSETS';
5096 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.CASH_LIQ_ASSETS;
5097
5098 do_store_financial_number(p_fin_num_rec,
5099 p_new_fin_report,
5100 l_fin_num_tab,
5101 x_return_status);
5102
5103 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5104 RETURN;
5105 END IF;
5106
5107 END IF;
5108
5109 IF p_interface_rec.ACCOUNTS_RECEIVABLE IS NOT NULL THEN
5110 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'ACCOUNTS_RECEIVABLE';
5111 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.ACCOUNTS_RECEIVABLE;
5112
5113 do_store_financial_number(p_fin_num_rec,
5114 p_new_fin_report,
5115 l_fin_num_tab,
5116 x_return_status);
5117
5118 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5119 RETURN;
5120 END IF;
5121 END IF;
5122
5123 IF p_interface_rec.ACCOUNTS_PAYABLE IS NOT NULL THEN
5124 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'ACCOUNTS_PAYABLE';
5125 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.ACCOUNTS_PAYABLE;
5126
5127 do_store_financial_number(p_fin_num_rec,
5128 p_new_fin_report,
5129 l_fin_num_tab,
5130 x_return_status);
5131
5132 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5133 RETURN;
5134 END IF;
5135 END IF;
5136
5137 IF p_interface_rec.INVENTORY IS NOT NULL THEN
5138 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'INVENTORY';
5139 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.INVENTORY;
5140
5141 do_store_financial_number(p_fin_num_rec,
5142 p_new_fin_report,
5143 l_fin_num_tab,
5144 x_return_status);
5145
5146 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5147 RETURN;
5148 END IF;
5149 END IF;
5150
5151 IF p_interface_rec.FIXED_ASSETS IS NOT NULL THEN
5152 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'FIXED_ASSETS';
5153 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.FIXED_ASSETS;
5154
5155 do_store_financial_number(p_fin_num_rec,
5156 p_new_fin_report,
5157 l_fin_num_tab,
5158 x_return_status);
5159
5160 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5161 RETURN;
5162 END IF;
5163 END IF;
5164
5165 IF p_interface_rec.TOTAL_CURRENT_ASSETS IS NOT NULL THEN
5166 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TOTAL_CURRENT_ASSETS';
5167 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TOTAL_CURRENT_ASSETS;
5168
5169 do_store_financial_number(p_fin_num_rec,
5170 p_new_fin_report,
5171 l_fin_num_tab,
5172 x_return_status);
5173
5174 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5175 RETURN;
5176 END IF;
5177 END IF;
5178
5179 IF p_interface_rec.TOTAL_CURR_LIABILITIES IS NOT NULL THEN
5180 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TOTAL_CURR_LIABILITIES';
5181 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TOTAL_CURR_LIABILITIES;
5182
5183 do_store_financial_number(p_fin_num_rec,
5184 p_new_fin_report,
5185 l_fin_num_tab,
5186 x_return_status);
5187
5188 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5189 RETURN;
5190 END IF;
5191 END IF;
5192
5193 IF x_return_status = 'S' AND p_interface_rec.TOTAL_ASSETS IS NOT NULL THEN
5194 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TOTAL_ASSETS';
5195 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TOTAL_ASSETS;
5196
5197 do_store_financial_number(p_fin_num_rec,
5198 p_new_fin_report,
5199 l_fin_num_tab,
5200 x_return_status);
5201
5202 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5203 RETURN;
5204 END IF;
5205 END IF;
5206
5207 IF p_interface_rec.INTANGIBLE_ASSETS IS NOT NULL THEN
5208 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'INTANGIBLE_ASSETS';
5209 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.INTANGIBLE_ASSETS;
5210
5211 do_store_financial_number(p_fin_num_rec,
5212 p_new_fin_report,
5213 l_fin_num_tab,
5214 x_return_status);
5215
5216 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5217 RETURN;
5218 END IF;
5219 END IF;
5220
5221 IF p_interface_rec.LONG_TERM_DEBT IS NOT NULL THEN
5222 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'LONG_TERM_DEBT';
5223 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.LONG_TERM_DEBT;
5224
5225 do_store_financial_number(p_fin_num_rec,
5226 p_new_fin_report,
5227 l_fin_num_tab,
5228 x_return_status);
5229
5230 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5231 RETURN;
5232 END IF;
5233 END IF;
5234
5235 IF p_interface_rec.TOT_LONG_TERM_LIAB IS NOT NULL THEN
5236 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TOT_LONG_TERM_LIAB';
5237 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TOT_LONG_TERM_LIAB;
5238
5239 do_store_financial_number(p_fin_num_rec,
5240 p_new_fin_report,
5241 l_fin_num_tab,
5242 x_return_status);
5243
5244 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5245 RETURN;
5246 END IF;
5247 END IF;
5248
5249 IF p_interface_rec.TOTAL_LIABILITIES IS NOT NULL THEN
5250 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TOTAL_LIABILITIES';
5251 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TOTAL_LIABILITIES;
5252
5253 do_store_financial_number(p_fin_num_rec,
5254 p_new_fin_report,
5255 l_fin_num_tab,
5256 x_return_status);
5257
5258 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5259 RETURN;
5260 END IF;
5261 END IF;
5262
5263 IF p_interface_rec.RETAINED_EARNINGS IS NOT NULL THEN
5264 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'RETAINED_EARNINGS';
5265 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.RETAINED_EARNINGS;
5266
5267 do_store_financial_number(p_fin_num_rec,
5268 p_new_fin_report,
5269 l_fin_num_tab,
5270 x_return_status);
5271
5272 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5273 RETURN;
5274 END IF;
5275 END IF;
5276
5277 IF p_interface_rec.NET_WORTH IS NOT NULL THEN
5278 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'NET_WORTH';
5279 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.NET_WORTH;
5280
5281 do_store_financial_number(p_fin_num_rec,
5282 p_new_fin_report,
5283 l_fin_num_tab,
5284 x_return_status);
5285
5286 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5287 RETURN;
5288 END IF;
5289 END IF;
5290
5291 IF p_interface_rec.PREVIOUS_NET_WORTH IS NOT NULL THEN
5292 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'PREV_NET_WORTH';
5293 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.PREVIOUS_NET_WORTH;
5294
5295 do_store_financial_number(p_fin_num_rec,
5296 p_new_fin_report,
5297 l_fin_num_tab,
5298 x_return_status);
5299
5300 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5301 RETURN;
5302 END IF;
5303 END IF;
5304
5305 -- bug fix 1502068
5306 IF p_interface_rec.PREVIOUS_WORKING_CAPITAL IS NOT NULL THEN
5307 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'PREV_WORKING_CAPITAL';
5308 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.PREVIOUS_WORKING_CAPITAL;
5309
5310 do_store_financial_number(p_fin_num_rec,
5311 p_new_fin_report,
5312 l_fin_num_tab,
5313 x_return_status);
5314
5315 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5316 RETURN;
5317 END IF;
5318 END IF;
5319
5320
5321 IF p_interface_rec.TOTAL_LIAB_EQUITY IS NOT NULL THEN
5322 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TOTAL_LIAB_EQUITY';
5323 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TOTAL_LIAB_EQUITY;
5324
5325 do_store_financial_number(p_fin_num_rec,
5326 p_new_fin_report,
5327 l_fin_num_tab,
5328 x_return_status);
5329
5330 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5331 RETURN;
5332 END IF;
5333 END IF;
5334
5335 IF p_interface_rec.QUICK_RATIO IS NOT NULL THEN
5336 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'QUICK_RATIO';
5337 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.QUICK_RATIO;
5338
5339 do_store_financial_number(p_fin_num_rec,
5340 p_new_fin_report,
5341 l_fin_num_tab,
5342 x_return_status);
5343
5344 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5345 RETURN;
5346 END IF;
5347 END IF;
5348
5349
5350 IF p_interface_rec.CAPITAL_AMOUNT IS NOT NULL THEN
5351 IF p_interface_rec.CAPITAL_TYPE_IND = '1' THEN
5352 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'ISSUED_CAPITAL';
5353 ELSIF p_interface_rec.CAPITAL_TYPE_IND = '2' THEN
5354 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'PAID_IN_CAPITAL';
5355 ELSIF p_interface_rec.CAPITAL_TYPE_IND = '3' THEN
5356 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'NOMINAL_CAPITAL';
5357 ELSIF p_interface_rec.CAPITAL_TYPE_IND = '4' THEN
5358 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'AUTHORIZED_CAPITAL';
5359 END IF;
5360
5361 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.CAPITAL_AMOUNT;
5362 --bug 3953178: in case capital_currency_code is null use pref_functional_currency
5363 IF p_interface_rec.CAPITAL_CURRENCY_CODE IS NOT NULL THEN
5364 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.CAPITAL_CURRENCY_CODE;
5365 ELSE
5366 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.PREF_FUNCTIONAL_CURRENCY;
5367 END IF;
5368 --end of 3953178
5369 do_store_financial_number(p_fin_num_rec,
5370 p_new_fin_report,
5371 l_fin_num_tab,
5372 x_return_status);
5373
5374 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5375 RETURN;
5376 END IF;
5377 END IF;
5378
5379
5380 ELSIF p_type_of_financial_report = 'INCOME_STATEMENT' THEN
5381
5382 --
5383 --INCOME STATEMENT
5384 --
5385
5386 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER: INCOME_STATEMENT');
5387
5388 --Following financial numbers come under 'INCOME_STATEMENT':
5389 --Sales
5390 --Previous Sales
5391 --Cost of Sales
5392 --Gross Income
5393 --Profit Before Tax
5394 --Net Income
5395 --Dividends
5396
5397 IF p_interface_rec.SALES IS NOT NULL THEN
5398 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'SALES';
5399 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.SALES;
5400
5401 do_store_financial_number(p_fin_num_rec,
5402 p_new_fin_report,
5403 l_fin_num_tab,
5404 x_return_status);
5405
5406 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5407 RETURN;
5408 END IF;
5409 END IF;
5410
5411 IF p_interface_rec.PREVIOUS_SALES IS NOT NULL THEN
5412 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'PREVIOUS_SALES';
5413 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.PREVIOUS_SALES;
5414
5415 do_store_financial_number(p_fin_num_rec,
5416 p_new_fin_report,
5417 l_fin_num_tab,
5418 x_return_status);
5419
5420 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5421 RETURN;
5422 END IF;
5423 END IF;
5424
5425 IF p_interface_rec.COST_OF_SALES IS NOT NULL THEN
5426 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'COST_OF_SALES';
5427 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.COST_OF_SALES;
5428
5429 do_store_financial_number(p_fin_num_rec,
5430 p_new_fin_report,
5431 l_fin_num_tab,
5432 x_return_status);
5433
5434 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5435 RETURN;
5436 END IF;
5437 END IF;
5438
5439 IF p_interface_rec.GROSS_INCOME IS NOT NULL THEN
5440 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'GROSS_INCOME';
5441 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.GROSS_INCOME;
5442
5443 do_store_financial_number(p_fin_num_rec,
5444 p_new_fin_report,
5445 l_fin_num_tab,
5446 x_return_status);
5447
5448 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5449 RETURN;
5450 END IF;
5451 END IF;
5452
5453 IF p_interface_rec.PROFIT_BEFORE_TAX IS NOT NULL THEN
5454 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'PROFIT_BEFORE_TAX';
5455 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.PROFIT_BEFORE_TAX;
5456
5457 do_store_financial_number(p_fin_num_rec,
5458 p_new_fin_report,
5459 l_fin_num_tab,
5460 x_return_status);
5461
5462 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5463 RETURN;
5464 END IF;
5465 END IF;
5466
5467 IF p_interface_rec.NET_INCOME IS NOT NULL THEN
5468 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'NET_INCOME';
5469 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.NET_INCOME;
5470
5471 do_store_financial_number(p_fin_num_rec,
5472 p_new_fin_report,
5473 l_fin_num_tab,
5474 x_return_status);
5475
5476 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5477 RETURN;
5478 END IF;
5479 END IF;
5480
5481 IF p_interface_rec.DIVIDENDS IS NOT NULL THEN
5482 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'DIVIDENDS';
5483 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.DIVIDENDS;
5484
5485 do_store_financial_number(p_fin_num_rec,
5486 p_new_fin_report,
5487 l_fin_num_tab,
5488 x_return_status);
5489
5490 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5491 RETURN;
5492 END IF;
5493 END IF;
5494
5495
5496
5497 ELSIF p_type_of_financial_report = 'TANGIBLE_NET_WORTH' THEN
5498
5499 --
5500 --TANGIBLE_NET_WORTH
5501 --
5502
5503 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER: TANGIBLE_NET_WORTH');
5504
5505 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'TANGIBLE_NET_WORTH';
5506 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.TANGIBLE_NET_WORTH;
5507 --bug 3953178: in case tangible_net_worth_curr is null use pref_functional_currency
5508 IF p_interface_rec.TANGIBLE_NET_WORTH_CURR IS NOT NULL THEN
5509 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.TANGIBLE_NET_WORTH_CURR;
5510 ELSE
5511 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.PREF_FUNCTIONAL_CURRENCY;
5512 END IF;
5513 --end of3953178.
5514 -- p_fin_num_rec.PROJECTED_ACTUAL_FLAG := p_interface_rec.TANGIBLE_NET_WORTH_IND;
5515
5516 do_store_financial_number(p_fin_num_rec,
5517 p_new_fin_report,
5518 l_fin_num_tab,
5519 x_return_status);
5520
5521 ELSIF p_type_of_financial_report = 'ANNUAL_SALES_VOLUME' THEN
5522
5523 --
5524 --ANNUAL_SALES_VOLUME
5525 --
5526
5527 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER: ANNUAL_SALES_VOLUME');
5528
5529 p_fin_num_rec.FINANCIAL_NUMBER_NAME := 'ANNUAL_SALES_VOLUME';
5530 p_fin_num_rec.FINANCIAL_NUMBER := p_interface_rec.ANNUAL_SALES_VOLUME;
5531 --bug 3953178: in case annual_sales_currency is null use pref_functional_currency
5532 IF p_interface_rec.ANNUAL_SALES_CURRENCY IS NOT NULL THEN
5533 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.ANNUAL_SALES_CURRENCY;
5534 ELSE
5535 p_fin_num_rec.FINANCIAL_NUMBER_CURRENCY := p_interface_rec.PREF_FUNCTIONAL_CURRENCY;
5536 END IF;
5537 --end of 3953178
5538 --possible values of ANNUAL_SALES_EST_IND:
5539 --1=Actual
5540 --2=Estimated
5541 --3=Forecast
5542 --4=Projected
5543 --5=Calculated
5544
5545 IF p_interface_rec.ANNUAL_SALES_EST_IND = '1' THEN
5546 p_fin_num_rec.PROJECTED_ACTUAL_FLAG := 'A';
5547 ELSIF p_interface_rec.ANNUAL_SALES_EST_IND = '2' THEN
5548 p_fin_num_rec.PROJECTED_ACTUAL_FLAG := 'E';
5549 ELSIF p_interface_rec.ANNUAL_SALES_EST_IND = '3' THEN
5550 p_fin_num_rec.PROJECTED_ACTUAL_FLAG := 'F';
5551 ELSIF p_interface_rec.ANNUAL_SALES_EST_IND = '4' THEN
5552 p_fin_num_rec.PROJECTED_ACTUAL_FLAG := 'P';
5553 ELSIF p_interface_rec.ANNUAL_SALES_EST_IND = '5' THEN
5554 p_fin_num_rec.PROJECTED_ACTUAL_FLAG := 'C';
5555 END IF;
5556
5557 do_store_financial_number(p_fin_num_rec,
5558 p_new_fin_report,
5559 l_fin_num_tab,
5560 x_return_status);
5561 END IF;
5562
5563 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_FINANCIAL_NUMBER (-) ');
5564
5565 END store_financial_number;
5566
5567
5568 --
5569 -- Create Financial Numbers.
5570 --
5571 /*===========================================================================+
5572 | PROCEDURE
5573 | do_store_financial_number
5574 |
5575 | DESCRIPTION
5576 | store financial numbers
5577 |
5578 | SCOPE - PRIVATE
5579 |
5580 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
5581 |
5582 | ARGUMENTS : IN:
5583 | p_new_fin_report
5584 | p_fin_num_tab
5585 | OUT:
5586 | IN/ OUT:
5587 | p_fin_num_rec
5588 | x_return_status
5589 |
5590 | RETURNS : NONE
5591 |
5592 | NOTES
5593 |
5594 | MODIFICATION HISTORY
5595 |
5596 +===========================================================================*/
5597
5598 procedure do_store_financial_number(
5599 --p_fin_num_rec IN OUT NOCOPY hz_org_info_pub.financial_numbers_rec_type ,
5600 p_fin_num_rec IN OUT NOCOPY HZ_ORGANIZATION_INFO_V2PUB.financial_number_rec_type,
5601 p_new_fin_report IN VARCHAR2,
5602 p_fin_num_tab IN fin_num_table,
5603 x_return_status IN OUT NOCOPY VARCHAR2
5604 ) IS
5605 l_fin_name_exists VARCHAR2(1) := 'N';
5606 l_financial_number_id NUMBER;
5607 l_msg_count NUMBER;
5608 l_msg_data VARCHAR2(2000);
5609 l_last_update_date1 DATE;
5610 l_ovn NUMBER;
5611 BEGIN
5612
5613 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_FINANCIAL_NUMBER (+) ');
5614
5615 IF p_new_fin_report = 'Y' THEN /* financial report is new. */
5616
5617 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_FINANCIAL_NUMBER: financial report is new');
5618
5619 p_fin_num_rec.created_by_module := 'TCA_DNB_MAPPING';
5620 HZ_ORGANIZATION_INFO_V2PUB.create_financial_number(
5621 'F',
5622 p_fin_num_rec,
5623 l_financial_number_id,
5624 x_return_status,
5625 l_msg_count,
5626 l_msg_data);
5627
5628 /*
5629 hz_org_info_pub.create_financial_numbers(
5630 1,
5631 'F',
5632 'F',
5633 p_fin_num_rec,
5634 x_return_status,
5635 l_msg_count,
5636 l_msg_data,
5637 l_financial_number_id);
5638 */
5639 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5640 RETURN;
5641 END IF;
5642
5643 --else some fin num may be existing. check in db to see if fin num exists. If it does, update it, else create it.
5644
5645 ELSE /* financial report is not new. */
5646
5647 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_FINANCIAL_NUMBER: financial report exists');
5648
5649 p_fin_num_rec.financial_number_id := NULL;
5650
5651 IF p_fin_num_tab.COUNT > 0 THEN
5652 FOR i IN p_fin_num_tab.FIRST..p_fin_num_tab.LAST LOOP
5653 IF p_fin_num_rec.financial_number_name = p_fin_num_tab(i).financial_number_name THEN
5654 l_fin_name_exists := 'Y';
5655 p_fin_num_rec.financial_number_id := p_fin_num_tab(i).financial_number_id;
5656 l_last_update_date1 := p_fin_num_tab(i).last_update_date;
5657 l_ovn := p_fin_num_tab(i).object_version_number;
5658 EXIT;
5659 END IF;
5660 END LOOP;
5661 END IF;
5662
5663 IF l_fin_name_exists = 'Y' THEN
5664
5665 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_FINANCIAL_NUMBER: financial report exists: fin num exists');
5666
5667
5668 p_fin_num_rec.created_by_module := NULL;
5669 HZ_ORGANIZATION_INFO_V2PUB.update_financial_number(
5670 'F',
5671 p_fin_num_rec,
5672 l_ovn,
5673 x_return_status,
5674 l_msg_count,
5675 l_msg_data);
5676 /*
5677 hz_org_info_pub.update_financial_numbers(
5678 1,
5679 'F',
5680 'F',
5681 p_fin_num_rec,
5682 l_last_update_date1,
5683 x_return_status,
5684 l_msg_count,
5685 l_msg_data);
5686 */
5687 ELSE
5688
5689 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_FINANCIAL_NUMBER: financial report is not new: fin num does not exist');
5690
5691 p_fin_num_rec.created_by_module := 'TCA_DNB_MAPPING';
5692 HZ_ORGANIZATION_INFO_V2PUB.create_financial_number(
5693 'F',
5694 p_fin_num_rec,
5695 l_financial_number_id,
5696 x_return_status,
5697 l_msg_count,
5698 l_msg_data);
5699
5700 /*
5701 hz_org_info_pub.create_financial_numbers(
5702 1,
5703 'F',
5704 'F',
5705 p_fin_num_rec,
5706 x_return_status,
5707 l_msg_count,
5708 l_msg_data,
5709 l_financial_number_id);
5710 */
5711 END IF;
5712
5713 END IF; /* financial report is new. */
5714
5715 arp_util.debug('HZ_MAP_PARTY_PUB.D_STORE_FINANCIAL_NUMBER (-) ');
5716
5717 END do_store_financial_number;
5718
5719 /*===========================================================================+
5720 | PROCEDURE
5721 | store_related_duns
5722 |
5723 | DESCRIPTION
5724 | store financial numbers
5725 |
5726 | SCOPE - PRIVATE
5727 |
5728 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
5729 |
5730 | ARGUMENTS : IN:
5731 | p_commit
5732 | p_group_id
5733 | OUT:
5734 | IN/ OUT:
5735 | x_return_status
5736 |
5737 | RETURNS : NONE
5738 |
5739 | NOTES
5740 |
5741 | MODIFICATION HISTORY
5742 |
5743 | 19-AUG-2004 Rajib Ranjan Borah o Bug 3107162.Status in hz_party_interface
5744 | can be either P1 or W1. Therefore added
5745 | W1 in cursor c1.
5746 | o If previous status was P1, set it to P2.
5747 | If previous status was W1, set it to W2.
5748 +===========================================================================*/
5749
5750 procedure store_related_duns(
5751 p_commit IN VARCHAR2:= FND_API.G_FALSE,
5752 p_group_id IN NUMBER,
5753 x_return_status IN OUT NOCOPY VARCHAR2
5754 ) IS
5755 CURSOR c1 IS
5756 SELECT * FROM
5757 HZ_PARTY_INTERFACE
5758 WHERE NVL(group_id, FND_API.G_MISS_NUM) = NVL(p_group_id, FND_API.G_MISS_NUM)
5759 AND status IN ('P1','W1'); -- Bug 3107162
5760
5761 l_interface_rec HZ_PARTY_INTERFACE%ROWTYPE;
5762 l_related_duns_rec related_duns_rec_type;
5763 num_of_rec NUMBER;
5764 l_profile VARCHAR2(1);
5765
5766 /* VJN INTRODUCED CHANGE BEGINS */
5767 conform_party_id number;
5768 conform_parent_party_id number ;
5769 conform_dup_party_id number;
5770 conform_gup_party_id number;
5771 conform_parent_flag varchar2(1);
5772 x_msg_count number;
5773 x_msg_data varchar2(200) ;
5774 /* VJN INTRODUCED CHANGE ENDS*/
5775
5776
5777 --For related DUNS, open cursor here again.
5778 BEGIN
5779
5780 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS (+) ');
5781 OPEN c1;
5782 LOOP
5783 BEGIN
5784 FETCH c1 INTO l_interface_rec;
5785 EXIT WHEN c1%NOTFOUND;
5786
5787 num_of_rec := num_of_rec + 1;
5788
5789 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: fetched record from cursor: '|| to_char(num_of_rec));
5790
5791
5792 --Set Savepoint
5793 SAVEPOINT store_related_duns_pub;
5794
5795 --Initialize API return status to success.
5796 x_return_status := FND_API.G_RET_STS_SUCCESS;
5797
5798 --VJN :: Initialize dnb hierarchy variables
5799
5800 conform_party_id := null;
5801 conform_parent_party_id := null ;
5802 conform_dup_party_id := null;
5803 conform_gup_party_id := null;
5804 conform_parent_flag := null;
5805
5806 IF l_interface_rec.GDP_NAME IN ('BATCH', 'VENDOR_MGMT', 'ENT_MGMT') THEN
5807
5808 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: GDP_NAME IN (BATCH, VENDOR_MGMT, ENT_MGMT)');
5809
5810 --Related DUNS info. is provided only by above products.
5811
5812 l_related_duns_rec.MAIN_PARTY_ID := l_interface_rec.party_id;
5813 l_related_duns_rec.MAIN_DUNS_NUMBER := l_interface_rec.DUNS_NUMBER; -- Bug 5440525
5814 l_related_duns_rec.CONTENT_SOURCE_TYPE := l_interface_rec.CONTENT_SOURCE_TYPE;
5815
5816
5817 -- VJN :: GET THE DNB PURCHASEE PARTY ID
5818 conform_party_id := l_related_duns_rec.MAIN_PARTY_ID ;
5819
5820 --
5821 --HQ
5822 --
5823
5824 IF l_interface_rec.HQ_DUNS_NUMBER IS NOT NULL THEN
5825
5826 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: HQ');
5827
5828 l_related_duns_rec.DUNS_NUMBER := l_interface_rec.HQ_DUNS_NUMBER ;
5829 l_related_duns_rec.NAME := l_interface_rec.HQ_NAME ;
5830 l_related_duns_rec.COUNTRY := l_interface_rec.HQ_COUNTRY;
5831 l_related_duns_rec.ADDRESS1 := l_interface_rec.HQ_ADDRESS1 ;
5832 l_related_duns_rec.CITY := l_interface_rec.HQ_CITY ;
5833 l_related_duns_rec.PRIMARY_GEO_AREA := l_interface_rec.HQ_PRIMARY_GEO_AREA ;
5834 l_related_duns_rec.COUNTY := l_interface_rec.HQ_COUNTY ;
5835 l_related_duns_rec.POSTAL_CODE := l_interface_rec.HQ_POSTAL_CODE ;
5836 l_related_duns_rec.PHONE_NUMBER := l_interface_rec.HQ_PHONE_NUMBER ;
5837 l_related_duns_rec.RELATIONSHIP_TYPE := 'HEADQUARTERS/DIVISION';
5838 l_related_duns_rec.RELATIONSHIP_CODE := 'HEADQUARTERS_OF';
5839
5840 -- VJN :::: Get the HQ party Id Information from the out variable
5841 do_store_related_duns(l_related_duns_rec, x_return_status, conform_parent_party_id);
5842 conform_parent_flag := 'H';
5843
5844 END IF;
5845 --
5846 --PARENT
5847 --
5848
5849 --
5850 --If DUNS=Parent DUNS (DNB should be sending the Parent data if the company is the final Parent.),
5851 --do_store_related_duns will not be called.
5852 --
5853
5854 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
5855 l_interface_rec.PARENT_DUNS_NUMBER IS NOT NULL THEN
5856
5857 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: PARENT');
5858
5859 l_related_duns_rec.DUNS_NUMBER := l_interface_rec.PARENT_DUNS_NUMBER ;
5860 l_related_duns_rec.NAME := l_interface_rec.PARENT_NAME ;
5861 l_related_duns_rec.COUNTRY := l_interface_rec.PARENT_COUNTRY ;
5862 l_related_duns_rec.ADDRESS1 := l_interface_rec.PARENT_ADDRESS1 ;
5863 l_related_duns_rec.CITY := l_interface_rec.PARENT_CITY ;
5864 l_related_duns_rec.PRIMARY_GEO_AREA := l_interface_rec.PARENT_PRIMARY_GEO_AREA ;
5865 l_related_duns_rec.COUNTY := l_interface_rec.PARENT_COUNTY ;
5866 l_related_duns_rec.POSTAL_CODE := l_interface_rec.PARENT_POSTAL_CODE ;
5867 l_related_duns_rec.PHONE_NUMBER := l_interface_rec.PARENT_PHONE_NUMBER ;
5868 l_related_duns_rec.RELATIONSHIP_TYPE := 'PARENT/SUBSIDIARY';
5869 l_related_duns_rec.RELATIONSHIP_CODE := 'PARENT_OF';
5870
5871 -- VJN :::: Get the parent party Id Information from the out variable
5872 do_store_related_duns(l_related_duns_rec, x_return_status, conform_parent_party_id);
5873 conform_parent_flag := 'P';
5874
5875 END IF;
5876
5877 --
5878 --DOM_ULT
5879 --
5880
5881 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
5882 l_interface_rec.DOM_ULT_DUNS_NUMBER IS NOT NULL THEN
5883
5884 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: DOM_ULT');
5885
5886 l_related_duns_rec.DUNS_NUMBER := l_interface_rec.DOM_ULT_DUNS_NUMBER ;
5887 l_related_duns_rec.NAME := l_interface_rec.DOM_ULT_NAME ;
5888 l_related_duns_rec.COUNTRY := l_interface_rec.DOM_ULT_COUNTRY;
5889 l_related_duns_rec.ADDRESS1 := l_interface_rec.DOM_ULT_ADDRESS1 ;
5890 l_related_duns_rec.CITY := l_interface_rec.DOM_ULT_CITY ;
5891 l_related_duns_rec.PRIMARY_GEO_AREA:=l_interface_rec.DOM_ULT_PRIMARY_GEO_AREA;
5892 l_related_duns_rec.COUNTY := l_interface_rec.DOM_ULT_COUNTY ;
5893 l_related_duns_rec.POSTAL_CODE := l_interface_rec.DOM_ULT_POSTAL_CODE ;
5894 l_related_duns_rec.PHONE_NUMBER := l_interface_rec.DOM_ULT_PHONE_NUMBER ;
5895 l_related_duns_rec.RELATIONSHIP_TYPE := 'DOMESTIC_ULTIMATE';
5896 l_related_duns_rec.RELATIONSHIP_CODE := 'DOMESTIC_ULTIMATE_OF';
5897
5898 -- VJN :::: Get the DUP party Id Information from the out variable
5899 do_store_related_duns(l_related_duns_rec, x_return_status, conform_dup_party_id);
5900
5901 END IF;
5902
5903 --
5904 --GLB_ULT
5905 --
5906
5907 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
5908 l_interface_rec.GLB_ULT_DUNS_NUMBER IS NOT NULL THEN
5909
5910 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: GLB_ULT');
5911
5912 l_related_duns_rec.DUNS_NUMBER := l_interface_rec.GLB_ULT_DUNS_NUMBER ;
5913 l_related_duns_rec.NAME := l_interface_rec.GLB_ULT_NAME ;
5914 l_related_duns_rec.COUNTRY := l_interface_rec.GLB_ULT_COUNTRY;
5915 l_related_duns_rec.ADDRESS1 := l_interface_rec.GLB_ULT_ADDRESS1 ;
5916 l_related_duns_rec.CITY := l_interface_rec.GLB_ULT_CITY ;
5917 l_related_duns_rec.PRIMARY_GEO_AREA :=l_interface_rec.GLB_ULT_PRIMARY_GEO_AREA;
5918 l_related_duns_rec.COUNTY := l_interface_rec.GLB_ULT_COUNTY ;
5919 l_related_duns_rec.POSTAL_CODE := l_interface_rec.GLB_ULT_POSTAL_CODE ;
5920 l_related_duns_rec.PHONE_NUMBER := l_interface_rec.GLB_ULT_PHONE_NUMBER ;
5921 l_related_duns_rec.RELATIONSHIP_TYPE := 'GLOBAL_ULTIMATE';
5922 l_related_duns_rec.RELATIONSHIP_CODE := 'GLOBAL_ULTIMATE_OF';
5923
5924 -- VJN :::: Get the GUP party Id Information from the out variable
5925 do_store_related_duns(l_related_duns_rec, x_return_status, conform_gup_party_id);
5926
5927 END IF;
5928
5929 -- VJN :::::: CALL CONFORM PARTY SCRIPT , DEPENDING ON THE PROFILE OPTION
5930 -- Y --- STOP/DONT CONFORM
5931 -- N --- GO AHEAD AND CONFORM
5932 -- THE PROFILE OPTION 'HZ_DNB_HIER_STOP_CONFORM' IS INTRODUCED FOR DEBUGGING PURPOSES.
5933 -- IF THIS OPTION DOES NOT EXIST, THE MAPPING PROGRAM WILL ALWAYS CONFORM A PURCHASED PARTY
5934 -- IF THIS OPTION EXISTS, THEN CONFORMATION WILL BE AS PER THE FLAGS MENTIONED ABOVE.
5935
5936 IF x_return_status = FND_API.G_RET_STS_SUCCESS AND
5937 nvl(fnd_profile.value('HZ_DNB_HIER_STOP_CONFORM'),'N') = 'N'
5938 THEN
5939 IF fnd_profile.value('HZ_GENERATE_PARTY_NUMBER') = 'N' THEN
5940 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'Y');
5941 l_profile := 'N';
5942 END IF;
5943 HZ_DNB_HIERARCHY_PVT. conform_party_to_dnb_hierarchy ( 'T', conform_party_id, conform_parent_party_id,
5944 conform_dup_party_id, conform_gup_party_id ,
5945 conform_parent_flag ,
5946 x_return_status, x_msg_count, x_msg_data );
5947 IF l_profile = 'N' THEN
5948 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'N');
5949 END IF;
5950 END IF;
5951
5952
5953
5954 END IF; /* GDP_NAME */
5955
5956 --
5957 --Check return status
5958 --
5959
5960 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
5961 IF l_interface_rec.status = 'W1' THEN -- Bug 3107162
5962 UPDATE hz_party_interface
5963 SET status = 'W2'
5964 WHERE party_interface_id = l_interface_rec.party_interface_id;
5965 ELSE -- i.e. previous status was 'P1'
5966 UPDATE hz_party_interface
5967 SET status = 'P2'
5968 WHERE party_interface_id = l_interface_rec.party_interface_id;
5969 END IF;
5970
5971 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: update party interface status to P2 for party_interface_id = ' || l_interface_rec.party_interface_id );
5972
5973 do_update_request_log(
5974 l_interface_rec.request_log_id,
5975 l_interface_rec.party_id,
5976 'S'
5977 );
5978
5979 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS: update request log status to S');
5980 IF FND_API.to_Boolean(p_commit) THEN
5981 commit;
5982 END IF;
5983
5984 ELSE
5985 ROLLBACK to store_related_duns_pub;
5986 /* need to rollback the successful transactions for this record prior to failure. */
5987 do_update_request_log(
5988 l_interface_rec.request_log_id,
5989 l_interface_rec.party_id,
5990 'E2'
5991 );
5992
5993 store_error(
5994 p_status => 'E2',
5995 p_party_interface_id => l_interface_rec.party_interface_id);
5996
5997
5998 END IF; /* IF x_return_status = */
5999
6000
6001
6002 EXCEPTION
6003 WHEN FND_API.G_EXC_ERROR THEN
6004 ROLLBACK TO store_related_duns_pub;
6005 x_return_status := FND_API.G_RET_STS_ERROR;
6006
6007 do_update_request_log(
6008 l_interface_rec.request_log_id,
6009 l_interface_rec.party_id,
6010 'E2'
6011 );
6012
6013 store_error(
6014 p_status => 'E2',
6015 p_party_interface_id => l_interface_rec.party_interface_id);
6016
6017 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6018 ROLLBACK TO store_related_duns_pub;
6019 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6020
6021 do_update_request_log(
6022 l_interface_rec.request_log_id,
6023 l_interface_rec.party_id,
6024 'E2'
6025 );
6026
6027 store_error(
6028 p_status => 'E2',
6029 p_party_interface_id => l_interface_rec.party_interface_id);
6030
6031 WHEN OTHERS THEN
6032 ROLLBACK TO store_related_duns_pub;
6033 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6034
6035 FND_MESSAGE.SET_NAME('AR', 'HZ_API_OTHERS_EXCEP');
6036 FND_MESSAGE.SET_TOKEN('ERROR' ,SQLERRM);
6037 FND_MSG_PUB.ADD;
6038
6039 do_update_request_log(
6040 l_interface_rec.request_log_id,
6041 l_interface_rec.party_id,
6042 'E2'
6043 );
6044
6045 store_error(
6046 p_status => 'E2',
6047 p_party_interface_id => l_interface_rec.party_interface_id);
6048
6049 END;
6050
6051 END LOOP;
6052 CLOSE c1;
6053
6054 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_RELATED_DUNS (-) ');
6055
6056 END store_related_duns;
6057
6058 /*===========================================================================+
6059 | PROCEDURE
6060 | do_store_related_duns
6061 |
6062 | DESCRIPTION
6063 | store financial numbers
6064 |
6065 | SCOPE - PRIVATE
6066 |
6067 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
6068 |
6069 | ARGUMENTS : IN:
6070 | p_related_duns_rec
6071 | OUT:
6072 | IN/ OUT:
6073 | x_return_status
6074 |
6075 | RETURNS : NONE
6076 |
6077 | NOTES
6078 |
6079 | MODIFICATION HISTORY
6080 | 07-APR-2004 Dhaval Mehta Bug 3550989 : Pass orig_system and orig_system_reference
6081 | to org_profile record type when calling create_org API
6082 | 19-APR-2004 Dhaval Mehta Bug 3020636 : While creating relationships for related parties,
6083 | create relationships with parties having active record in
6084 | SSM table. Do not create rel with all parties having
6085 | active org profile records. exists - do_store_related_duns
6086 |
6087 +===========================================================================*/
6088
6089 procedure do_store_related_duns(
6090 p_related_duns_rec IN related_duns_rec_type,
6091 x_return_status IN OUT NOCOPY VARCHAR2,
6092 x_conform_party_id OUT NOCOPY number
6093 ) IS
6094
6095 -- Bug 3020636 : Modify the cursor to include SSM table
6096 -- to find active profile for related party.
6097
6098 CURSOR c1 IS
6099 SELECT org.party_id
6100 FROM hz_organization_profiles org, hz_orig_sys_references ssm
6101 WHERE org.duns_number_c = lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0')
6102 AND org.actual_content_source = p_related_duns_rec.content_source_type
6103 AND org.effective_end_date is NULL
6104 AND org.party_id = ssm.owner_table_id
6105 AND ssm.owner_table_name = 'HZ_PARTIES'
6106 AND ssm.orig_system = 'DNB'
6107 AND ssm.status = 'A'
6108 AND rownum = 1;
6109
6110
6111 l_organization_rec HZ_PARTY_V2PUB.organization_rec_type;
6112 l_location_rec hz_location_v2pub.location_rec_type;
6113 l_contact_points_rec hz_contact_point_v2pub.contact_point_rec_type;
6114 l_phone_rec hz_contact_point_v2pub.phone_rec_type := HZ_CONTACT_POINT_V2PUB.G_MISS_PHONE_REC;
6115 l_party_rel_rec HZ_RELATIONSHIP_V2PUB.relationship_rec_type;
6116
6117 l_msg_count NUMBER;
6118 l_msg_data VARCHAR2(2000);
6119 l_count NUMBER;
6120 l_count2 NUMBER;
6121 l_organization_profile_id NUMBER;
6122 l_party_id NUMBER;
6123 l_profile VARCHAR2(1);
6124 l_last_update_date1 DATE;
6125 x_party_id HZ_PARTIES.PARTY_ID%TYPE;
6126 x_party_number HZ_PARTIES.PARTY_NUMBER%TYPE;
6127
6128
6129 BEGIN
6130
6131 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_RELATED_DUNS (+) ');
6132
6133 l_organization_rec.actual_content_source := p_related_duns_rec.content_source_type;
6134 l_organization_rec.created_by_module := 'TCA_DNB_MAPPING';
6135
6136 l_party_rel_rec.actual_content_source := p_related_duns_rec.content_source_type;
6137 l_party_rel_rec.object_id := p_related_duns_rec.main_party_id;
6138 l_party_rel_rec.relationship_type := p_related_duns_rec.RELATIONSHIP_TYPE;
6139 l_party_rel_rec.relationship_code := p_related_duns_rec.RELATIONSHIP_CODE;
6140 l_party_rel_rec.subject_type := 'ORGANIZATION';
6141 l_party_rel_rec.object_type := 'ORGANIZATION';
6142 l_party_rel_rec.subject_table_name := 'HZ_PARTIES';
6143 l_party_rel_rec.object_table_name := 'HZ_PARTIES';
6144 l_party_rel_rec.created_by_module := 'TCA_DNB_MAPPING';
6145
6146 l_contact_points_rec.actual_content_source := p_related_duns_rec.content_source_type;
6147 l_contact_points_rec.created_by_module := 'TCA_DNB_MAPPING';
6148 l_phone_rec.PHONE_LINE_TYPE := 'GEN';
6149 -- for related duns, only create dnb data
6150 l_phone_rec.RAW_PHONE_NUMBER := p_related_duns_rec.PHONE_NUMBER;
6151
6152 --Bug 1736056: Default country to 'US' if it is NULL. Convert
6153 --lower case to upper case.
6154 l_location_rec.COUNTRY := NVL(UPPER(p_related_duns_rec.COUNTRY), G_DEFAULT_COUNTRY_CODE) ;
6155 l_location_rec.ADDRESS1 := NVL(p_related_duns_rec.ADDRESS1, 'Not provided by DNB');
6156 l_location_rec.CITY := p_related_duns_rec.CITY ;
6157 l_location_rec.STATE := p_related_duns_rec.PRIMARY_GEO_AREA ;
6158 l_location_rec.PROVINCE := p_related_duns_rec.PRIMARY_GEO_AREA ;
6159 l_location_rec.COUNTY := p_related_duns_rec.COUNTY ;
6160 l_location_rec.POSTAL_CODE := p_related_duns_rec.POSTAL_CODE ;
6161 l_location_rec.actual_content_source := p_related_duns_rec.content_source_type;
6162 l_location_rec.created_by_module := 'TCA_DNB_MAPPING';
6163
6164 --
6165 --If DUNS = Related DUNS, only create party relationship.
6166 --
6167
6168 IF p_related_duns_rec.DUNS_NUMBER = p_related_duns_rec.MAIN_DUNS_NUMBER THEN
6169 l_party_rel_rec.subject_id := p_related_duns_rec.main_party_id;
6170
6171 store_party_rel(
6172 l_party_rel_rec,
6173 x_return_status);
6174 -- VJN ::: POPULATE PASSED IN OUT VARIABLE
6175 x_conform_party_id := l_party_rel_rec.subject_id ;
6176 ELSE
6177
6178 SELECT COUNT(*) INTO l_count
6179 FROM hz_organization_profiles
6180 WHERE duns_number_c = lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0')
6181 AND actual_content_source = p_related_duns_rec.content_source_type
6182 AND (SYSDATE BETWEEN effective_start_date AND NVL(effective_end_date, to_date('12/31/4712','MM/DD/YYYY')));
6183
6184 IF l_count = 0 THEN
6185
6186 --
6187 --party does not exist in system. create party and org profile.
6188 --
6189
6190 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_RELATED_DUNS: party does not exist');
6191
6192 l_organization_rec.organization_name := p_related_duns_rec.NAME;
6193 l_organization_rec.DUNS_NUMBER_C := lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0');
6194 --Bug 3550989 : Pass orig_system and orig_system_reference to create_org API
6195 l_organization_rec.party_rec.orig_system := 'DNB';
6196 l_organization_rec.party_rec.orig_system_reference := lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0');
6197
6198 --Bug 1721094: generate party number by sequence.
6199 IF fnd_profile.value('HZ_GENERATE_PARTY_NUMBER') = 'N' THEN
6200 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'Y');
6201 l_profile := 'N';
6202 END IF;
6203
6204 l_organization_rec.created_by_module := 'TCA_DNB_MAPPING';
6205 HZ_PARTY_V2PUB.create_organization(
6206 'F',
6207 l_organization_rec,
6208 x_return_status,
6209 l_msg_count,
6210 l_msg_data,
6211 x_party_id,
6212 x_party_number,
6213 l_organization_profile_id);
6214 /* Bug Fix : 2770991 */
6215 IF x_party_id IS NOT NULL THEN
6216 l_organization_rec.party_rec.party_id := x_party_id;
6217 END IF;
6218 IF x_party_number IS NOT NULL THEN
6219 l_organization_rec.party_rec.party_number := x_party_number;
6220 END IF;
6221
6222 --Bug 1721094: reset profile option.
6223 IF l_profile = 'N' THEN
6224 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'N');
6225 END IF;
6226
6227 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6228 RETURN;
6229 END IF;
6230
6231 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_RELATED_DUNS: party does not exist: created party with party_id ' || to_char(l_organization_rec.party_rec.party_id));
6232 --
6233 --update displayed_duns_party_id.
6234 --
6235
6236 --arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ORG: party does not exist: update displayed_duns_party_id');
6237
6238 UPDATE hz_organization_profiles
6239 SET displayed_duns_party_id = l_organization_rec.party_rec.party_id
6240 WHERE organization_profile_id = l_organization_profile_id;
6241
6242 -- party_id = l_organization_rec.party_rec.party_id AND
6243 -- effective_end_date is null;
6244
6245 l_party_rel_rec.subject_id := l_organization_rec.party_rec.party_id;
6246
6247 store_party_rel(
6248 l_party_rel_rec,
6249 x_return_status);
6250
6251 -- VJN ::: POPULATE PASSED IN OUT VARIABLE
6252 x_conform_party_id := l_party_rel_rec.subject_id ;
6253
6254 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6255 RETURN;
6256 END IF;
6257
6258 l_contact_points_rec.owner_table_id := l_organization_rec.party_rec.party_id;
6259 --Bug 3550989 : Pass orig_system and orig_system_reference to create_org API
6260 l_contact_points_rec.orig_system := 'DNB';
6261 l_contact_points_rec.orig_system_reference := lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0');
6262
6263 IF l_phone_rec.raw_phone_number is not null then
6264 store_contact_point (
6265 l_contact_points_rec,
6266 l_phone_rec,
6267 x_return_status);
6268 END IF;
6269
6270 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6271 RETURN;
6272 END IF;
6273
6274 --Bug 3550989 : Pass orig_system and orig_system_reference to create_org API
6275 l_location_rec.orig_system_reference := lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0');
6276 -- Bug 3417357 : Pass p_creatE_new=TRUE for new parties
6277 store_location (
6278 l_location_rec,
6279 l_organization_rec.party_rec.party_id,
6280 TRUE,
6281 x_return_status);
6282
6283 ELSE
6284
6285 --
6286 --party exists. get all party ids having this DUNS.
6287 --
6288
6289 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_RELATED_DUNS: party exists');
6290
6291
6292 OPEN c1;
6293 LOOP
6294 FETCH c1 INTO l_party_id;
6295 EXIT WHEN c1%NOTFOUND;
6296
6297 l_party_rel_rec.subject_id := l_party_id;
6298 store_party_rel(l_party_rel_rec,
6299 x_return_status);
6300 -- VJN ::: POPULATE PASSED IN OUT VARIABLE
6301 x_conform_party_id := l_party_rel_rec.subject_id ;
6302
6303 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6304 RETURN;
6305 END IF;
6306
6307 l_contact_points_rec.owner_table_id := l_party_id;
6308 -- Bug 4534494: need to pass OSR
6309 l_contact_points_rec.orig_system := 'DNB';
6310 l_contact_points_rec.orig_system_reference := lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0');
6311
6312 IF l_phone_rec.raw_phone_number is not null then
6313
6314 store_contact_point (l_contact_points_rec,
6315 l_phone_rec,
6316 x_return_status);
6317 END IF;
6318
6319 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6320 RETURN;
6321 END IF;
6322 -- Bug 3417357 : Pass p_create_new=FALSE when party is updated
6323 -- Bug 4534494: need to pass OSR
6324 l_location_rec.orig_system_reference := lpad(to_char(p_related_duns_rec.DUNS_NUMBER),9,'0');
6325
6326 store_location( l_location_rec,
6327 l_party_id,
6328 FALSE,
6329 x_return_status);
6330
6331 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6332 RETURN;
6333 END IF;
6334
6335
6336 END LOOP;
6337 CLOSE c1;
6338 END IF;
6339
6340 END IF;
6341
6342 arp_util.debug('HZ_MAP_PARTY_PUB.DO_STORE_RELATED_DUNS (-) ');
6343
6344 END do_store_related_duns;
6345
6346 /*===========================================================================+
6347 | PROCEDURE
6348 | store_party_rel
6349 |
6350 | DESCRIPTION
6351 | store party relationship
6352 |
6353 | SCOPE - PRIVATE
6354 |
6355 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
6356 |
6357 | ARGUMENTS : IN:
6358 | OUT:
6359 | IN/ OUT:
6360 | p_party_rel_rec
6361 | x_return_status
6362 |
6363 | RETURNS : NONE
6364 |
6365 | NOTES
6366 |
6367 | MODIFICATION HISTORY
6368 |
6369 | 19-APR-2004 Dhaval Mehta o Bug 3020636 :
6370 | 1. A party can have only either a HQ or a Parent but not
6371 | both together. For relationship_type = HEADQUARTERS/DIVISION
6372 | or relationship_type = PARENT/SUBSIDIARY End date the previous
6373 | relationship if exists
6374 | 2. While checking for existing relationships, end date only those
6375 | the rel with changed duns number for subject_id
6376 +===========================================================================*/
6377
6378 procedure store_party_rel(
6379 p_party_rel_rec IN OUT NOCOPY HZ_RELATIONSHIP_V2PUB.relationship_rec_type,
6380 x_return_status IN OUT NOCOPY VARCHAR2
6381 ) IS
6382
6383 CURSOR c_old_party_rel IS
6384 SELECT rel.relationship_id, rel.subject_id
6385 FROM hz_relationships rel
6386 WHERE rel.object_id = p_party_rel_rec.object_id
6387 AND rel.relationship_code = p_party_rel_rec.relationship_code
6388 AND rel.relationship_type = p_party_rel_rec.relationship_type
6389 AND rel.actual_content_source = p_party_rel_rec.actual_content_source
6390 AND rel.start_date <= sysdate
6391 AND NVL(rel.end_date, to_date('12/31/4712','MM/DD/YYYY')) > sysdate
6392 AND rel.subject_table_name = 'HZ_PARTIES'
6393 AND rel.object_table_name = 'HZ_PARTIES';
6394 -- AND rel.DIRECTIONAL_FLAG = 'F';
6395
6396 l_msg_count NUMBER;
6397 l_msg_data VARCHAR2(2000);
6398 l_object_version_number1 NUMBER;
6399 l_object_version_number2 NUMBER;
6400
6401 x_relationship_id NUMBER;
6402 x_party_id NUMBER;
6403 x_party_number hz_parties.party_number%TYPE;
6404
6405 l_profile VARCHAR2(1);
6406
6407 TYPE l_old_rel_id_table IS TABLE OF hz_relationships.relationship_id%TYPE
6408 INDEX BY BINARY_INTEGER;
6409
6410 TYPE l_old_sub_id_table IS TABLE OF hz_relationships.subject_id%TYPE
6411 INDEX BY BINARY_INTEGER;
6412
6413 l_old_rel_ids l_old_rel_id_table;
6414 l_old_sub_ids l_old_sub_id_table;
6415
6416 l_old_duns_number hz_organization_profiles.duns_number_c%TYPE;
6417 l_new_duns_number hz_organization_profiles.duns_number_c%TYPE;
6418 l_old_subject_id NUMBER;
6419
6420 l_party_rel_rec HZ_RELATIONSHIP_V2PUB.relationship_rec_type;
6421 l_create_rel BOOLEAN := TRUE;
6422
6423 i NUMBER := 0;
6424
6425 -- Bug 3020636 : Added Local variables and cursor
6426
6427 l_rel_type hz_relationships.relationship_type%TYPE;
6428 l_rel_code hz_relationships.relationship_code%TYPE;
6429 l_rel_id hz_relationships.relationship_id%TYPE;
6430 l_obj_ver_no hz_relationships.object_version_number%TYPE;
6431
6432 CURSOR c_old_parent_hq IS
6433 SELECT rel.relationship_id
6434 FROM hz_relationships rel
6435 WHERE rel.object_id = p_party_rel_rec.object_id
6436 AND rel.relationship_code = l_rel_code
6437 AND rel.relationship_type = l_rel_type
6438 AND rel.actual_content_source = p_party_rel_rec.actual_content_source
6439 AND rel.start_date <= sysdate
6440 AND NVL(rel.end_date, to_date('12/31/4712','MM/DD/YYYY')) > sysdate
6441 AND rel.subject_table_name = 'HZ_PARTIES'
6442 AND rel.object_table_name = 'HZ_PARTIES';
6443
6444
6445 BEGIN
6446
6447 -- Bug 3020636 : for relationship_type = HEADQUARTERS/DIVISION or
6448 -- relationship_type = PARENT/SUBSIDIARY
6449 -- Check if the other type exists for the object_id.
6450 -- a party can have only either a HQ or a Parent but not both together.
6451 -- End date the previous relationship if exists.
6452 if(p_party_rel_rec.relationship_type = 'PARENT/SUBSIDIARY' OR
6453 p_party_rel_rec.relationship_type = 'HEADQUARTERS/DIVISION') then
6454
6455 if(p_party_rel_rec.relationship_code = 'PARENT_OF' and
6456 p_party_rel_rec.relationship_type = 'PARENT/SUBSIDIARY') then
6457 l_rel_type := 'HEADQUARTERS/DIVISION';
6458 l_rel_code := 'HEADQUARTERS_OF';
6459 end if;
6460 if(p_party_rel_rec.relationship_code = 'HEADQUARTERS_OF' and
6461 p_party_rel_rec.relationship_type = 'HEADQUARTERS/DIVISION') then
6462 l_rel_type := 'PARENT/SUBSIDIARY';
6463 l_rel_code := 'PARENT_OF';
6464 end if;
6465
6466 OPEN c_old_parent_hq;
6467 LOOP
6468 FETCH c_old_parent_hq
6469 INTO l_rel_id;
6470 EXIT WHEN c_old_parent_hq%NOTFOUND;
6471
6472 SELECT object_version_number INTO l_obj_ver_no
6473 FROM hz_relationships
6474 WHERE relationship_id = l_rel_id
6475 AND subject_table_name = 'HZ_PARTIES'
6476 AND object_table_name = 'HZ_PARTIES'
6477 AND DIRECTIONAL_FLAG = 'F';
6478
6479
6480 l_party_rel_rec.actual_content_source := p_party_rel_rec.actual_content_source;
6481 l_party_rel_rec.end_date := SYSDATE;
6482 l_object_version_number2 := NULL;
6483 l_party_rel_rec.relationship_id := l_rel_id;
6484 l_party_rel_rec.created_by_module := NULL;
6485 l_party_rel_rec.application_id := NULL;
6486
6487 HZ_RELATIONSHIP_V2PUB.update_relationship(
6488 'F',
6489 l_party_rel_rec,
6490 l_obj_ver_no,
6491 l_object_version_number2,
6492 x_return_status,
6493 l_msg_count,
6494 l_msg_data);
6495
6496 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6497 RETURN;
6498 END IF;
6499 END LOOP;
6500 CLOSE c_old_parent_hq;
6501 end if;
6502
6503 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_PARTY_REL (+) ');
6504
6505 OPEN c_old_party_rel;
6506 LOOP
6507 FETCH c_old_party_rel
6508 INTO l_old_rel_ids(i), l_old_sub_ids(i);
6509 i := i+1;
6510 EXIT WHEN c_old_party_rel%NOTFOUND;
6511 END LOOP;
6512 CLOSE c_old_party_rel;
6513
6514 IF l_old_rel_ids.COUNT = 0 THEN
6515 --Create party rel.
6516 l_create_rel := TRUE;
6517
6518 ELSE
6519 -- Bug 3020636 : Change start
6520 -- End date only relationships with changed duns number
6521 l_create_rel := FALSE;
6522 FOR i IN l_old_rel_ids.FIRST..l_old_rel_ids.LAST LOOP
6523 l_old_subject_id := l_old_sub_ids(i);
6524
6525 --Find the old duns number
6526 SELECT duns_number_c INTO l_old_duns_number
6527 FROM hz_organization_profiles o
6528 WHERE o.party_id = l_old_subject_id
6529 AND o.effective_end_date IS NULL
6530 AND o.actual_content_source = p_party_rel_rec.actual_content_source;
6531
6532 --Find the new duns number
6533 SELECT duns_number_c INTO l_new_duns_number
6534 FROM hz_organization_profiles o
6535 WHERE o.party_id = p_party_rel_rec.subject_id
6536 AND o.effective_end_date IS NULL
6537 AND o.actual_content_source = p_party_rel_rec.actual_content_source;
6538
6539 IF l_old_duns_number = l_new_duns_number THEN
6540 IF l_old_sub_ids(i) = p_party_rel_rec.subject_id THEN
6541 l_create_rel := FALSE;
6542 RETURN;
6543 END IF;
6544
6545 ELSE
6546 --End date old party rel.
6547 SELECT object_version_number INTO l_object_version_number1
6548 FROM hz_relationships
6549 WHERE relationship_id = l_old_rel_ids(i)
6550 AND subject_table_name = 'HZ_PARTIES'
6551 AND object_table_name = 'HZ_PARTIES'
6552 AND DIRECTIONAL_FLAG = 'F';
6553
6554 --do not need to pass in LUD of parties as party is not updated.
6555
6556 l_party_rel_rec.actual_content_source := p_party_rel_rec.actual_content_source;
6557 l_party_rel_rec.end_date := SYSDATE;
6558 l_object_version_number2 := NULL;
6559 l_party_rel_rec.relationship_id := l_old_rel_ids(i);
6560 l_party_rel_rec.created_by_module := NULL;
6561 l_party_rel_rec.application_id := NULL;
6562 HZ_RELATIONSHIP_V2PUB.update_relationship(
6563 'F',
6564 l_party_rel_rec,
6565 l_object_version_number1,
6566 l_object_version_number2,
6567 x_return_status,
6568 l_msg_count,
6569 l_msg_data);
6570
6571 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6572 RETURN;
6573 END IF;
6574 l_create_rel := TRUE;
6575 END IF;
6576 END LOOP;
6577
6578 -- End changes for bug 3020636
6579 END IF;
6580
6581 IF l_create_rel THEN
6582 p_party_rel_rec.start_date := SYSDATE;
6583
6584 --Bug 1721094: generate party number by sequence.
6585 IF fnd_profile.value('HZ_GENERATE_PARTY_NUMBER') = 'N' THEN
6586 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'Y');
6587 l_profile := 'N';
6588 END IF;
6589
6590 arp_util.debug('HZ_MAP_PARTY_PUB.store_party_rel p_party_rel_rec.subject_id = ' || p_party_rel_rec.subject_id );
6591 arp_util.debug('HZ_MAP_PARTY_PUB.store_party_rel p_party_rel_rec.subject_type = ' || p_party_rel_rec.subject_type );
6592
6593 p_party_rel_rec.created_by_module := 'TCA_DNB_MAPPING';
6594 HZ_RELATIONSHIP_V2PUB.create_relationship(
6595 'F',
6596 p_party_rel_rec,
6597 x_relationship_id,
6598 x_party_id,
6599 x_party_number,
6600 x_return_status,
6601 l_msg_count,
6602 l_msg_data);
6603
6604 --Bug 1721094: reset profile option.
6605 IF l_profile = 'N' THEN
6606 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'N');
6607 END IF;
6608
6609 END IF;
6610
6611 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_PARTY_REL (-) ');
6612
6613 END store_party_rel;
6614
6615 /*===========================================================================+
6616 | PROCEDURE
6617 | store_error
6618 |
6619 | DESCRIPTION
6620 | store error message
6621 |
6622 | SCOPE - PRIVATE
6623 |
6624 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
6625 |
6626 | ARGUMENTS : IN:
6627 | p_status
6628 | p_party_interface_id
6629 | OUT:
6630 | IN/ OUT:
6631 |
6632 | RETURNS : NONE
6633 |
6634 | NOTES
6635 |
6636 | MODIFICATION HISTORY
6637 |
6638 +===========================================================================*/
6639
6640 procedure store_error(
6641 p_status VARCHAR2,
6642 p_party_interface_id NUMBER
6643 ) IS
6644 -- l_interface_error_id NUMBER;
6645 l_message_text VARCHAR2(2000);
6646 l_msg_count NUMBER;
6647 BEGIN
6648
6649 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ERROR (+) ');
6650
6651
6652 UPDATE hz_party_interface
6653 SET status = p_status
6654 WHERE party_interface_id = p_party_interface_id;
6655
6656 --reset the message table index used in reading messages to point to the top of the message table.
6657
6658 FND_MSG_PUB.RESET;
6659
6660 FOR I IN 1..FND_MSG_PUB.Count_Msg LOOP
6661 -- SELECT hz_party_interface_errors_s.nextval INTO l_interface_error_id from dual;
6662
6663 l_message_text := FND_MSG_PUB.Get(
6664 p_encoded => FND_API.G_FALSE );
6665
6666 INSERT INTO hz_party_interface_errors (
6667 interface_error_id,
6668 party_interface_id,
6669 message_text,
6670 created_by,
6671 creation_date,
6672 last_updated_by,
6673 last_update_date,
6674 last_update_login)
6675 VALUES (
6676 hz_party_interface_errors_s.nextval ,
6677 p_party_interface_id,
6678 l_message_text,
6679 hz_utility_v2pub.created_by,
6680 hz_utility_v2pub.creation_date,
6681 hz_utility_v2pub.last_updated_by,
6682 hz_utility_v2pub.last_update_date,
6683 hz_utility_v2pub.last_update_login);
6684
6685 END LOOP;
6686
6687 COMMIT; /* commit update to hz_party_interface and inserts into hz_party_interface_errors */
6688
6689 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_ERROR (-) ');
6690
6691 END store_error;
6692
6693 /*===========================================================================+
6694 | PROCEDURE
6695 | store_business_report
6696 |
6697 | DESCRIPTION
6698 | Store business report into org profile.
6699 |
6700 | SCOPE - PRIVATE
6701 |
6702 | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED
6703 |
6704 | ARGUMENTS : IN:
6705 | p_organization_profile_id
6706 | p_business_report
6707 | OUT:
6708 | IN/ OUT:
6709 |
6710 | RETURNS : NONE
6711 |
6712 | NOTES
6713 |
6714 | MODIFICATION HISTORY
6715 |
6716 +===========================================================================*/
6717
6718 procedure store_business_report(
6719 p_organization_profile_id NUMBER,
6720 p_business_report CLOB
6721 ) IS
6722 BEGIN
6723
6724 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_BUSINESS_REPORT(+) ');
6725
6726 UPDATE hz_organization_profiles
6727 SET business_report = p_business_report
6728 WHERE organization_profile_id = p_organization_profile_id;
6729
6730 arp_util.debug('HZ_MAP_PARTY_PUB.STORE_BUSINESS_REPORT(-) ');
6731
6732 END;
6733
6734
6735 procedure map_conc_wrapper(
6736 errbuf OUT NOCOPY VARCHAR2,
6737 retcode OUT NOCOPY VARCHAR2,
6738 p_group_id IN VARCHAR2 := NULL
6739 ) IS
6740 l_group_id NUMBER;
6741
6742 l_x_return_status VARCHAR2(1);
6743 l_x_msg_count NUMBER;
6744 l_x_msg_data VARCHAR2(2000);
6745 l_validation_level NUMBER := FND_API.G_VALID_LEVEL_FULL;
6746
6747 l_count NUMBER;
6748 l_msg_data VARCHAR2(2000);
6749 BEGIN
6750
6751 --convert char to number
6752 l_group_id := TO_NUMBER( p_group_id );
6753
6754 FND_FILE.PUT_LINE( FND_FILE.LOG,
6755 'Concurrent program ARHMAPSB - Map DNB data(+)' );
6756
6757 map(
6758 1,
6759 FND_API.G_TRUE,
6760 FND_API.G_TRUE,
6761 l_group_id,
6762 l_x_return_status,
6763 l_x_msg_count,
6764 l_x_msg_data,
6765 null,
6766 l_validation_level
6767 );
6768
6769 --handle return values
6770 IF ( l_x_return_status <> 'S' ) THEN
6771 errbuf := FND_MESSAGE.GET || ' ' || SQLERRM;
6772 retcode := 2;
6773 END IF;
6774 --reset the message table index used in reading messages to point to the top of the message table.
6775 FND_MSG_PUB.RESET;
6776
6777 --write error message into log file
6778 FOR l_count IN 1..l_x_msg_count LOOP
6779 l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,
6780 FND_API.G_FALSE);
6781 FND_FILE.PUT_LINE( FND_FILE.LOG,
6782 TO_CHAR(l_count) || ' : ' || l_msg_data );
6783 END LOOP;
6784 -- END IF;
6785
6786 FND_FILE.PUT_LINE (FND_FILE.LOG, 'Concurrent program ARHMAPSB - Map DNB data(-)');
6787
6788 END map_conc_wrapper;
6789
6790 --Bug 2802598: If DNB sends lookups which do not present in TCA tables, create them dynamically.
6791 PROCEDURE create_lookup(
6792 p_lookup_code IN VARCHAR2,
6793 p_lookup_type IN VARCHAR2,
6794 x_return_status IN OUT NOCOPY VARCHAR2
6795 ) IS
6796
6797 row_id varchar2(64);
6798 l_dummy VARCHAR2(1);
6799 l_class_code_rec HZ_CLASSIFICATION_V2PUB.class_code_rec_type;
6800 x_msg_count NUMBER;
6801 x_msg_data VARCHAR2(2000);
6802
6803 -- Bug 3822690 : Modify the cursor for better performance
6804 -- 1. Remove upper for lookup type
6805 -- 2. Remove upper for lookup code
6806 -- 3. Add view_application_id = 222
6807 -- 4. Use fnd_lookup_values_vl for translation issues
6808 CURSOR c_check_lookups
6809 IS
6810 SELECT 'Y'
6811 FROM fnd_lookup_values_vl
6812 -- WHERE upper(lookup_type) = upper(p_lookup_type)
6813 -- AND upper(lookup_code) = upper(p_lookup_code)
6814 WHERE lookup_type = p_lookup_type
6815 AND lookup_code = p_lookup_code
6816 AND view_application_id = 222
6817 AND (enabled_flag = 'Y' AND
6818 trunc(sysdate) BETWEEN
6819 trunc(NVL(start_date_active, sysdate)) AND
6820 trunc(NVL(end_date_active, sysdate))
6821 );
6822
6823 BEGIN
6824
6825 SAVEPOINT create_lookup;
6826
6827 OPEN c_check_lookups;
6828 FETCH c_check_lookups INTO l_dummy;
6829
6830 IF c_check_lookups%NOTFOUND
6831 THEN
6832
6833 --create new lookup
6834 Fnd_Lookup_Values_Pkg.Insert_Row(
6835 X_ROWID => row_id,
6836 X_LOOKUP_TYPE => p_lookup_type,
6837 X_SECURITY_GROUP_ID => 0,
6838 X_VIEW_APPLICATION_ID => /*HZ_UTILITY_V2PUB.application_id*/222,-- Bug 3107162
6839 X_LOOKUP_CODE => p_lookup_code,
6840 X_TAG => null,
6841 X_ATTRIBUTE_CATEGORY => null,
6842 X_ATTRIBUTE1 => null,
6843 X_ATTRIBUTE2 => null,
6844 X_ATTRIBUTE3 => null,
6845 X_ATTRIBUTE4 => null,
6846 X_ENABLED_FLAG => 'Y',
6847 X_START_DATE_ACTIVE => sysdate,
6848 X_END_DATE_ACTIVE => null,
6849 X_TERRITORY_CODE => null,
6850 X_ATTRIBUTE5 => null,
6851 X_ATTRIBUTE6 => null,
6852 X_ATTRIBUTE7 => null,
6853 X_ATTRIBUTE8 => null,
6854 X_ATTRIBUTE9 => null,
6855 X_ATTRIBUTE10 => null,
6856 X_ATTRIBUTE11 => null,
6857 X_ATTRIBUTE12 => null,
6858 X_ATTRIBUTE13 => null,
6859 X_ATTRIBUTE14 => null,
6860 X_ATTRIBUTE15 => null,
6861 X_MEANING => p_lookup_code,
6862 X_DESCRIPTION => p_lookup_code,
6863 X_CREATION_DATE => HZ_UTILITY_V2PUB.CREATION_DATE,
6864 X_CREATED_BY => HZ_UTILITY_V2PUB.CREATED_BY,
6865 X_LAST_UPDATE_DATE => HZ_UTILITY_V2PUB.LAST_UPDATE_DATE,
6866 X_LAST_UPDATED_BY => HZ_UTILITY_V2PUB.LAST_UPDATED_BY,
6867 X_LAST_UPDATE_LOGIN => HZ_UTILITY_V2PUB.LAST_UPDATE_LOGIN);
6868
6869 END IF;
6870 CLOSE c_check_lookups;
6871 EXCEPTION
6872
6873 WHEN FND_API.G_EXC_ERROR THEN
6874
6875 ROLLBACK TO create_lookup;
6876 x_return_status := FND_API.G_RET_STS_ERROR;
6877 FND_MSG_PUB.Count_And_Get(
6878 p_encoded => FND_API.G_FALSE,
6879 p_count => x_msg_count,
6880 p_data => x_msg_data);
6881
6882 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6883
6884 ROLLBACK TO create_lookup ;
6885 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6886 FND_MSG_PUB.Count_And_Get(
6887 p_encoded => FND_API.G_FALSE,
6888 p_count => x_msg_count,
6889 p_data => x_msg_data);
6890
6891 WHEN OTHERS THEN
6892
6893 ROLLBACK TO create_lookup;
6894 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6895 FND_MESSAGE.SET_NAME('AR', 'HZ_API_OTHERS_EXCEP');
6896 FND_MESSAGE.SET_TOKEN('ERROR' ,SQLERRM);
6897 FND_MSG_PUB.ADD;
6898 FND_MSG_PUB.Count_And_Get(
6899 p_encoded => FND_API.G_FALSE,
6900 p_count => x_msg_count,
6901 p_data => x_msg_data);
6902
6903 END create_lookup;
6904
6905 --Bug 2802598: If DNB sends lookups which do not present in TCA tables, create them
6906 --dynamically for
6907 -- FAILURE_SCORE_COMMENTARY,
6908 -- CREDIT_SCORE_COMMENTARY,
6909 -- FAILURE_SCORE_OVERRIDE_CODE,
6910 -- REGISTRATION_TYPE
6911 -- LEGAL_STATUS
6912 -- Bug 3809276
6913 -- local_activity_code.
6914 -- Bug 3107162.
6915 -- TOTAL_EMP_MIN_IND,
6916 -- TOTAL_EMPLOYEES_IND,
6917 -- EMP_AT_PRIMARY_ADR_EST_IND
6918 -- EMP_AT_PRIMARY_ADR_MIN_IND.
6919 -- Bug 3848365
6920 -- SIC_CODE1 to SIC_CODE6
6921
6922 PROCEDURE create_dynamic_lookups(
6923 p_party_interface_rec IN HZ_PARTY_INTERFACE%ROWTYPE,
6924 x_return_status IN OUT NOCOPY VARCHAR2
6925 ) IS
6926
6927 -- bug 3809276: added a local variable to store local_activity_code_type
6928 l_local_activity_code_type varchar2(30);
6929
6930 BEGIN
6931
6932 --FAILURE_SCORE_COMMENTARY lookups
6933 IF p_party_interface_rec.failure_score_commentary1 IS NOT NULL THEN
6934 --create new lookup
6935 create_lookup(
6936 p_lookup_code => p_party_interface_rec.failure_score_commentary1,
6937 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6938 x_return_status => x_return_status
6939 );
6940 END IF;
6941 IF p_party_interface_rec.failure_score_commentary2 IS NOT NULL THEN
6942 --create new lookup
6943 create_lookup(
6944 p_lookup_code => p_party_interface_rec.failure_score_commentary2,
6945 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6946 x_return_status => x_return_status
6947 );
6948 END IF;
6949 IF p_party_interface_rec.failure_score_commentary3 IS NOT NULL THEN
6950 --create new lookup
6951 create_lookup(
6952 p_lookup_code => p_party_interface_rec.failure_score_commentary3,
6953 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6954 x_return_status => x_return_status
6955 );
6956 END IF;
6957 IF p_party_interface_rec.failure_score_commentary4 IS NOT NULL THEN
6958 --create new lookup
6959 create_lookup(
6960 p_lookup_code => p_party_interface_rec.failure_score_commentary4,
6961 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6962 x_return_status => x_return_status
6963 );
6964 END IF;
6965 IF p_party_interface_rec.failure_score_commentary5 IS NOT NULL THEN
6966 --create new lookup
6967 create_lookup(
6968 p_lookup_code => p_party_interface_rec.failure_score_commentary5,
6969 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6970 x_return_status => x_return_status
6971 );
6972 END IF;
6973 IF p_party_interface_rec.failure_score_commentary6 IS NOT NULL THEN
6974 --create new lookup
6975 create_lookup(
6976 p_lookup_code => p_party_interface_rec.failure_score_commentary6,
6977 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6978 x_return_status => x_return_status
6979 );
6980 END IF;
6981 IF p_party_interface_rec.failure_score_commentary7 IS NOT NULL THEN
6982 --create new lookup
6983 create_lookup(
6984 p_lookup_code => p_party_interface_rec.failure_score_commentary7,
6985 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6986 x_return_status => x_return_status
6987 );
6988 END IF;
6989 IF p_party_interface_rec.failure_score_commentary8 IS NOT NULL THEN
6990 --create new lookup
6991 create_lookup(
6992 p_lookup_code => p_party_interface_rec.failure_score_commentary8,
6993 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
6994 x_return_status => x_return_status
6995 );
6996 END IF;
6997 IF p_party_interface_rec.failure_score_commentary9 IS NOT NULL THEN
6998 --create new lookup
6999 create_lookup(
7000 p_lookup_code => p_party_interface_rec.failure_score_commentary9,
7001 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
7002 x_return_status => x_return_status
7003 );
7004 END IF;
7005 IF p_party_interface_rec.failure_score_commentary10 IS NOT NULL THEN
7006 --create new lookup
7007 create_lookup(
7008 p_lookup_code => p_party_interface_rec.failure_score_commentary10,
7009 p_lookup_type => 'FAILURE_SCORE_COMMENTARY',
7010 x_return_status => x_return_status
7011 );
7012 END IF;
7013 --CREDIT_SCORE_COMMENTARY lookups
7014 IF p_party_interface_rec.credit_score_commentary1 IS NOT NULL THEN
7015 --create new lookup
7016 create_lookup(
7017 p_lookup_code => p_party_interface_rec.credit_score_commentary1,
7018 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7019 x_return_status => x_return_status
7020 );
7021 END IF;
7022 IF p_party_interface_rec.credit_score_commentary2 IS NOT NULL THEN
7023 --create new lookup
7024 create_lookup(
7025 p_lookup_code => p_party_interface_rec.credit_score_commentary2,
7026 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7027 x_return_status => x_return_status
7028 );
7029 END IF;
7030 IF p_party_interface_rec.credit_score_commentary3 IS NOT NULL THEN
7031 --create new lookup
7032 create_lookup(
7033 p_lookup_code => p_party_interface_rec.credit_score_commentary3,
7034 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7035 x_return_status => x_return_status
7036 );
7037 END IF;
7038 IF p_party_interface_rec.credit_score_commentary4 IS NOT NULL THEN
7039 --create new lookup
7040 create_lookup(
7041 p_lookup_code => p_party_interface_rec.credit_score_commentary4,
7042 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7043 x_return_status => x_return_status
7044 );
7045 END IF;
7046 IF p_party_interface_rec.credit_score_commentary5 IS NOT NULL THEN
7047 --create new lookup
7048 create_lookup(
7049 p_lookup_code => p_party_interface_rec.credit_score_commentary5,
7050 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7051 x_return_status => x_return_status
7052 );
7053 END IF;
7054 IF p_party_interface_rec.credit_score_commentary6 IS NOT NULL THEN
7055 --create new lookup
7056 create_lookup(
7057 p_lookup_code => p_party_interface_rec.credit_score_commentary6,
7058 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7059 x_return_status => x_return_status
7060 );
7061 END IF;
7062 IF p_party_interface_rec.credit_score_commentary7 IS NOT NULL THEN
7063 --create new lookup
7064 create_lookup(
7065 p_lookup_code => p_party_interface_rec.credit_score_commentary7,
7066 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7067 x_return_status => x_return_status
7068 );
7069 END IF;
7070 IF p_party_interface_rec.credit_score_commentary8 IS NOT NULL THEN
7071 --create new lookup
7072 create_lookup(
7073 p_lookup_code => p_party_interface_rec.credit_score_commentary8,
7074 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7075 x_return_status => x_return_status
7076 );
7077 END IF;
7078 IF p_party_interface_rec.credit_score_commentary9 IS NOT NULL THEN
7079 --create new lookup
7080 create_lookup(
7081 p_lookup_code => p_party_interface_rec.credit_score_commentary9,
7082 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7083 x_return_status => x_return_status
7084 );
7085 END IF;
7086 IF p_party_interface_rec.credit_score_commentary10 IS NOT NULL THEN
7087 --create new lookup
7088 create_lookup(
7089 p_lookup_code => p_party_interface_rec.credit_score_commentary10,
7090 p_lookup_type => 'CREDIT_SCORE_COMMENTARY',
7091 x_return_status => x_return_status
7092 );
7093 END IF;
7094 --FAILURE_SCORE_OVERRIDE_CODE lookups
7095 IF p_party_interface_rec.failure_score_override_code IS NOT NULL THEN
7096 --create new lookup
7097 create_lookup(
7098 p_lookup_code => p_party_interface_rec.failure_score_override_code,
7099 p_lookup_type => 'FAILURE_SCORE_OVERRIDE_CODE',
7100 x_return_status => x_return_status
7101 );
7102 END IF;
7103 IF p_party_interface_rec.credit_score_override_code IS NOT NULL THEN
7104 --create new lookup
7105 create_lookup(
7106 p_lookup_code => p_party_interface_rec.credit_score_override_code,
7107 p_lookup_type => 'FAILURE_SCORE_OVERRIDE_CODE',
7108 x_return_status => x_return_status
7109 );
7110 END IF;
7111 --legal_status
7112 IF p_party_interface_rec.legal_status IS NOT NULL THEN
7113 --create new lookup
7114 create_lookup(
7115 p_lookup_code => p_party_interface_rec.legal_status,
7116 p_lookup_type => 'LEGAL_STATUS',
7117 x_return_status => x_return_status
7118 );
7119 END IF;
7120 --REGISTRATION_TYPE
7121 IF p_party_interface_rec.registration_type IS NOT NULL THEN
7122 --create new lookup
7123 create_lookup(
7124 p_lookup_code => p_party_interface_rec.registration_type,
7125 p_lookup_type => 'REGISTRATION_TYPE',
7126 x_return_status => x_return_status
7127 );
7128 END IF;
7129
7130 --Bug: 3809276
7131 --LOCAL_ACTIVITY_CODE_TYPE
7132 l_local_activity_code_type := p_party_interface_rec.local_activity_code_type;
7133
7134 IF l_local_activity_code_type = '4' OR l_local_activity_code_type = '5'
7135 THEN
7136 l_local_activity_code_type := 'NACE';
7137 END IF;
7138 IF p_party_interface_rec.local_activity_code IS NOT NULL THEN
7139 --create new lookup
7140 create_lookup(
7141 p_lookup_code => p_party_interface_rec.local_activity_code,
7142 p_lookup_type => l_local_activity_code_type,
7143 x_return_status => x_return_status
7144 );
7145 END IF;
7146
7147 --End of bug 3809276
7148
7149 -- Bug 3107162.
7150 IF p_party_interface_rec.total_emp_est_ind IS NOT NULL THEN
7151 create_lookup(
7152 p_lookup_code => p_party_interface_rec.total_emp_est_ind,
7153 p_lookup_type => 'TOTAL_EMP_EST_IND',
7154 x_return_status => x_return_status
7155 );
7156 END IF;
7157
7158 IF p_party_interface_rec.total_emp_min_ind IS NOT NULL THEN
7159 create_lookup(
7160 p_lookup_code => p_party_interface_rec.total_emp_min_ind,
7161 p_lookup_type => 'TOTAL_EMP_MIN_IND',
7162 x_return_status => x_return_status
7163 );
7164 END IF;
7165
7166
7167 IF p_party_interface_rec.total_employees_ind IS NOT NULL THEN
7168
7169 create_lookup(
7170 p_lookup_code => p_party_interface_rec.total_employees_ind,
7171 p_lookup_type => 'TOTAL_EMPLOYEES_INDICATOR',
7172 x_return_status => x_return_status
7173 );
7174 END IF;
7175
7176 IF p_party_interface_rec.emp_at_primary_adr_est_ind IS NOT NULL THEN
7177 create_lookup(
7178 p_lookup_code => p_party_interface_rec.emp_at_primary_adr_est_ind,
7179 p_lookup_type => 'EMP_AT_PRIMARY_ADR_EST_IND',
7180 x_return_status => x_return_status
7181 );
7182 END IF;
7183
7184 IF p_party_interface_rec.emp_at_primary_adr_min_ind IS NOT NULL THEN
7185 create_lookup(
7186 p_lookup_code => p_party_interface_rec.emp_at_primary_adr_min_ind,
7187 p_lookup_type => 'EMP_AT_PRIMARY_ADR_MIN_IND',
7188 x_return_status => x_return_status
7189 );
7190 END IF;
7191
7192 IF p_party_interface_rec.sic_code1 IS NOT NULL THEN
7193 create_lookup(
7194 p_lookup_code => p_party_interface_rec.sic_code1,
7195 p_lookup_type => p_party_interface_rec.sic_code_type,
7196 x_return_status => x_return_status
7197 );
7198 END IF;
7199
7200 IF p_party_interface_rec.sic_code2 IS NOT NULL THEN
7201 create_lookup(
7202 p_lookup_code => p_party_interface_rec.sic_code2,
7203 p_lookup_type => p_party_interface_rec.sic_code_type,
7204 x_return_status => x_return_status
7205 );
7206 END IF;
7207
7208 IF p_party_interface_rec.sic_code3 IS NOT NULL THEN
7209 create_lookup(
7210 p_lookup_code => p_party_interface_rec.sic_code3,
7211 p_lookup_type => p_party_interface_rec.sic_code_type,
7212 x_return_status => x_return_status
7213 );
7214 END IF;
7215
7216 IF p_party_interface_rec.sic_code4 IS NOT NULL THEN
7217 create_lookup(
7218 p_lookup_code => p_party_interface_rec.sic_code4,
7219 p_lookup_type => p_party_interface_rec.sic_code_type,
7220 x_return_status => x_return_status
7221 );
7222 END IF;
7223
7224 IF p_party_interface_rec.sic_code5 IS NOT NULL THEN
7225 create_lookup(
7226 p_lookup_code => p_party_interface_rec.sic_code5,
7227 p_lookup_type => p_party_interface_rec.sic_code_type,
7228 x_return_status => x_return_status
7229 );
7230 END IF;
7231
7232 IF p_party_interface_rec.sic_code6 IS NOT NULL THEN
7233 create_lookup(
7234 p_lookup_code => p_party_interface_rec.sic_code6,
7235 p_lookup_type => p_party_interface_rec.sic_code_type,
7236 x_return_status => x_return_status
7237 );
7238 END IF;
7239
7240 EXCEPTION
7241 WHEN OTHERS THEN
7242 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7243 FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_OTHERS_EXCEP' );
7244 FND_MESSAGE.SET_TOKEN( 'ERROR' ,SQLERRM );
7245 FND_MSG_PUB.ADD;
7246 END create_dynamic_lookups;
7247
7248 END HZ_MAP_PARTY_PUB;
7249