DBA Data[Home] [Help]

PACKAGE BODY: APPS.AMS_LISTIMPORT_PVT

Source


1 PACKAGE BODY AMS_ListImport_PVT AS
2 /* $Header: amsvimlb.pls 120.14 2012/01/03 11:27:36 nkjaiswa ship $ */
3 
4 -----------------------------------------------------------
5 
6 -- PACKAGE
7 --   AMS_ListImport_PVT
8 --
9 -- PURPOSE
10 --   This purpose of this program is to create organization,person
11 --   ,party relationship, org contacts, locations , party sites,
12 --   email and phone records for B2B or B2C type customer's
13 --
14 -- 	Call TCA API's to create the records in HZ schema.
15 --
16 --
17 --	 For B2B creates the following  using TCA API's
18 --
19 --		 1. 	Create organization
20 --		 2. 	Create Person
21 --		 3. 	Create Party Relation
22 --		 4. 	Create Party for Party Relationship
23 --		 5. 	Create Org contact
24 --		 6. 	Create Location (if address is available)
25 --		 7. 	Create Party Site (if address  is available)
26 --		 8. 	Create Contact Points (if contact points are available)
27 --
28 --
29 --	 For B2C creates the following  using TCA API's
30 --
31 --		1. 	Create Person
32 --		2. 	Create Location (if address is available)
33 --		3. 	Create Party Site (if address  is available)
34 --		4. 	Create Contact Points (if contact points are available)
35 --
36 -- PROCEDURES
37 --       list_import_to_hz
38 --
39 -- PARAMETERS
40 --           INPUT
41 --               p_import_list_header_id NUMBER.
42 --
43 --           OUTPUT
44 --              Errbuf                  VARCHAR2 -- Conc Pgm Error mesgs.
45 --              RetCode                 VARCHAR2 -- Conc Pgm Error Code.
46 --                                      0 - Success, 2 - Failure.
47 --
48 -- HISTORY amsvimlb.pls
49 -- 19-Mar-2001 usingh      Created.
50 -- ---------------------------------------------------------
51 G_ARC_IMPORT_HEADER  CONSTANT VARCHAR2(30) := 'IMPH';
52 g_pkg_name  CONSTANT VARCHAR2(30):='AMS_LISTIMPORT_PVT';
53 g_prof VARCHAR2(50) := fnd_profile.value('HZ_EXECUTE_API_CALLOUTS');
54 --
55 -- This program processes the xml data.
56 --
57 AMS_DEBUG_HIGH_ON boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH);
58 AMS_DEBUG_LOW_ON boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW);
59 AMS_DEBUG_MEDIUM_ON boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM);
60 
61 -- SOLIN, Bug 3792806
62 -- Using binded variables to replace literals.
63 G_STATUS_SUCCESS   CONSTANT VARCHAR2(30) := 'SUCCESS';
64 G_STATUS_DUPLICATE CONSTANT VARCHAR2(30) := 'DUPLICATE';
65 G_STATUS_ERROR     CONSTANT VARCHAR2(30) := 'ERROR';
66 G_STATUS_RELOAD    CONSTANT VARCHAR2(30) := 'RELOAD';
67 -- SOLIN, end
68 
69 PROCEDURE Process_b2b_xml_data (
70     p_import_list_header_id    IN    NUMBER,
71     p_xml_element_id		IN    NUMBER,
72     p_cust_tbl                  IN OUT NOCOPY   cust_data_in_tbl,
73     x_return_status             OUT NOCOPY   VARCHAR2,
74     x_msg_data                  OUT NOCOPY   VARCHAR2
75 );
76 
77 --
78 -- This program processes the xml data.
79 --
80 PROCEDURE Process_b2c_xml_data (
81     p_import_list_header_id    IN    NUMBER,
82     p_xml_element_id            IN    NUMBER,
83     p_cust_tbl                  IN OUT NOCOPY   cust_b2c_data_in_tbl,
84     x_return_status             OUT NOCOPY   VARCHAR2,
85     x_msg_data                  OUT NOCOPY   VARCHAR2
86 );
87 
88 --
89 -- This program populates the ams_imp-source_lines table.
90 --
91 Procedure      Create_b2b_src_lines(
92                 p_import_list_header_id   IN number,
93                 p_cust_b2b_tbl            in cust_data_in_tbl,
94                 x_return_status           OUT NOCOPY varchar2,
95                 x_msg_data                OUT NOCOPY varchar2) ;
96 
97 --
98 -- This program populates the ams_imp-source_lines table.
99 --
100 Procedure      Create_b2c_src_lines(
101                 p_import_list_header_id   IN number,
102                 p_cust_b2c_tbl            in cust_b2c_data_in_tbl,
103                 x_return_status           OUT NOCOPY varchar2,
104                 x_msg_data                OUT NOCOPY varchar2) ;
105 
106 --
107 -- This procedure validates the date column.
108 --
109 
110 procedure date_validate (
111    p_import_list_header_id    IN    NUMBER,
112    p_import_source_line_id    IN    NUMBER,
113    p_batch_id			IN    NUMBER,
114    p_column1		      IN    VARCHAR2,
115    p_column2		      IN    VARCHAR2,
116    p_column3		      IN    VARCHAR2,
117    p_column4		      IN    VARCHAR2,
118    p_column5		      IN    VARCHAR2,
119    p_column6		      IN    VARCHAR2
120 			);
121 --
122 -- This procedure generates the status of import
123 --
124 --
125 PROCEDURE process_status_code (
126    p_import_list_header_id    IN    NUMBER
127                             );
128 
129 --
130 -- This procedure is used to capture lead errors.
131 --
132 --
133 PROCEDURE capture_lead_error(
134    p_import_list_header_id    IN    NUMBER
135                             );
136 
137 --
138 -- for XML updates the error in the element table
139 --
140 PROCEDURE update_xml_error_text (
141    				 p_import_list_header_id    IN    NUMBER,
142                                  p_import_type        IN varchar2);
143 
144 
145 --
146 -- This procedure creates list notes from import
147 --
148 --
149 PROCEDURE create_list_note
150         (  p_import_list_header_id in number,
151            p_import_source_line_id in number,
152            p_party_id             in number,
153            p_source_object_code   in varchar2,
154            p_note_text            in varchar2,
155            x_return_status         OUT NOCOPY    VARCHAR2,
156            x_msg_count             OUT NOCOPY    NUMBER,
157            x_msg_data              OUT NOCOPY    VARCHAR2
158         );
159 
160 
161 --
162 -- This procedure is used to update the status for b2b/b2c import.
163 --
164 --
165 PROCEDURE update_cust_import_status(
166    p_import_list_header_id    IN    NUMBER
167                             );
168 
169 --
170 -- This procedure is updates the records with request_id ordered by party_name
171 --
172 --
173 PROCEDURE org_party_update(
174    p_import_list_header_id IN    NUMBER,
175    p_request_id		   IN    NUMBER,
176    p_batch_size		   IN    NUMBER,
177    x_return_status            OUT NOCOPY    VARCHAR2,
178    x_msg_count                OUT NOCOPY    NUMBER,
179    x_msg_data                 OUT NOCOPY    VARCHAR2
180                        );
181 
182 --
183 -- This procedure is used for existence checking for organization
184 --
185 --
186 PROCEDURE org_existence_checking(
187    p_import_list_header_id IN    NUMBER,
188    x_return_status            OUT NOCOPY    VARCHAR2,
189    x_msg_count                OUT NOCOPY    NUMBER,
190    x_msg_data                 OUT NOCOPY    VARCHAR2
191                        );
192 
193 --
194 -- This procedure is used for existence checking for organization with orig system reference
195 --
196 --
197 PROCEDURE org_existence_checking_osr(
198    p_import_list_header_id IN    NUMBER,
199    x_return_status            OUT NOCOPY    VARCHAR2,
200    x_msg_count                OUT NOCOPY    NUMBER,
201    x_msg_data                 OUT NOCOPY    VARCHAR2
202                        );
203 
204 --
205 -- This procedure is used for existence checking for Person
206 --
207 --
208 PROCEDURE per_existence_checking(
209    p_import_list_header_id IN   NUMBER,
210    x_return_status            OUT NOCOPY    VARCHAR2,
211    x_msg_count                OUT NOCOPY    NUMBER,
212    x_msg_data                 OUT NOCOPY    VARCHAR2
213                        );
214 --
215 -- This procedure is used for existence checking for Person with osr
216 --
217 --
218 PROCEDURE per_existence_checking_osr(
219    p_import_list_header_id IN   NUMBER,
220    x_return_status            OUT NOCOPY    VARCHAR2,
221    x_msg_count                OUT NOCOPY    NUMBER,
222    x_msg_data                 OUT NOCOPY    VARCHAR2
223                        );
224 --
225 -- This procedure is used for existence checking for organization contacts
226 --
227 --
228 PROCEDURE org_cont_existence_checking(
229    p_import_list_header_id IN    NUMBER,
230    x_return_status            OUT NOCOPY    VARCHAR2,
231    x_msg_count                OUT NOCOPY    NUMBER,
232    x_msg_data                 OUT NOCOPY    VARCHAR2
233                        );
234 
235 --
236 -- This procedure is used for existence checking for organization contacts with osr
237 --
238 --
239 PROCEDURE org_cont_existence_chk_osr(
240    p_import_list_header_id IN    NUMBER,
241    x_return_status            OUT NOCOPY    VARCHAR2,
242    x_msg_count                OUT NOCOPY    NUMBER,
243    x_msg_data                 OUT NOCOPY    VARCHAR2
244                        );
245 
246 --
247 -- This procedure is used for existence checking for organization address
248 --
249 --
250 PROCEDURE org_address_existence_checking(
251    p_import_list_header_id IN    NUMBER,
252    x_return_status            OUT NOCOPY    VARCHAR2,
253    x_msg_count                OUT NOCOPY    NUMBER,
254    x_msg_data                 OUT NOCOPY    VARCHAR2
255                        );
256 
257 --
258 -- This procedure is used for existence checking for organization address
259 --
260 --
261 PROCEDURE org_address1_exist_checking(
262    p_import_list_header_id IN    NUMBER,
263    x_return_status            OUT NOCOPY    VARCHAR2,
264    x_msg_count                OUT NOCOPY    NUMBER,
265    x_msg_data                 OUT NOCOPY    VARCHAR2
266                        );
267 
268 --
269 -- This procedure is used for existence checking for person address
270 --
271 --
272 PROCEDURE per_address_existence_checking(
273    p_import_list_header_id IN   NUMBER,
274    x_return_status            OUT NOCOPY    VARCHAR2,
275    x_msg_count                OUT NOCOPY    NUMBER,
276    x_msg_data                 OUT NOCOPY    VARCHAR2
277                        );
278 
279 
280 --
281 -- This procedure is updates the records with transposed phone number.
282 --
283 --
284 PROCEDURE gen_transposed_phone_number(
285    p_import_list_header_id IN   NUMBER,
286    x_return_status            OUT NOCOPY    VARCHAR2,
287    x_msg_count                OUT NOCOPY    NUMBER,
288    x_msg_data                 OUT NOCOPY    VARCHAR2
289                        );
290 
291 -- *********************************************************
292 --
293 -- This function returns the value for the element.
294 --
295 FUNCTION  Get_Element_VALUE (p_column_name IN VARCHAR2,
296                              p_search_tbl  IN AMS_IMPORT_XML_PVT.xml_element_set_type)
297 RETURN  VARCHAR2
298 IS
299 x_element_id   NUMBER;
300 x_value        VARCHAR2(2000) := null;
301 BEGIN
302      for i in 1..p_search_tbl.COUNT loop
303 
304         if (p_search_tbl(i).column_name = p_column_name) then
305               x_value      :=  p_search_tbl(i).data;
306               exit;
307         end if;
308      end loop;
309     RETURN (x_value);
310 END  Get_Element_VALUE;
311 
312 
313 --
314 -- This function returns the id for the element.
315 --
316 FUNCTION  Get_Element_ID (p_column_name IN VARCHAR2,
317                              p_search_tbl  IN AMS_IMPORT_XML_PVT.xml_element_set_type)
318 RETURN NUMBER
319 IS
320 x_element_id   NUMBER;
321 x_value        VARCHAR2(2000);
322 BEGIN
323      for i in 1..p_search_tbl.COUNT loop
324 
325         if (p_search_tbl(i).column_name = p_column_name) then
326               x_element_id :=  p_search_tbl(i).imp_xml_element_id;
327               exit;
328         end if;
329      end loop;
330     RETURN (x_element_id);
331 END  Get_Element_ID;
332 
333 
334 --
335 -- ---------------------------------------------------------
336 -- This concurrent program populates the data to TCA tables
337 -- from OMO table.
338 --
339 
340 PROCEDURE list_import_to_hz (
341 			    Errbuf          OUT NOCOPY     VARCHAR2,
342 			    Retcode         OUT NOCOPY     VARCHAR2,
343 			    p_import_list_header_id NUMBER,
344 			    p_number_of_processes NUMBER DEFAULT 1
345 			    ) IS
346 x_return_status          	varchar(1);
347 l_ret_status             	varchar(1);
348 x_msg_count		     	number;
349 x_msg_data		     	varchar(4000);
350 x_b2b				varchar(30);
351 x_tmp_var                  	VARCHAR2(4000);
352 x_tmp_var1                 	VARCHAR2(4000);
353 l_return_status                 VARCHAR2(1);
354 i_import_source_line_id         number;
355 i_number_of_rows_processed      number := 0;
356 i_party_id 			number;
357 
358 L_COUNT          NUMBER := 0;
359 l_overlay  	VARCHAR2(1);
360 l_b2b_party_id    number;
361 l_b2c_party_id    number;
362 l_enabled_flag     VARCHAR2(1);
363 x_new_party        VARCHAR2(1);
364 x_component_name   VARCHAR2(60);
365 x_notes                         varchar(2000);
366 x_source_object_code            varchar2(60);
367 l_sa_email        VARCHAR2(2000);
368 l_vr_code          VARCHAR2(30);
369 l_vr_code_exists   VARCHAR2(1);
370 l_resource_id     number;
371 -- sranka 1/14/2003
372 -- added l_import_source_line_id
373 l_import_source_line_id number;
374 
375 l_header_status         VARCHAR2(30);
376 l_request_id        number;
377 l_total_recs            number;
378 l_batch_size            number;
379 l_numb_of_inst          number;
380 l_lookup_code           varchar2(60);
381 l_user_status_id        number;
382 l_mod                   number;
383 new_request_id          number;
384 l_parent_request_id          number;
385 
386 -- For the Parent Wait for child to finish
387 l_req_data               VARCHAR2(10);
388 l_req_data_counter       NUMBER;
389 i_batch_size             number;
390 
391 
392 cursor c_header_status is
393 select nvl(batch_size,0),parent_request_id from ams_imp_list_headers_all
394 where import_list_header_id = p_import_list_header_id;
395 
396 cursor c_total_recs is
397 select count(*) from ams_imp_source_lines
398 where import_list_header_id = p_import_list_header_id
399   and load_status in ('ACTIVE','RELOAD');
400 
401 
402 
403 -- Cursor to check if it's B2B or B2C party type.
404 
405 cursor b2borb2c is
406 	  select import_type from ams_imp_list_headers_all
407 	  where  import_list_header_id = p_import_list_header_id;
408 
409 
410 /*  For Mapped party */
411 cursor party_mapped is
412 SELECT 'Y'  FROM ams_list_src_fields sf,
413 ams_imp_list_headers_all hd
414 WHERE sf.field_column_name = 'PARTY_ID'
415   AND sf.enabled_flag = 'Y'
416   AND sf.list_source_type_id = hd.list_source_type_id
417   and hd.import_type = 'CUSTOMER'
418   AND hd.import_list_header_id = p_import_list_header_id;
419 
420 -- Cursor for B2B party type
421 
422 cursor b2b is
423  SELECT
424  IMPORT_SOURCE_LINE_ID,
425  PARTY_NAME,
426  FISCAL_YEAREND_MONTH,
427  DUNS_NUMBER,
428  EMPLOYEES_TOTAL,
429  LINE_OF_BUSINESS,
430  YEAR_ESTABLISHED,
431  TAX_REFERENCE,
432  CEO_NAME,
433  PERSON_FIRST_NAME,
434  PERSON_MIDDLE_NAME,
435  PERSON_LAST_NAME,
436  PERSON_NAME_SUFFIX,
437  PERSON_name_prefix,
438  -- to_date(BEST_TIME_CONTACT_BEGIN,'MM/DD/YYYY'),
439  -- to_date(BEST_TIME_CONTACT_END,'MM/DD/YYYY'),
440  COUNTRY,
441  ADDRESS1,
442  ADDRESS2,
443  CITY,
444  COUNTY,
445  STATE,
446  PROVINCE,
447  POSTAL_CODE,
448  --TIME_ZONE,
449  EMAIL_ADDRESS,
450  PHONE_COUNTRY_CODE,
451  PHONE_AREA_CODE,
452  PHONE_NUMBER,
453  PHONE_EXTENTION,
454  DEPARTMENT,
455  JOB_TITLE,
456  JOB_TITLE_CODE, -- 5033551
457  DECISION_MAKER_FLAG,
458  SIC_CODE,
459  SIC_CODE_TYPE,
460 --  TOTAL_NUM_OF_ORDERS,
461 -- TOTAL_ORDERED_AMOUNT,
462 -- to_date(LAST_ORDERED_DATE,'MM/DD/YYYY'),
463  ANALYSIS_FY         ,
464  CURR_FY_POTENTIAL_REVENUE,
465  NEXT_FY_POTENTIAL_REVENUE,
466  GSA_INDICATOR_FLAG       ,
467  MISSION_STATEMENT        ,
468  ORGANIZATION_NAME_PHONETIC,
469  CATEGORY_CODE              ,
470  JGZZ_FISCAL_CODE           ,
471  -- TAX_NAME                   ,
472  ADDRESS3                   ,
473  ADDRESS4                   ,
474  ADDRESS_LINES_PHONETIC     ,
475  -- APARTMENT_FLAG             ,
476  -- bug 4641591: columns obsolete
477  -- PO_BOX_NUMBER              ,
478  --  HOUSE_NUMBER               ,
479  --  STREET_SUFFIX              ,
480  -- SECONDARY_SUFFIX_ELENENT   ,
481  --  STREET                     ,
482  -- RURAL_ROUTE_TYPE           ,
483  -- RURAL_ROUTE_NUMBER         ,
484  --  STREET_NUMBER              ,
485  --  FLOOR                      ,
486  --  SUITE                      ,
487  POSTAL_PLUS4_CODE          ,
488  -- OVERSEAS_ADDRESS_FLAG      ,
489  identifying_address_flag   ,
490  party_id ,
491 -- to_date(ADDRESS_EFFECTIVE_DATE,'MM/DD/YYYY'),
492 -- to_date(ADDRESS_EXPIRATION_DATE,'MM/DD/YYYY'),
493 ADDRESS_EFFECTIVE_DATE,
494 ADDRESS_EXPIRATION_DATE,
495 --ANNUAL_REVENUE,
496 --ANNUAL_REVENUE_CURRENCY,
497 BRANCH_FLAG,
498 NVL(BUSINESS_LINE,LINE_OF_BUSINESS),
499 BUSINESS_SCOPE,
500 CHIEF_EXECUTIVE_TITLE,
501 CONGRESSIONAL_DISTRICT_CODE,
502 CONTROL_YEAR,
503 CORPORATION_CLASS,
504 CREDIT_SCORE,
505 CREDIT_SCORE_COMMENTARY,
506 --CUSTOMER_CATEGORY,
507 DB_RATING,
508 DATE_OF_BIRTH,
509 DATE_OF_DEATH,
510 -- to_date(DATE_OF_BIRTH,'MM/DD/YYYY'),
511 -- to_date(DATE_OF_DEATH,'MM/DD/YYYY'),
512 DEBARMENTS_COUNT,
513 DEBARTMENTS_DATE,
514 -- to_date(DEBARTMENTS_DATE,'MM/DD/YYYY'),
515 DECLARED_ETHNICITY,
516 DEPARTMENT_INDICATOR,
517 DESCRIPTION,
518 DISADVANTAGED_INDICATOR,
519 ENQUIRY_DUNS,
520 EXPORT_INDICATOR,
521 FAILURE_SCORE,
522 FAILURE_SCORE_COMMENTARY,
523 FAILURE_SCORE_NATL_PERCENTILE,
524 FAILURE_SCORE_OVERRIDE_CODE,
525 --FISCAL_CODE,
526 GLOBAL_FAILURE_SCORE,
527 HEADQUARTER_BRANCH_INDICATOR,
528 HEAD_OF_HOUSEHOLD_FLAG,
529 HOUSEHOLD_SIZE,
530 IMPORT_INDICATOR,
531 ORGANIZATION_KNOWN_AS,
532 ORGANIZATION_KNOWN_AS2,
533 ORGANIZATION_KNOWN_AS3,
534 ORGANIZATION_KNOWN_AS4,
535 ORGANIZATION_KNOWN_AS5,
536 PERSON_KNOWN_AS,
537 PERSON_KNOWN_AS2,
538 PERSON_KNOWN_AS3,
539 PERSON_KNOWN_AS4,
540 PERSON_KNOWN_AS5,
541 LABOR_SURPLUS_INDICATOR,
542 LOCAL_ACTIVITY_CODE,
543 LOCAL_ACTIVITY_CODE_TYPE,
544 LOCATION_DIRECTIONS ,
545 --LOCATION_STATUS,
546 MARITAL_STATUS,
547 -- to_date(MARITAL_STATUS_EFFECTIVE_DATE,'MM/DD/YYYY'),
548 MARITAL_STATUS_EFFECTIVE_DATE,
549 MINORITY_OWNED_INDICATOR,
550 MINORITY_OWNED_TYPE,
551 --ORGANIZATION_ALIAS,
552 ORGANIZATION_TYPE,
553 ORGANIZATION_URL,
554 OUT_OF_BUSINESS_INDICATOR,
555 PERSONAL_INCOME,
556 PERSON_ACADEMIC_TITLE,
557 PERSON_FIRST_NAME_PHONETIC,
558 PERSON_LAST_NAME_PHONETIC,
559 MIDDLE_NAME_PHONETIC,
560 PERSON_NAME_PHONETIC,
561 PERSON_PREVIOUS_TITLE_NAME,
562 PLACE_OF_BIRTH,
563 --PREFERRED_NAME,
564 PRINCIPAL_NAME,
565 PRINCIPAL_TITLE,
566 PUBLIC_PRIVATE_OWNERSHIP_FLAG,
567 RENT_OWNED_INDICATOR,
568 --RENT_OWNER_INDICATOR,
569 SECOND_TITLE,
570 SHORT_DESCRIPTION,
571 SMALL_BUSINESS_INDICATOR,
572 -- TAX_ID,
573 WOMAN_OWNED_INDICATOR,
574 ORGANIZATION_ATTRIBUTE1,
575 ORGANIZATION_ATTRIBUTE2,
576 ORGANIZATION_ATTRIBUTE3,
577 ORGANIZATION_ATTRIBUTE4,
578 ORGANIZATION_ATTRIBUTE5,
579 ORGANIZATION_ATTRIBUTE6,
580 ORGANIZATION_ATTRIBUTE7,
581 ORGANIZATION_ATTRIBUTE8,
582 ORGANIZATION_ATTRIBUTE9,
583 ORGANIZATION_ATTRIBUTE10,
584 ORGANIZATION_ATTRIBUTE11,
585 ORGANIZATION_ATTRIBUTE12,
586 ORGANIZATION_ATTRIBUTE13,
587 ORGANIZATION_ATTRIBUTE14,
588 ORGANIZATION_ATTRIBUTE15,
589 PERSON_ATTRIBUTE1,
590 PERSON_ATTRIBUTE2,
591 PERSON_ATTRIBUTE3,
592 PERSON_ATTRIBUTE4,
593 PERSON_ATTRIBUTE5,
594 PERSON_ATTRIBUTE6,
595 PERSON_ATTRIBUTE7,
596 PERSON_ATTRIBUTE8,
597 PERSON_ATTRIBUTE9,
598 PERSON_ATTRIBUTE10,
599 PERSON_ATTRIBUTE11,
600 PERSON_ATTRIBUTE12,
601 PERSON_ATTRIBUTE13,
602 PERSON_ATTRIBUTE14,
603 PERSON_ATTRIBUTE15,
604 ORG_CONTACT_ATTRIBUTE1,
605 ORG_CONTACT_ATTRIBUTE2,
606 ORG_CONTACT_ATTRIBUTE3,
607 ORG_CONTACT_ATTRIBUTE4,
608 ORG_CONTACT_ATTRIBUTE5,
609 ORG_CONTACT_ATTRIBUTE6,
610 ORG_CONTACT_ATTRIBUTE7,
611 ORG_CONTACT_ATTRIBUTE8,
612 ORG_CONTACT_ATTRIBUTE9,
613 ORG_CONTACT_ATTRIBUTE10,
614 ORG_CONTACT_ATTRIBUTE11,
615 ORG_CONTACT_ATTRIBUTE12,
616 ORG_CONTACT_ATTRIBUTE13,
617 ORG_CONTACT_ATTRIBUTE14,
618 ORG_CONTACT_ATTRIBUTE15,
619 ADDRESS_ATTRIBUTE1,
620 ADDRESS_ATTRIBUTE2,
621 ADDRESS_ATTRIBUTE3,
622 ADDRESS_ATTRIBUTE4,
623 ADDRESS_ATTRIBUTE5,
624 ADDRESS_ATTRIBUTE6,
625 ADDRESS_ATTRIBUTE7,
626 ADDRESS_ATTRIBUTE8,
627 ADDRESS_ATTRIBUTE9,
628 ADDRESS_ATTRIBUTE10,
629 ADDRESS_ATTRIBUTE11,
630 ADDRESS_ATTRIBUTE12,
631 ADDRESS_ATTRIBUTE13,
632 ADDRESS_ATTRIBUTE14,
633 ADDRESS_ATTRIBUTE15,
634 FAX_COUNTRY_CODE,
635 FAX_AREA_CODE,
636 FAX_NUMBER,
637 ORG_ATTRIBUTE_CATEGORY,
638 PERSON_ATTRIBUTE_CATEGORY,
639 ORG_CONTACT_ATTRIBUTE_CATEGORY,
640 ADDRESS_ATTRIBUTE_CATEGORY ,
641 PARTY_SITE_USE,
642 notes,
643 VEHICLE_RESPONSE_CODE      ,
644 SALES_AGENT_EMAIL_ADDRESS ,
645 ORIG_SYSTEM_REFERENCE,
646 
647 -- sranka 3/21/2003
648 -- made changes for supporting EMPLOYEE_OF" relationship
649  RELATIONSHIP_TYPE,
650  RELATIONSHIP_CODE,
651  org_email_address,
652 ORG_PH_COUNTRY_CODE,
653 ORG_PH_AREA_CODE,
654 ORG_PH_NUMBER,
655 ORG_PH_EXTENSION,
656 ORG_PHONE_TYPE,
657 PHONE_TYPE,
658 
659 
660 -- sranka Made the changes for COLT Enhancement 7/15/2003
661 ORG_COUNTRY,
662 ORG_ADDRESS1,
663 ORG_ADDRESS2,
664 ORG_ADDRESS3,
665 ORG_ADDRESS4,
666 ORG_CITY,
667 ORG_COUNTY,
668 ORG_STATE,
669 ORG_PROVINCE,
670 ORG_POSTAL_CODE,
671 ORG_ADDR_ATTRIBUTE_CATEGORY,
672 ORG_ADDR_ATTRIBUTE1,
673 ORG_ADDR_ATTRIBUTE2,
674 ORG_ADDR_ATTRIBUTE3,
675 ORG_ADDR_ATTRIBUTE4,
676 ORG_ADDR_ATTRIBUTE5,
677 ORG_ADDR_ATTRIBUTE6,
678 ORG_ADDR_ATTRIBUTE7,
679 ORG_ADDR_ATTRIBUTE8,
680 ORG_ADDR_ATTRIBUTE9,
681 ORG_ADDR_ATTRIBUTE10,
682 ORG_ADDR_ATTRIBUTE11,
683 ORG_ADDR_ATTRIBUTE12,
684 ORG_ADDR_ATTRIBUTE13,
685 ORG_ADDR_ATTRIBUTE14,
686 ORG_ADDR_ATTRIBUTE15,
687 ORG_ADDR_ATTRIBUTE16,
688 ORG_ADDR_ATTRIBUTE17,
689 ORG_ADDR_ATTRIBUTE18,
690 ORG_ADDR_ATTRIBUTE19,
691 ORG_ADDR_ATTRIBUTE20,
692 ORG_PS_ATTRIBUTE_CATEGORY,
693 ORG_PS_ATTRIBUTE1,
694 ORG_PS_ATTRIBUTE2,
695 ORG_PS_ATTRIBUTE3,
696 ORG_PS_ATTRIBUTE4,
697 ORG_PS_ATTRIBUTE5,
698 ORG_PS_ATTRIBUTE6,
699 ORG_PS_ATTRIBUTE7,
700 ORG_PS_ATTRIBUTE8,
701 ORG_PS_ATTRIBUTE9,
702 ORG_PS_ATTRIBUTE10,
703 ORG_PS_ATTRIBUTE11,
704 ORG_PS_ATTRIBUTE12,
705 ORG_PS_ATTRIBUTE13,
706 ORG_PS_ATTRIBUTE14,
707 ORG_PS_ATTRIBUTE15,
708 ORG_PS_ATTRIBUTE16,
709 ORG_PS_ATTRIBUTE17,
710 ORG_PS_ATTRIBUTE18,
711 ORG_PS_ATTRIBUTE19,
712 ORG_PS_ATTRIBUTE20,
713 ORG_CPS_ATTRIBUTE_CATEGORY,
714 ORG_CPS_ATTRIBUTE1,
715 ORG_CPS_ATTRIBUTE2,
716 ORG_CPS_ATTRIBUTE3,
717 ORG_CPS_ATTRIBUTE4,
718 ORG_CPS_ATTRIBUTE5,
719 ORG_CPS_ATTRIBUTE6,
720 ORG_CPS_ATTRIBUTE7,
721 ORG_CPS_ATTRIBUTE8,
722 ORG_CPS_ATTRIBUTE9,
723 ORG_CPS_ATTRIBUTE10,
724 ORG_CPS_ATTRIBUTE11,
725 ORG_CPS_ATTRIBUTE12,
726 ORG_CPS_ATTRIBUTE13,
727 ORG_CPS_ATTRIBUTE14,
728 ORG_CPS_ATTRIBUTE15,
729 ORG_CPS_ATTRIBUTE16,
730 ORG_CPS_ATTRIBUTE17,
731 ORG_CPS_ATTRIBUTE18,
732 ORG_CPS_ATTRIBUTE19,
733 ORG_CPS_ATTRIBUTE20,
734 NATIVE_LANGUAGE,
735 ORGANIZATION_ATTRIBUTE16,
736 ORGANIZATION_ATTRIBUTE17,
737 ORGANIZATION_ATTRIBUTE18,
738 ORGANIZATION_ATTRIBUTE19,
739 ORGANIZATION_ATTRIBUTE20,
740 ORGANIZATION_ATTRIBUTE21,
741 ORGANIZATION_ATTRIBUTE22,
742 ORGANIZATION_ATTRIBUTE23,
743 ORGANIZATION_ATTRIBUTE24,
744 PERSON_ATTRIBUTE16,
745 PERSON_ATTRIBUTE17,
746 PERSON_ATTRIBUTE18,
747 PERSON_ATTRIBUTE19,
748 PERSON_ATTRIBUTE20,
749 --PERSON_ATTRIBUTE21,
750 --PERSON_ATTRIBUTE22,
751 --PERSON_ATTRIBUTE23,
752 --PERSON_ATTRIBUTE24,
753 ORG_CONTACT_ATTRIBUTE16,
754 ORG_CONTACT_ATTRIBUTE17,
755 ORG_CONTACT_ATTRIBUTE18,
756 ORG_CONTACT_ATTRIBUTE19,
757 ORG_CONTACT_ATTRIBUTE20,
758 ORG_CONTACT_ATTRIBUTE21,
759 ORG_CONTACT_ATTRIBUTE22,
760 ORG_CONTACT_ATTRIBUTE23,
761 ORG_CONTACT_ATTRIBUTE24,
762 ADDRESS_ATTRIBUTE16,
763 ADDRESS_ATTRIBUTE17,
764 ADDRESS_ATTRIBUTE18,
765 ADDRESS_ATTRIBUTE19,
766 ADDRESS_ATTRIBUTE20
767  FROM AMS_HZ_B2B_MAPPING_V
768  WHERE IMPORT_LIST_HEADER_ID =  p_import_list_header_id
769    and request_id = l_request_id
770    AND load_status in ('ACTIVE','RELOAD');
771 
772 -- Cursor B2C Party Type
773 
774 CURSOR B2C IS
775  SELECT
776  IMPORT_SOURCE_LINE_ID,
777  PERSON_FIRST_NAME,
778  PERSON_MIDDLE_NAME,
779  PERSON_LAST_NAME,
780  PERSON_NAME_SUFFIX,
781  PERSON_name_prefix,
782  -- to_date(BEST_TIME_CONTACT_BEGIN,'MM/DD/YYYY'),
783  -- to_date(BEST_TIME_CONTACT_END,'MM/DD/YYYY'),
784  COUNTRY,
785  ADDRESS1,
786  ADDRESS2,
787  CITY,
788  COUNTY,
789  STATE,
790  PROVINCE,
791  POSTAL_CODE,
792  -- TIME_ZONE,
793  EMAIL_ADDRESS,
794  PHONE_COUNTRY_CODE,
795  PHONE_AREA_CODE,
796  PHONE_NUMBER,
797  PHONE_EXTENTION,
798 -- PERSON_PRE_NAME_ADJUNCT,
799  SALUTATION,
800  ADDRESS3                   ,
801  ADDRESS4                   ,
802  ADDRESS_LINES_PHONETIC     ,
803  -- APARTMENT_FLAG             ,
804  -- bug 4641591: columns obsolete
805  -- PO_BOX_NUMBER              ,
806  --  HOUSE_NUMBER               ,
807  --  STREET_SUFFIX              ,
808  -- SECONDARY_SUFFIX_ELEMENT   ,
809  --  STREET                     ,
810  -- RURAL_ROUTE_TYPE           ,
811  -- RURAL_ROUTE_NUMBER         ,
812  --  STREET_NUMBER              ,
813  --  FLOOR                      ,
814  --  SUITE                      ,
815  POSTAL_PLUS4_CODE          ,
816  -- OVERSEAS_ADDRESS_FLAG      ,
817  identifying_address_flag   ,
818  party_id ,
819  PERSON_LAST_NAME_PHONETIC,
820  PERSON_FIRST_NAME_PHONETIC ,
821 --PREFERRED_NAME,
822 URL,-- replace PREFERRED_NAME with URL
823 SECOND_TITLE,
824 -- DATE_OF_BIRTH,
825 -- to_date(DATE_OF_BIRTH,'MM/DD/YYYY'),
826 DATE_OF_BIRTH,
827 PERSON_ACADEMIC_TITLE,
828 PERSON_PREVIOUS_TITLE_NAME,
829 PERSON_KNOWN_AS,
830 PERSON_KNOWN_AS2,
831 PERSON_KNOWN_AS3,
832 PERSON_KNOWN_AS4,
833 PERSON_KNOWN_AS5,
834 PERSON_NAME_PHONETIC,
835 MIDDLE_NAME_PHONETIC,
836 FISCAL_CODE,
837 PLACE_OF_BIRTH,
838 DATE_OF_DEATH,
839 -- to_date(DATE_OF_DEATH,'MM/DD/YYYY'),
840 DECLARED_ETHNICITY,
841 MARITAL_STATUS, PERSONAL_INCOME,
842 -- to_date(MARITAL_STATUS_EFFECTIVE_DATE,'MM/DD/YYYY'),
843 MARITAL_STATUS_EFFECTIVE_DATE,
844 HEAD_OF_HOUSEHOLD_FLAG,
845 HOUSEHOLD_SIZE, LOCATION_DIRECTIONS,
846 ADDRESS_EFFECTIVE_DATE, ADDRESS_EXPIRATION_DATE,
847 PERSON_ATTRIBUTE1, PERSON_ATTRIBUTE2,
848 PERSON_ATTRIBUTE3, PERSON_ATTRIBUTE4,
849 PERSON_ATTRIBUTE5, PERSON_ATTRIBUTE6,
850 PERSON_ATTRIBUTE7, PERSON_ATTRIBUTE8,
851 PERSON_ATTRIBUTE9, PERSON_ATTRIBUTE10,
852 PERSON_ATTRIBUTE11, PERSON_ATTRIBUTE12,
853 PERSON_ATTRIBUTE13, PERSON_ATTRIBUTE14,
854 PERSON_ATTRIBUTE15, ADDRESS_ATTRIBUTE1,
855 ADDRESS_ATTRIBUTE2, ADDRESS_ATTRIBUTE3,
856 ADDRESS_ATTRIBUTE4, ADDRESS_ATTRIBUTE5,
857 ADDRESS_ATTRIBUTE6, ADDRESS_ATTRIBUTE7,
858 ADDRESS_ATTRIBUTE8, ADDRESS_ATTRIBUTE9,
859 ADDRESS_ATTRIBUTE10, ADDRESS_ATTRIBUTE11,
860 ADDRESS_ATTRIBUTE12, ADDRESS_ATTRIBUTE13,
861 ADDRESS_ATTRIBUTE14, ADDRESS_ATTRIBUTE15,
862 FAX_COUNTRY_CODE, FAX_AREA_CODE,
863 FAX_NUMBER,
864 PERSON_ATTRIBUTE_CATEGORY,
865 ADDRESS_ATTRIBUTE_CATEGORY ,
866 SHORT_DESCRIPTION,
867 DESCRIPTION,
868 PARTY_SITE_USE,
869 notes,
870 VEHICLE_RESPONSE_CODE      ,
871 SALES_AGENT_EMAIL_ADDRESS,
872 ORIG_SYSTEM_REFERENCE,
873 TAX_REFERENCE,
874 RENT_OWNED_INDICATOR,
875 gender,
876 HOUSEHOLD_INCOME,
877 phone_type,
878 -- sranka changes done for COLT Enhancements 7/15/2003
879 PS_ATTRIBUTE_CATEGORY,
880 PS_ATTRIBUTE1,
881 PS_ATTRIBUTE2,
882 PS_ATTRIBUTE3,
883 PS_ATTRIBUTE4,
884 PS_ATTRIBUTE5,
885 PS_ATTRIBUTE6,
886 PS_ATTRIBUTE7,
887 PS_ATTRIBUTE8,
888 PS_ATTRIBUTE9,
889 PS_ATTRIBUTE10,
890 PS_ATTRIBUTE11,
891 PS_ATTRIBUTE12,
892 PS_ATTRIBUTE13,
893 PS_ATTRIBUTE14,
894 PS_ATTRIBUTE15,
895 PS_ATTRIBUTE16,
896 PS_ATTRIBUTE17,
897 PS_ATTRIBUTE18,
898 PS_ATTRIBUTE19,
899 PS_ATTRIBUTE20,
900 NATIVE_LANGUAGE,
901 PERSON_ATTRIBUTE16,
902 PERSON_ATTRIBUTE17,
903 PERSON_ATTRIBUTE18,
904 PERSON_ATTRIBUTE19,
905 PERSON_ATTRIBUTE20,
906 PERSON_ATTRIBUTE21,
907 PERSON_ATTRIBUTE22,
908 PERSON_ATTRIBUTE23,
909 PERSON_ATTRIBUTE24,
910 ADDRESS_ATTRIBUTE16,
911 ADDRESS_ATTRIBUTE17,
912 ADDRESS_ATTRIBUTE18,
913 ADDRESS_ATTRIBUTE19,
914 ADDRESS_ATTRIBUTE20
915 FROM  AMS_HZ_B2C_MAPPING_V
916 WHERE IMPORT_LIST_HEADER_ID = P_IMPORT_LIST_HEADER_ID
917 and request_id = l_request_id
918 AND   load_status in ('ACTIVE','RELOAD');
919 
920 
921 CURSOR vehicle_code_exists (x_vehicle_code varchar) IS
922 select 'Y' from ams_lookups where lookup_type = 'AMS_VEHICLE_RESPONSE_CODE'
923 and lookup_code = x_vehicle_code  and enabled_flag = 'Y';
924 
925 
926 CURSOR resource_exists (x_sa_email_address varchar) IS
927 select ams.resource_id from ams_jtf_rs_emp_v ams , fnd_user fnd
928 where fnd.user_Name = upper(x_sa_email_address)
929   and fnd.user_id = ams.user_id;
930 
931 cursor c_hdr_status is
932 select status_code from ams_imp_list_headers_all
933 where import_list_header_id = p_import_list_header_id;
934 
935  party_rec       hz_party_v2pub.party_rec_type;
936  org_rec         hz_party_v2pub.organization_rec_type;
937  person_rec      hz_party_v2pub.person_rec_type;
938  location_rec    hz_location_v2pub.location_rec_type;
939  psite_rec       hz_party_site_v2pub.party_site_rec_type;
940  psiteuse_rec    hz_party_site_v2pub.party_site_use_rec_type;
941  cpoint_rec      hz_contact_point_v2pub.contact_point_rec_type;
942  email_rec       hz_contact_point_v2pub.email_rec_type;
943  phone_rec       hz_contact_point_v2pub.phone_rec_type;
944  fax_rec         hz_contact_point_v2pub.phone_rec_type;
945  ocon_rec        hz_party_contact_v2pub.org_contact_rec_type;
946  edi_rec         hz_contact_point_v2pub.edi_rec_type;
947  telex_rec       hz_contact_point_v2pub.telex_rec_type;
948  web_rec         hz_contact_point_v2pub.web_rec_type;
949 
950  org_email_rec       hz_contact_point_v2pub.email_rec_type;
951  org_phone_rec       hz_contact_point_v2pub.phone_rec_type;
952  org_location_rec    hz_location_v2pub.location_rec_type;
953  org_psite_rec       hz_party_site_v2pub.party_site_rec_type;
954  language_rec        HZ_PERSON_INFO_V2PUB.person_language_rec_type;
955 
956 
957 begin
958 
959 -- Checks if it's B2B or B2C party type.
960 	OPEN b2borb2c;
961 	FETCH b2borb2c into x_b2b;
962         CLOSE b2borb2c;
963  -- Checks if party_id is mapped
964         open party_mapped;
965         fetch party_mapped into G_PARTY_MAPPED;
966         close party_mapped;
967 
968  -- FND_PROFILE.Get('CONC_REQUEST_ID', l_request_id);
969 l_request_id := FND_GLOBAL.CONC_REQUEST_ID;
970              AMS_Utility_PVT.Create_Log (
971               x_return_status   => l_return_status,
972               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
973               p_log_used_by_id  => p_import_list_header_id,
974               p_msg_data        => 'IN import to HZ Request Id: '|| to_char(l_request_id),
975               p_msg_type        => 'DEBUG');
976 -- ******************************************************
977 IF p_number_of_processes > 0 then
978    if p_number_of_processes >= 10 then
979        l_numb_of_inst := 10;
980      else
981        l_numb_of_inst := p_number_of_processes;
982    end if;
983  open  c_total_recs;
984  fetch c_total_recs into  l_total_recs;
985  close c_total_recs;
986  open  c_hdr_status;
987  fetch c_hdr_status into l_header_status;
988  close c_hdr_status;
989  if l_header_status = 'ERROR' then
990 	l_total_recs := 0;
991 	i_batch_size := 0;
992  end if;
993  if l_total_recs = 0 then
994    open c_header_status;
995    fetch c_header_status into i_batch_size,l_parent_request_id;
996    close c_header_status;
997      AMS_Utility_PVT.Create_Log (
998          x_return_status   => l_return_status,
999          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1000          p_log_used_by_id  => p_import_list_header_id,
1001          p_msg_data        => 'l_parent_request_id = '|| to_char(l_parent_request_id),
1002          p_msg_type        => 'DEBUG'
1003        );
1004  if l_request_id = l_parent_request_id then
1005    AMS_Utility_PVT.Create_Log (
1006          x_return_status   => l_ret_status,
1007          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1008          p_log_used_by_id  => p_import_list_header_id,
1009          p_msg_data        => 'Stop processing size = '||to_char(i_batch_size),
1010          p_msg_type        => 'DEBUG'
1011          );
1012      if i_batch_size < 1 then
1013 
1014        --TCA mandate: bug 4587049
1015        --Enable/restore TCA events status
1016        --g_prof := fnd_profile.value('HZ_EXECUTE_API_CALLOUTS');
1017              AMS_Utility_PVT.Create_Log (
1018               x_return_status   => l_return_status,
1019               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1020               p_log_used_by_id  => p_import_list_header_id,
1021               p_msg_data        => 'Restoring g_prof HZ_EXECUTE_API_CALLOUTS: '|| g_prof,
1022               p_msg_type        => 'DEBUG');
1023 
1024        if g_prof <> 'N' then
1025          fnd_profile.put('HZ_EXECUTE_API_CALLOUTS',g_prof);
1026        end if;
1027 
1028        update_cust_import_status(p_import_list_header_id);
1029      end if;
1030      AMS_Utility_PVT.Create_Log (
1031          x_return_status   => l_return_status,
1032          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1033          p_log_used_by_id  => p_import_list_header_id,
1034          p_msg_data        => 'AMSILHZC ----- no records to process ZERO not submittng any child request.',
1035          p_msg_type        => 'DEBUG'
1036        );
1037       return;
1038  end if;
1039   ELSE
1040    l_req_data := fnd_conc_global.request_data;
1041 /*
1042              AMS_Utility_PVT.Create_Log (
1043               x_return_status   => l_return_status,
1044               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1045               p_log_used_by_id  => p_import_list_header_id,
1046               p_msg_data        => 'l_req_data : '|| l_req_data,
1047               p_msg_type        => 'DEBUG');
1048 */
1049    if (l_req_data is not null) then
1050         l_req_data_counter := to_number(l_req_data);
1051         l_req_data_counter := l_req_data_counter + 1;
1052    else
1053         l_req_data_counter := 1;
1054    end if;
1055 /*
1056              AMS_Utility_PVT.Create_Log (
1057               x_return_status   => l_return_status,
1058               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1059               p_log_used_by_id  => p_import_list_header_id,
1060               p_msg_data        => 'l_req_data_counter : '|| to_char(l_req_data_counter),
1061               p_msg_type        => 'DEBUG');
1062 */
1063  end if; -- if l_total_recs = 0 then
1064 
1065  if l_numb_of_inst = 1 then
1066           l_batch_size := l_total_recs;
1067    else
1068           l_batch_size := ROUND(l_total_recs / l_numb_of_inst) + 1;
1069  end if;
1070 
1071              AMS_Utility_PVT.Create_Log (
1072               x_return_status   => l_return_status,
1073               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1074               p_log_used_by_id  => p_import_list_header_id,
1075               p_msg_data        => 'l_batch_size : '|| to_char(l_batch_size),
1076               p_msg_type        => 'DEBUG');
1077 
1078  if l_numb_of_inst > l_total_recs then
1079     l_numb_of_inst := l_total_recs;
1080  end if;
1081  if l_numb_of_inst > 10 then
1082     l_numb_of_inst := 10;
1083  end if;
1084  update ams_imp_list_headers_all set BATCH_SIZE = l_numb_of_inst,
1085                                      parent_request_id = l_request_id
1086  where import_list_header_id = p_import_list_header_id;
1087  commit;
1088 
1089              AMS_Utility_PVT.Create_Log (
1090               x_return_status   => l_return_status,
1091               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1092               p_log_used_by_id  => p_import_list_header_id,
1093               p_msg_data        => 'l_numb_of_inst : '|| to_char(l_numb_of_inst),
1094               p_msg_type        => 'DEBUG');
1095 
1096        --TCA mandate: bug 4587049
1097        --Disable TCA events just before starting list import child to process TCA data
1098        --g_prof := fnd_profile.value('HZ_EXECUTE_API_CALLOUTS');
1099              AMS_Utility_PVT.Create_Log (
1100               x_return_status   => l_return_status,
1101               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1102               p_log_used_by_id  => p_import_list_header_id,
1103               p_msg_data        => 'Disabling g_prof HZ_EXECUTE_API_CALLOUTS: '|| g_prof,
1104               p_msg_type        => 'DEBUG');
1105 
1106        if g_prof <> 'N' then
1107          fnd_profile.put('HZ_EXECUTE_API_CALLOUTS','N');
1108        end if;
1109 
1110     FOR loop_counter IN 1..l_numb_of_inst LOOP
1111         new_request_id := FND_REQUEST.SUBMIT_REQUEST (
1112                       application       => 'AMS',
1113                       program           => 'AMSILHZC',
1114                       description       => 'List Import Child Req ' || to_char(loop_counter),
1115                       sub_request       => TRUE,
1116                       argument1         => p_import_list_header_id,
1117                       argument2         => 0);
1118 
1119               AMS_Utility_PVT.Create_Log (
1120               x_return_status   => l_return_status,
1121               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1122               p_log_used_by_id  => p_import_list_header_id,
1123               p_msg_data        => 'List Import Child Req : -- concurrent program_id is '||to_char(new_request_id),
1124               p_msg_type        => 'DEBUG'
1125               );
1126      IF new_request_id = 0 THEN
1127      --     RAISE FND_API.g_exc_unexpected_error;
1128               AMS_Utility_PVT.Create_Log (
1129               x_return_status   => l_return_status,
1130               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1131               p_log_used_by_id  => p_import_list_header_id,
1132               p_msg_data        => 'List Import Child Req : Error in submitting request',
1133               p_msg_type        => 'DEBUG'
1134               );
1135      end if;
1136 
1137         update ams_imp_source_lines
1138            set request_id = new_request_id
1139          where import_list_header_id = p_import_list_header_id
1140            and request_id is null
1141            and load_status in ('ACTIVE','RELOAD')
1142            and ROWNUM <= l_batch_size;
1143          commit;
1144 /*
1145      if x_b2b = 'Y' then
1146 	org_party_update(
1147    	p_import_list_header_id,
1148    	new_request_id,
1149    	l_batch_size,
1150    	x_return_status       ,
1151    	x_msg_count           ,
1152    	x_msg_data           );
1153       else
1154         update ams_imp_source_lines
1155            set request_id = new_request_id
1156          where import_list_header_id = p_import_list_header_id
1157            and request_id is null
1158            and ROWNUM <= l_batch_size;
1159      end if;
1160 */
1161     END LOOP;
1162 /*
1163              AMS_Utility_PVT.Create_Log (
1164               x_return_status   => l_return_status,
1165               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1166               p_log_used_by_id  => p_import_list_header_id,
1167               p_msg_data        => 'Start child prog pause --l_req_data_counter= '||to_char(l_req_data_counter),
1168               p_msg_type        => 'DEBUG');
1169 */
1170     fnd_conc_global.set_req_globals(conc_status  => 'PAUSED',
1171                                     request_data => to_char(l_req_data_counter));
1172 
1173 /*
1174              AMS_Utility_PVT.Create_Log (
1175               x_return_status   => l_return_status,
1176               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1177               p_log_used_by_id  => p_import_list_header_id,
1178               p_msg_data        => 'End AMSILHZC '||to_char(sysdate),
1179               p_msg_type        => 'DEBUG');
1180 */
1181 ELSIF p_number_of_processes = 0 THEN
1182 
1183  update ams_imp_list_headers_all set BATCH_SIZE = BATCH_SIZE - 1
1184  where import_list_header_id = p_import_list_header_id;
1185  commit;
1186 
1187 
1188 -- *****************************************************
1189 
1190 if x_b2b = 'B2B' then
1191     AMS_Utility_PVT.Create_Log (
1192          x_return_status   => l_ret_status,
1193          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1194          p_log_used_by_id  => p_import_list_header_id,
1195          p_msg_data        => 'TCA import -- Start b2b customer import',
1196          p_msg_type        => 'DEBUG'
1197          );
1198 
1199 	   OPEN b2b;
1200  LOOP
1201 	   FETCH b2b into
1202 -- sranka 1/14/2003
1203 -- added l_import_source_line_id to put the correct val of the import_source_line_id
1204        l_import_source_line_id,
1205 	   org_rec.organization_name,
1206 	   org_rec.fiscal_yearend_month,
1207 	   org_rec.duns_number_c,
1208 	   org_rec.employees_total,
1209 	   org_rec.line_of_business,
1210 	   org_rec.year_established,
1211 	   org_rec.tax_reference,
1212 	   org_rec.ceo_name,
1213 	   person_rec.person_first_name,
1214 	   person_rec.person_middle_name,
1215 	   person_rec.person_last_name,
1216 	   person_rec.person_name_suffix,
1217 	   person_rec.person_pre_name_adjunct,
1218 	   -- person_rec.best_time_contact_begin,
1219 	   -- person_rec.best_time_contact_end,
1220 	   location_rec.country,
1221 	   location_rec.address1,
1222 	   location_rec.address2,
1223 	   location_rec.city,
1224 	   location_rec.county,
1225 	   location_rec.state,
1226 	   location_rec.province,
1227 	   location_rec.postal_code,
1228 --	   location_rec.time_zone,
1229 	   email_rec.email_address,
1230 	   phone_rec.phone_country_code,
1231 	   phone_rec.phone_area_code,
1232            phone_rec.phone_number,
1233            phone_rec.phone_extension,
1234 	   ocon_rec.department,
1235 	   ocon_rec.job_title,
1236 	   ocon_rec.job_title_code, -- 5033551
1237 	   ocon_rec.decision_maker_flag,
1238            org_rec.sic_code,
1239            org_rec.sic_code_type,
1240  --          org_rec.party_rec.TOTAL_NUM_OF_ORDERS,
1241   --         org_rec.party_rec.TOTAL_ORDERED_AMOUNT,
1242    --        org_rec.party_rec.LAST_ORDERED_DATE,
1243            org_rec.analysis_fy,
1244            org_rec.CURR_FY_POTENTIAL_REVENUE,
1245            org_rec.NEXT_FY_POTENTIAL_REVENUE,
1246            org_rec.GSA_INDICATOR_FLAG,
1247            org_rec.MISSION_STATEMENT,
1248            org_rec.ORGANIZATION_NAME_PHONETIC,
1249            org_rec.party_rec.CATEGORY_CODE,
1250            org_rec.JGZZ_FISCAL_CODE,
1251     --       org_rec.TAX_NAME,
1252            location_rec.ADDRESS3,
1253            location_rec.ADDRESS4,
1254            location_rec.ADDRESS_LINES_PHONETIC,
1255            -- location_rec.APARTMENT_FLAG,
1256            -- bug 4641591: columns obsolete
1257            -- 	   location_rec.PO_BOX_NUMBER,
1258            --            location_rec.HOUSE_NUMBER,
1259            --            location_rec.STREET_SUFFIX,
1260            -- location_rec.SECONDARY_SUFFIX_ELEMENT,
1261            --            location_rec.STREET,
1262            -- location_rec.RURAL_ROUTE_TYPE,
1263            -- location_rec.RURAL_ROUTE_NUMBER,
1264            --            location_rec.STREET_NUMBER,
1265            --            location_rec.FLOOR,
1266            --            location_rec.SUITE,
1267            location_rec.POSTAL_PLUS4_CODE,
1268            -- location_rec.OVERSEAS_ADDRESS_FLAG,
1269            psite_rec.identifying_address_flag,
1270            l_b2b_party_id,
1271 	   location_rec.address_effective_date,
1272 	   location_rec.address_expiration_date,
1273            --ANNUAL_REVENUE,
1274 	   --ANNUAL_REVENUE_CURRENCY,
1275 	   org_rec.branch_flag,
1276 	   org_rec.line_of_business,
1277            org_rec.business_scope,
1278 	   org_rec.ceo_title,
1279            org_rec.cong_dist_code,
1280 	   org_rec.control_yr,
1281            org_rec.corporation_class,
1282 	   org_rec.credit_score,
1283            org_rec.credit_score_commentary,
1284 	   --CUSTOMER_CATEGORY,
1285            org_rec.db_rating,
1286            person_rec.date_of_birth,
1287            person_rec.date_of_death,
1288            org_rec.debarments_count,
1289            org_rec.debarments_date,
1290 	   person_rec.declared_ethnicity,
1291            org_rec.debarment_ind,
1292 	   location_rec.description,
1293            org_rec.disadv_8a_ind,
1294 	   org_rec.enquiry_duns,
1295            org_rec.export_ind,
1296 	   org_rec.failure_score,
1297            org_rec.failure_score_commentary,
1298 	   org_rec.failure_score_natnl_percentile,
1299            org_rec.failure_score_override_code,
1300 	   --FISCAL_CODE,
1301            org_rec.global_failure_score,
1302 	   org_rec.hq_branch_ind,
1303            person_rec.head_of_household_flag,
1304 	   person_rec.household_size,
1305            org_rec.import_ind,
1306            org_rec.known_as,
1307 	   org_rec.known_as2,
1308            org_rec.known_as3,
1309 	   org_rec.known_as4,
1310            org_rec.known_as5,
1311            person_rec.known_as,
1312            person_rec.known_as2,
1313            person_rec.known_as3,
1314            person_rec.known_as4,
1315            person_rec.known_as5,
1316            org_rec.labor_surplus_ind,
1317            org_rec.local_activity_code,
1318 	   org_rec.local_activity_code_type,
1319            location_rec.location_directions,
1320 	   --LOCATION_STATUS,
1321            person_rec.marital_status,
1322 	   person_rec.marital_status_effective_date,
1323            org_rec.minority_owned_ind,
1324 	   org_rec.minority_owned_type,
1325            --ORGANIZATION_ALIAS,
1326 	   org_rec.organization_type,
1327            web_rec.url,
1328 	   org_rec.oob_ind,
1329            person_rec.personal_income,
1330 	   person_rec.person_academic_title,
1331            person_rec.person_first_name_phonetic,
1332 	   person_rec.person_last_name_phonetic,
1333            person_rec.middle_name_phonetic,
1334 	   person_rec.person_name_phonetic,
1335            person_rec.person_previous_last_name, --modify ak
1336 	   person_rec.place_of_birth,
1337            --PREFERRED_NAME,
1338 	   org_rec.principal_name,
1339            org_rec.principal_title,
1340 	   org_rec.public_private_ownership_flag,
1341            org_rec.rent_own_ind,
1342 	   --RENT_OWNER_INDICATOR,
1343            person_rec.person_academic_title,
1344 	   location_rec.short_description,
1345            org_rec.small_bus_ind,
1346 	   -- person_rec.tax_reference,
1347            org_rec.woman_owned_ind,
1348            org_rec.party_rec.attribute1,
1349            org_rec.party_rec.attribute2,
1350            org_rec.party_rec.attribute3,
1351            org_rec.party_rec.attribute4,
1352            org_rec.party_rec.attribute5,
1353            org_rec.party_rec.attribute6,
1354            org_rec.party_rec.attribute7,
1355            org_rec.party_rec.attribute8,
1356            org_rec.party_rec.attribute9,
1357            org_rec.party_rec.attribute10,
1358            org_rec.party_rec.attribute11,
1359            org_rec.party_rec.attribute12,
1360            org_rec.party_rec.attribute13,
1361            org_rec.party_rec.attribute14,
1362            org_rec.party_rec.attribute15,
1363            person_rec.attribute1,
1364            person_rec.attribute2,
1365            person_rec.attribute3,
1366            person_rec.attribute4,
1367            person_rec.attribute5,
1368            person_rec.attribute6,
1369            person_rec.attribute7,
1370            person_rec.attribute8,
1371            person_rec.attribute9,
1372            person_rec.attribute10,
1373            person_rec.attribute11,
1374            person_rec.attribute12,
1375            person_rec.attribute13,
1376            person_rec.attribute14,
1377            person_rec.attribute15,
1378            ocon_rec.attribute1,
1379            ocon_rec.attribute2,
1380            ocon_rec.attribute3,
1381            ocon_rec.attribute4,
1382            ocon_rec.attribute5,
1383            ocon_rec.attribute6,
1384            ocon_rec.attribute7,
1385            ocon_rec.attribute8,
1386            ocon_rec.attribute9,
1387            ocon_rec.attribute10,
1388            ocon_rec.attribute11,
1389            ocon_rec.attribute12,
1390            ocon_rec.attribute13,
1391            ocon_rec.attribute14,
1392            ocon_rec.attribute15,
1393            location_rec.attribute1,
1394            location_rec.attribute2,
1395            location_rec.attribute3,
1396            location_rec.attribute4,
1397            location_rec.attribute5,
1398            location_rec.attribute6,
1399            location_rec.attribute7,
1400            location_rec.attribute8,
1401            location_rec.attribute9,
1402            location_rec.attribute10,
1403            location_rec.attribute11,
1404            location_rec.attribute12,
1405            location_rec.attribute13,
1406            location_rec.attribute14,
1407            location_rec.attribute15,
1408            fax_rec.phone_country_code,
1409 	   fax_rec.phone_area_code,
1410            fax_rec.phone_number,
1411            org_rec.party_rec.attribute_category,
1412            person_rec.attribute_category,
1413            ocon_rec.attribute_category,
1414            location_rec.attribute_category,
1415            psiteuse_rec.site_use_type,
1416            x_notes,
1417            l_vr_code,
1418            l_sa_email,
1419            org_rec.party_rec.orig_system_reference,
1420 -- sranka 3/4/2003
1421 -- made changes for supporting EMPLOYEE_OF" relationship
1422            ocon_rec.party_rel_rec.relationship_type,
1423            ocon_rec.party_rel_rec.relationship_code,
1424            org_email_rec.email_address,
1425            org_phone_rec.phone_country_code,
1426            org_phone_rec.phone_area_code,
1427            org_phone_rec.phone_number,
1428            org_phone_rec.phone_extension,
1429            org_phone_rec.phone_line_type,
1430            phone_rec.phone_line_type,
1431 
1432 org_location_rec.country,
1433 org_location_rec.address1,
1434 org_location_rec.address2,
1435 org_location_rec.address3,
1436 org_location_rec.address4,
1437 org_location_rec.city,
1438 org_location_rec.county,
1439 org_location_rec.state,
1440 org_location_rec.province,
1441 org_location_rec.postal_code,
1442 org_location_rec.attribute_category,
1443 org_location_rec.attribute1,
1444 org_location_rec.attribute2,
1445 org_location_rec.attribute3,
1446 org_location_rec.attribute4,
1447 org_location_rec.attribute5,
1448 org_location_rec.attribute6,
1449 org_location_rec.attribute7,
1450 org_location_rec.attribute8,
1451 org_location_rec.attribute9,
1452 org_location_rec.attribute10,
1453 org_location_rec.attribute11,
1454 org_location_rec.attribute12,
1455 org_location_rec.attribute13,
1456 org_location_rec.attribute14,
1457 org_location_rec.attribute15,
1458 org_location_rec.attribute16,
1459 org_location_rec.attribute17,
1460 org_location_rec.attribute18,
1461 org_location_rec.attribute19,
1462 org_location_rec.attribute20,
1463 org_psite_rec.attribute_category,
1464 org_psite_rec.attribute1,
1465 org_psite_rec.attribute2,
1466 org_psite_rec.attribute3,
1467 org_psite_rec.attribute4,
1468 org_psite_rec.attribute5,
1469 org_psite_rec.attribute6,
1470 org_psite_rec.attribute7,
1471 org_psite_rec.attribute8,
1472 org_psite_rec.attribute9,
1473 org_psite_rec.attribute10,
1474 org_psite_rec.attribute11,
1475 org_psite_rec.attribute12,
1476 org_psite_rec.attribute13,
1477 org_psite_rec.attribute14,
1478 org_psite_rec.attribute15,
1479 org_psite_rec.attribute16,
1480 org_psite_rec.attribute17,
1481 org_psite_rec.attribute18,
1482 org_psite_rec.attribute19,
1483 org_psite_rec.attribute20,
1484 psite_rec.attribute_category,
1485 psite_rec.attribute1,
1486 psite_rec.attribute2,
1487 psite_rec.attribute3,
1488 psite_rec.attribute4,
1489 psite_rec.attribute5,
1490 psite_rec.attribute6,
1491 psite_rec.attribute7,
1492 psite_rec.attribute8,
1493 psite_rec.attribute9,
1494 psite_rec.attribute10,
1495 psite_rec.attribute11,
1496 psite_rec.attribute12,
1497 psite_rec.attribute13,
1498 psite_rec.attribute14,
1499 psite_rec.attribute15,
1500 psite_rec.attribute16,
1501 psite_rec.attribute17,
1502 psite_rec.attribute18,
1503 psite_rec.attribute19,
1504 psite_rec.attribute20,
1505 language_rec.language_name,
1506 org_rec.party_rec.attribute16,
1507 org_rec.party_rec.attribute17,
1508 org_rec.party_rec.attribute18,
1509 org_rec.party_rec.attribute19,
1510 org_rec.party_rec.attribute20,
1511 org_rec.party_rec.attribute21,
1512 org_rec.party_rec.attribute22,
1513 org_rec.party_rec.attribute23,
1514 org_rec.party_rec.attribute24,
1515 person_rec.attribute16,
1516 person_rec.attribute17,
1517 person_rec.attribute18,
1518 person_rec.attribute19,
1519 person_rec.attribute20,
1520 --person_rec.attribute21,
1521 --person_rec.attribute22,
1522 --person_rec.attribute23,
1523 --person_rec.attribute24,
1524 ocon_rec.attribute16,
1525 ocon_rec.attribute17,
1526 ocon_rec.attribute18,
1527 ocon_rec.attribute19,
1528 ocon_rec.attribute20,
1529 ocon_rec.attribute21,
1530 ocon_rec.attribute22,
1531 ocon_rec.attribute23,
1532 ocon_rec.attribute24,
1533 location_rec.attribute16,
1534 location_rec.attribute17,
1535 location_rec.attribute18,
1536 location_rec.attribute19,
1537 location_rec.attribute20  ;
1538 
1539 
1540 
1541 
1542            person_rec.party_rec.attribute1 := ocon_rec.attribute1;
1543            person_rec.party_rec.attribute2 := ocon_rec.attribute2;
1544            person_rec.party_rec.attribute3 := ocon_rec.attribute3;
1545            person_rec.party_rec.attribute4 := ocon_rec.attribute4;
1546            person_rec.party_rec.attribute5 := ocon_rec.attribute5;
1547            person_rec.party_rec.attribute6 := ocon_rec.attribute6;
1548            person_rec.party_rec.attribute7 := ocon_rec.attribute7;
1549            person_rec.party_rec.attribute8 := ocon_rec.attribute8;
1550            person_rec.party_rec.attribute9 := ocon_rec.attribute9;
1551            person_rec.party_rec.attribute10 := ocon_rec.attribute10;
1552            person_rec.party_rec.attribute11 := ocon_rec.attribute11;
1553            person_rec.party_rec.attribute12 := ocon_rec.attribute12;
1554            person_rec.party_rec.attribute13 := ocon_rec.attribute13;
1555            person_rec.party_rec.attribute14 := ocon_rec.attribute14;
1556            person_rec.party_rec.attribute15 := ocon_rec.attribute15;
1557            person_rec.party_rec.attribute_category:= ocon_rec.attribute_category;
1558 
1559 	     -- hbandi code change for the Bug # 7498992
1560 	   person_rec.party_rec.attribute16 := ocon_rec.attribute16;
1561 	   person_rec.party_rec.attribute17 := ocon_rec.attribute17;
1562 	   person_rec.party_rec.attribute18 := ocon_rec.attribute18;
1563 	   person_rec.party_rec.attribute19 := ocon_rec.attribute19;
1564 	   person_rec.party_rec.attribute20 := ocon_rec.attribute20;
1565 	   person_rec.party_rec.attribute21 := ocon_rec.attribute21;
1566 	   person_rec.party_rec.attribute22 := ocon_rec.attribute22;
1567 	   person_rec.party_rec.attribute23 := ocon_rec.attribute23;
1568 	   person_rec.party_rec.attribute24 := ocon_rec.attribute24;
1569 	   --  End of Hbandi Code
1570 
1571 	   if b2b%notfound then
1572 		 exit;
1573         end if;
1574 
1575 -- sranka 1/14/2003
1576 -- made the changes to populate the correct import_source_line_id and support orig_system_reference
1577 
1578 --  i_import_source_line_id := org_rec.party_rec.orig_system_reference; // Original line
1579   i_import_source_line_id := l_import_source_line_id;
1580 
1581 -- TCA mandates changes: bug 4587049
1582 --  org_rec.party_rec.created_by_module := 'AMS_LIST_IMPORT';
1583   org_rec.created_by_module := 'AMS_LIST_IMPORT';
1584   person_rec.created_by_module := 'AMS_LIST_IMPORT';
1585   ocon_rec.created_by_module := 'AMS_LIST_IMPORT';
1586   language_rec.created_by_module := 'AMS_LIST_IMPORT';
1587   location_rec.created_by_module := 'AMS_LIST_IMPORT';
1588   psite_rec.created_by_module := 'AMS_LIST_IMPORT';
1589   psiteuse_rec.created_by_module := 'AMS_LIST_IMPORT';
1590   cpoint_rec.created_by_module := 'AMS_LIST_IMPORT';
1591 
1592   AMS_List_Import_PUB.Create_Customer (
1593   p_api_version              => 1,
1594   p_init_msg_list            => 'T',
1595   p_commit                   => 'F',
1596   x_return_status            => x_return_status,
1597   x_msg_count                => x_msg_count,
1598   x_msg_data                 => x_msg_data,
1599   p_party_id                 => l_b2b_party_id,
1600   p_b2b_flag                 => 'Y',
1601   p_import_list_header_id    => P_IMPORT_LIST_HEADER_ID,
1602   p_party_rec                => party_rec,
1603   p_org_rec                  => org_rec,
1604   p_person_rec               => person_rec,
1605   p_location_rec             => location_rec,
1606   p_psite_rec                => psite_rec,
1607   p_cpoint_rec               => cpoint_rec,
1608   p_email_rec                => email_rec,
1609   p_phone_rec                => phone_rec,
1610   p_fax_rec                  => fax_rec,
1611   p_ocon_rec                 => ocon_rec,
1612   p_siteuse_rec		     => psiteuse_rec,
1613   p_web_rec                  => web_rec,
1614   x_new_party                => x_new_party,
1615   p_component_name           => x_component_name,
1616   l_import_source_line_id    => l_import_source_line_id  ,
1617   p_org_email_rec            => org_email_rec,
1618   p_org_phone_rec            => org_phone_rec,
1619   p_org_location_rec         => org_location_rec,
1620   p_org_psite_rec            => org_psite_rec,
1621   p_language_rec          =>  language_rec
1622   );
1623 
1624     if x_return_status = 'S' and x_notes is not null and l_b2b_party_id is not null  then
1625       if x_notes is not null then
1626         create_list_note
1627         (  p_import_list_header_id,
1628            i_import_source_line_id,
1629            l_b2b_party_id,
1630            'PARTY'   ,
1631            x_notes,
1632            x_return_status,
1633            x_msg_count    ,
1634            x_msg_data );
1635           if x_return_status <> 'S' then
1636                 UPDATE ams_imp_source_lines
1637                 SET load_status = 'ERROR', ENABLED_FLAG = null
1638                 WHERE import_source_line_id = i_import_source_line_id;
1639                AMS_List_Import_PUB.error_capture (
1640                  1, 'T', 'F', null,
1641                 x_return_status,
1642                 x_msg_count,
1643                 x_msg_data,
1644                 p_import_list_header_id,
1645                 i_import_source_line_id,
1646                 null, null, null,null,
1647                 'Error in note creation' );
1648 
1649           end if;
1650       end if;
1651     end if;
1652     if l_vr_code is not null then
1653          open vehicle_code_exists(l_vr_code);
1654          fetch vehicle_code_exists into l_vr_code_exists;
1655          close vehicle_code_exists;
1656          if l_vr_code_exists is null then
1657                 UPDATE ams_imp_source_lines
1658                 SET load_status = 'ERROR',ENABLED_FLAG = null
1659                 WHERE import_source_line_id = i_import_source_line_id;
1660                AMS_List_Import_PUB.error_capture (
1661                  1,
1662                 'T',
1663                 'F',
1664                 null,
1665                 x_return_status,
1666                 x_msg_count,
1667                 x_msg_data,
1668                 p_import_list_header_id,
1669                 i_import_source_line_id,
1670                 null, null, null,null,
1671                 'VEHICLE_RESPONSE_CODE : Invalid value for column VEHICLE_RESPONSE_CODE');
1672         end if;
1673     end if;
1674     if l_sa_email is not null then
1675         open resource_exists (l_sa_email);
1676         fetch resource_exists into l_resource_id;
1677         close resource_exists;
1678         if l_resource_id is null then
1679                 UPDATE ams_imp_source_lines
1680                 SET load_status = 'ERROR',ENABLED_FLAG = null
1681                 WHERE import_source_line_id = i_import_source_line_id;
1682                AMS_List_Import_PUB.error_capture (
1683                  1,
1684                 'T',
1685                 'F',
1686                 null,
1687                 x_return_status,
1688                 x_msg_count,
1689                 x_msg_data,
1690                 p_import_list_header_id,
1691                 i_import_source_line_id,
1692                 null, null, null,null,
1693                 'SALES_AGENT_EMAIL_ADDRESS : Resource ID does not exist for this sales agent.');
1694         end if;
1695         UPDATE ams_imp_source_lines
1696           SET resource_id     = l_resource_id
1697         WHERE import_source_line_id = i_import_source_line_id;
1698     end if;
1699 
1700    if x_msg_count > 1 then
1701     FOR i IN 1..x_msg_count  LOOP
1702 	 x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
1703 	 x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
1704     END LOOP;
1705     x_msg_data := x_tmp_var1;
1706    END IF;
1707     errbuf := 'ERROR -'||substr(x_msg_data,1,180);
1708    if x_return_status <> 'S' then
1709       UPDATE ams_imp_source_lines
1710          SET load_status = 'ERROR',ENABLED_FLAG = null
1711        WHERE import_source_line_id = i_import_source_line_id;
1712        AMS_List_Import_PUB.error_capture (
1713         1,
1714         'T',
1715         'F',
1716         null,
1717         x_return_status,
1718         x_msg_count,
1719         x_msg_data,
1720         p_import_list_header_id,
1721         i_import_source_line_id,
1722         null,
1723         null,
1724         x_component_name,
1725         null,
1726         errbuf);
1727         if (x_return_status = 'E' and x_msg_data = 'Threshold')
1728           then
1729           exit;
1730         end if;
1731    end if;
1732    i_number_of_rows_processed := i_number_of_rows_processed + 1;
1733    i_import_source_line_id := null;
1734    x_return_status      := null;
1735    x_msg_count	        := null;
1736    x_msg_data           := null;
1737    x_new_party          := null;
1738    errbuf		:= null;
1739    x_tmp_var            := null;
1740    x_tmp_var1           := null;
1741    l_resource_id        := null;
1742    l_vr_code_exists     := null;
1743 END LOOP;
1744 CLOSE b2b;
1745 
1746 UPDATE ams_imp_list_headers_all
1747    -- SET processed_rows = i_number_of_rows_processed
1748    SET processed_rows = nvl(processed_rows,0) + i_number_of_rows_processed
1749  WHERE import_list_header_id = p_import_list_header_id;
1750 
1751 end if;
1752 
1753 -- >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<
1754 if x_b2b = 'B2C' then
1755     i_number_of_rows_processed := 0;
1756     AMS_Utility_PVT.Create_Log (
1757          x_return_status   => l_ret_status,
1758          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1759          p_log_used_by_id  => p_import_list_header_id,
1760          p_msg_data        => 'TCA import -- Start b2c customer import',
1761          p_msg_type        => 'DEBUG'
1762          );
1763 
1764           OPEN b2c;
1765  LOOP
1766   AMS_Utility_PVT.Create_Log (
1767          x_return_status   => l_ret_status,
1768          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1769          p_log_used_by_id  => p_import_list_header_id,
1770          p_msg_data        => 'before FETCH  ..................  ',
1771          p_msg_type        => 'DEBUG'
1772          );
1773            FETCH b2c into
1774            l_import_source_line_id,
1775            person_rec.person_first_name,
1776            person_rec.person_middle_name,
1777            person_rec.person_last_name,
1778            person_rec.person_name_suffix,
1779            person_rec.person_pre_name_adjunct,
1780            -- person_rec.best_time_contact_begin,
1781            -- person_rec.best_time_contact_end,
1782            location_rec.country,
1783            location_rec.address1,
1784            location_rec.address2,
1785            location_rec.city,
1786            location_rec.county,
1787            location_rec.state,
1788            location_rec.province,
1789            location_rec.postal_code,
1790  --          location_rec.time_zone,
1791 	   email_rec.email_address,
1792 	   phone_rec.phone_country_code,
1793 	   phone_rec.phone_area_code,
1794            phone_rec.phone_number,
1795            phone_rec.phone_extension,
1796           --  person_rec.person_pre_name_adjunct,
1797            person_rec.party_rec.SALUTATION,
1798            location_rec.ADDRESS3,
1799            location_rec.ADDRESS4,
1800            location_rec.ADDRESS_LINES_PHONETIC,
1801            -- location_rec.APARTMENT_FLAG,
1802            -- bug 4641591: columns obsolete
1803            -- 	   location_rec.PO_BOX_NUMBER,
1804            --            location_rec.HOUSE_NUMBER,
1805            --            location_rec.STREET_SUFFIX,
1806            -- location_rec.SECONDARY_SUFFIX_ELEMENT,
1807            --            location_rec.STREET,
1808            -- location_rec.RURAL_ROUTE_TYPE,
1809            -- location_rec.RURAL_ROUTE_NUMBER,
1810            --            location_rec.STREET_NUMBER,
1811            --            location_rec.FLOOR,
1812            --            location_rec.SUITE,
1813            location_rec.POSTAL_PLUS4_CODE,
1814            -- location_rec.OVERSEAS_ADDRESS_FLAG,
1815            psite_rec.identifying_address_flag,
1816            l_b2c_party_id,
1817 	   person_rec.person_last_name_phonetic,
1818 	   person_rec.person_first_name_phonetic,
1819            --PREFERRED_NAME,
1820 	   web_rec.url, -- replace PREFERRED_NAME with URL
1821 	   person_rec.person_academic_title,
1822            person_rec.date_of_birth,
1823 	   person_rec.person_academic_title,
1824            person_rec.person_previous_last_name,
1825 	   person_rec.known_as,
1826            person_rec.known_as2,
1827 	   person_rec.known_as3,
1828            person_rec.known_as4,
1829 	   person_rec.known_as5,
1830            person_rec.person_name_phonetic,
1831 	   person_rec.middle_name_phonetic,
1832            person_rec.jgzz_fiscal_code,
1833 	   person_rec.place_of_birth,
1834            person_rec.date_of_death,
1835 	   person_rec.declared_ethnicity,
1836            person_rec.marital_status,
1837 	   person_rec.personal_income,
1838            person_rec.marital_status_effective_date,
1839 	   person_rec.head_of_household_flag,
1840            person_rec.household_size,
1841 	   location_rec.location_directions,
1842            location_rec.address_effective_date,
1843 	   location_rec.address_expiration_date,
1844            person_rec.party_rec.attribute1,
1845            person_rec.party_rec.attribute2,
1846            person_rec.party_rec.attribute3,
1847            person_rec.party_rec.attribute4,
1848            person_rec.party_rec.attribute5,
1849            person_rec.party_rec.attribute6,
1850            person_rec.party_rec.attribute7,
1851            person_rec.party_rec.attribute8,
1852            person_rec.party_rec.attribute9,
1853            person_rec.party_rec.attribute10,
1854            person_rec.party_rec.attribute11,
1855            person_rec.party_rec.attribute12,
1856            person_rec.party_rec.attribute13,
1857            person_rec.party_rec.attribute14,
1858            person_rec.party_rec.attribute15,
1859            location_rec.attribute1,
1860            location_rec.attribute2,
1861            location_rec.attribute3,
1862            location_rec.attribute4,
1863            location_rec.attribute5,
1864            location_rec.attribute6,
1865            location_rec.attribute7,
1866            location_rec.attribute8,
1867            location_rec.attribute9,
1868            location_rec.attribute10,
1869            location_rec.attribute11,
1870            location_rec.attribute12,
1871            location_rec.attribute13,
1872            location_rec.attribute14,
1873            location_rec.attribute15,
1874            fax_rec.phone_country_code,
1875 	   fax_rec.phone_area_code,
1876            fax_rec.phone_number,
1877            person_rec.party_rec.attribute_category,
1878            location_rec.attribute_category ,
1879 	   location_rec.short_description,
1880 	   location_rec.description,
1881            psiteuse_rec.site_use_type,
1882            x_notes,
1883            l_vr_code,
1884            l_sa_email,
1885            person_rec.party_rec.orig_system_reference,
1886            person_rec.tax_reference,
1887            person_rec.rent_own_ind,
1888            person_rec.gender,
1889            person_rec.HOUSEHOLD_INCOME,
1890 	   phone_rec.phone_line_type,
1891 -- sranka changed for COLT Enhancement 7/15/2003
1892         psite_rec.attribute_category,
1893         psite_rec.attribute1,
1894         psite_rec.attribute2,
1895         psite_rec.attribute3,
1896         psite_rec.attribute4,
1897         psite_rec.attribute5,
1898         psite_rec.attribute6,
1899         psite_rec.attribute7,
1900         psite_rec.attribute8,
1901         psite_rec.attribute9,
1902         psite_rec.attribute10,
1903         psite_rec.attribute11,
1904         psite_rec.attribute12,
1905         psite_rec.attribute13,
1906         psite_rec.attribute14,
1907         psite_rec.attribute15,
1908         psite_rec.attribute16,
1909         psite_rec.attribute17,
1910         psite_rec.attribute18,
1911         psite_rec.attribute19,
1912         psite_rec.attribute20,
1913  language_rec.language_name,
1914            person_rec.party_rec.attribute16,
1915            person_rec.party_rec.attribute17,
1916            person_rec.party_rec.attribute18,
1917            person_rec.party_rec.attribute19,
1918            person_rec.party_rec.attribute20,
1919            person_rec.party_rec.attribute21,
1920            person_rec.party_rec.attribute22,
1921            person_rec.party_rec.attribute23,
1922            person_rec.party_rec.attribute24,
1923            location_rec.attribute16,
1924            location_rec.attribute17,
1925            location_rec.attribute18,
1926            location_rec.attribute19,
1927            location_rec.attribute20 ;
1928 
1929            if b2c%notfound then
1930                  exit;
1931            end if;
1932   AMS_Utility_PVT.Create_Log (
1933          x_return_status   => l_ret_status,
1934          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1935          p_log_used_by_id  => p_import_list_header_id,
1936          p_msg_data        => 'After  FETCH  ..................  ',
1937          p_msg_type        => 'DEBUG'
1938          );
1939 -- sranka 1/17/2003
1940 --  i_import_source_line_id := person_rec.party_rec.orig_system_reference; //original
1941   i_import_source_line_id := l_import_source_line_id;
1942 
1943   AMS_Utility_PVT.Create_Log (
1944          x_return_status   => l_ret_status,
1945          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1946          p_log_used_by_id  => p_import_list_header_id,
1947          p_msg_data        => 'before Create_Customer  ',
1948          p_msg_type        => 'DEBUG'
1949          );
1950 
1951   -- TCA mandates changes: bug 4587049
1952 --  org_rec.party_rec.created_by_module := 'AMS_LIST_IMPORT';
1953   org_rec.created_by_module := 'AMS_LIST_IMPORT';
1954   person_rec.created_by_module := 'AMS_LIST_IMPORT';
1955   ocon_rec.created_by_module := 'AMS_LIST_IMPORT';
1956   --language_rec.created_by_module := 'AMS_LIST_IMPORT';
1957   location_rec.created_by_module := 'AMS_LIST_IMPORT';
1958   psite_rec.created_by_module := 'AMS_LIST_IMPORT';
1959   psiteuse_rec.created_by_module := 'AMS_LIST_IMPORT';
1960   cpoint_rec.created_by_module := 'AMS_LIST_IMPORT';
1961 
1962   AMS_List_Import_PUB.Create_Customer (
1963   p_api_version              => 1,
1964   p_init_msg_list            => 'T',
1965   p_commit                   => 'F',
1966   x_return_status            => x_return_status,
1967   x_msg_count                => x_msg_count,
1968   x_msg_data                 => x_msg_data,
1969   p_party_id                 => l_b2c_party_id,
1970   p_b2b_flag                 => 'N',
1971   p_import_list_header_id    => P_IMPORT_LIST_HEADER_ID,
1972   p_party_rec                => party_rec,
1973   p_org_rec                  => org_rec,
1974   p_person_rec               => person_rec,
1975   p_location_rec             => location_rec,
1976   p_psite_rec                => psite_rec,
1977   p_cpoint_rec               => cpoint_rec,
1978   p_email_rec                => email_rec,
1979   p_phone_rec                => phone_rec,
1980   p_fax_rec                  => fax_rec,
1981   p_ocon_rec                 => ocon_rec,
1982   p_siteuse_rec		     => psiteuse_rec,
1983   p_web_rec                  => web_rec,
1984   x_new_party                => x_new_party,
1985   p_component_name           => x_component_name,
1986   l_import_source_line_id    => l_import_source_line_id
1987   );
1988 
1989    AMS_Utility_PVT.Create_Log (
1990          x_return_status   => l_ret_status,
1991          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
1992          p_log_used_by_id  => p_import_list_header_id,
1993          p_msg_data        => 'after Create_Customer  ' ,
1994          p_msg_type        => 'DEBUG'
1995          );
1996 
1997    AMS_Utility_PVT.Create_Log (
1998          x_return_status   => l_ret_status,
1999          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2000          p_log_used_by_id  => p_import_list_header_id,
2001          p_msg_data        => 'after Create_Customer x_return_status  = '||x_return_status,
2002          p_msg_type        => 'DEBUG'
2003          );
2004 
2005   AMS_Utility_PVT.Create_Log (
2006          x_return_status   => l_ret_status,
2007          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2008          p_log_used_by_id  => p_import_list_header_id,
2009          p_msg_data        => 'after Create_Customer x_msg_count = '||to_char(x_msg_count),
2010          p_msg_type        => 'DEBUG'
2011          );
2012 
2013   AMS_Utility_PVT.Create_Log (
2014          x_return_status   => l_ret_status,
2015          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2016          p_log_used_by_id  => p_import_list_header_id,
2017          p_msg_data        => 'after Create_Customer x_msg_data = '||x_msg_data,
2018          p_msg_type        => 'DEBUG'
2019          );
2020 
2021     if x_return_status = 'S' and x_notes is not null and l_b2c_party_id is not null then
2022       if x_notes is not null then
2023         create_list_note
2024         (  p_import_list_header_id,
2025            i_import_source_line_id,
2026            l_b2c_party_id,
2027            'PARTY'   ,
2028            x_notes,
2029            x_return_status,
2030            x_msg_count    ,
2031            x_msg_data );
2032           if x_return_status <> 'S' then
2033                 UPDATE ams_imp_source_lines
2034                 SET load_status = 'ERROR',ENABLED_FLAG = null
2035                 WHERE import_source_line_id = i_import_source_line_id;
2036                AMS_List_Import_PUB.error_capture (
2037                  1, 'T', 'F', null,
2038                 x_return_status,
2039                 x_msg_count,
2040                 x_msg_data,
2041                 p_import_list_header_id,
2042                 i_import_source_line_id,
2043                 null, null, null,null,
2044                 'Error in note creation' );
2045 
2046           end if;
2047       end if;
2048     end if;
2049     if l_vr_code is not null then
2050          open vehicle_code_exists(l_vr_code);
2051          fetch vehicle_code_exists into l_vr_code_exists;
2052          close vehicle_code_exists;
2053          if l_vr_code_exists is null then
2054                 UPDATE ams_imp_source_lines
2055                 SET load_status = 'ERROR',ENABLED_FLAG = null
2056                 WHERE import_source_line_id = i_import_source_line_id;
2057                AMS_List_Import_PUB.error_capture (
2058                  1,
2059                 'T',
2060                 'F',
2061                 null,
2062                 x_return_status,
2063                 x_msg_count,
2064                 x_msg_data,
2065                 p_import_list_header_id,
2066                 i_import_source_line_id,
2067                 null, null, null,null,
2068                 'VEHICLE_RESPONSE_CODE : Invalid value for column VEHICLE_RESPONSE_CODE');
2069         end if;
2070     end if;
2071     if l_sa_email is not null then
2072         open resource_exists (l_sa_email);
2073         fetch resource_exists into l_resource_id;
2074         close resource_exists;
2075         if l_resource_id is null then
2076                 UPDATE ams_imp_source_lines
2077                 SET load_status = 'ERROR',ENABLED_FLAG = null
2078                 WHERE import_source_line_id = i_import_source_line_id;
2079                AMS_List_Import_PUB.error_capture (
2080                  1,
2081                 'T',
2082                 'F',
2083                 null,
2084                 x_return_status,
2085                 x_msg_count,
2086                 x_msg_data,
2087                 p_import_list_header_id,
2088                 i_import_source_line_id,
2089                 null, null, null,null,
2090                 'SALES_AGENT_EMAIL_ADDRESS : Resource ID does not exist for this sales agent.');
2091         end if;
2092         UPDATE ams_imp_source_lines
2093           SET resource_id     = l_resource_id
2094         WHERE import_source_line_id = i_import_source_line_id
2095           AND import_list_header_id = p_import_list_header_id;
2096      end if;
2097 
2098    if x_msg_count > 1 then
2099     FOR i IN 1..x_msg_count  LOOP
2100          x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
2101          x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
2102     END LOOP;
2103     x_msg_data := x_tmp_var1;
2104   END IF;
2105     errbuf := 'ERROR -'||substr(x_msg_data,1,180);
2106     if x_return_status <> 'S' then
2107       UPDATE ams_imp_source_lines
2108          SET load_status = 'ERROR',ENABLED_FLAG = null
2109        WHERE import_source_line_id = i_import_source_line_id;
2110       AMS_List_Import_PUB.error_capture (
2111         1,
2112         'T',
2113         'F',
2114         null,
2115         x_return_status,
2116         x_msg_count,
2117         x_msg_data,
2118         p_import_list_header_id,
2119         i_import_source_line_id,
2120         null,
2121         null,
2122         x_component_name,
2123         null,
2124         substrb(errbuf,1,2000));
2125         if (x_return_status = 'E' and x_msg_data = 'Threshold')
2126           then
2127           exit;
2128         end if;
2129     end if;
2130     i_number_of_rows_processed := i_number_of_rows_processed + 1;
2131     i_import_source_line_id := null;
2132     x_return_status      := null;
2133     x_msg_count          := null;
2134     x_msg_data           := null;
2135     x_new_party	     	 := null;
2136     errbuf		:= null;
2137    x_tmp_var            := null;
2138    x_tmp_var1           := null;
2139    l_resource_id        := null;
2140    l_vr_code_exists     := null;
2141 
2142 END LOOP;
2143 CLOSE b2c;
2144 
2145 UPDATE ams_imp_list_headers_all
2146    -- SET processed_rows = i_number_of_rows_processed
2147    SET processed_rows  = nvl(processed_rows,0) + i_number_of_rows_processed
2148  WHERE import_list_header_id = p_import_list_header_id;
2149 
2150 end if; --  b2c
2151 END IF;  -- IF p_number_of_processes > 0 then
2152 /*
2153 open c_header_status;
2154 fetch c_header_status into i_batch_size,l_parent_request_id;
2155 close c_header_status;
2156    AMS_Utility_PVT.Create_Log (
2157          x_return_status   => l_ret_status,
2158          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2159          p_log_used_by_id  => p_import_list_header_id,
2160          p_msg_data        => 'Stop processing size = '||to_char(i_batch_size),
2161          p_msg_type        => 'DEBUG'
2162          );
2163 if i_batch_size < 1 then
2164    update_cust_import_status(p_import_list_header_id);
2165 end if;
2166 */
2167       errbuf:= 'TCA import  Program(-)';
2168       retcode:=0;
2169    AMS_Utility_PVT.Create_Log (
2170          x_return_status   => l_ret_status,
2171          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2172          p_log_used_by_id  => p_import_list_header_id,
2173          p_msg_data        => 'TCA import  Program(-)',
2174          p_msg_type        => 'DEBUG'
2175          );
2176 
2177 EXCEPTION
2178  WHEN OTHERS THEN
2179    errbuf:= substr(SQLERRM,1,254);
2180    retcode:= 2;
2181                 UPDATE ams_imp_source_lines
2182                 SET load_status = 'ERROR'
2183                 WHERE import_source_line_id = i_import_source_line_id;
2184                AMS_List_Import_PUB.error_capture (
2185                  1,
2186                 'T',
2187                 'F',
2188                 null,
2189                 x_return_status,
2190                 x_msg_count,
2191                 x_msg_data,
2192                 p_import_list_header_id,
2193                 nvl(i_import_source_line_id,0),
2194                 null, null, null,null,
2195                 'Error in TCA load program ' || SQLERRM||' '||SQLCODE);
2196        l_lookup_code := 'ERROR';
2197                 l_user_status_id := null;
2198                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2199                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2200                 system_status_code = 'ERROR' and default_flag = 'Y';
2201 
2202                 UPDATE ams_imp_list_headers_all
2203                 set status_code       =  l_lookup_code,
2204                 user_status_id    =  l_user_status_id,
2205                 status_date       =  sysdate
2206                 where import_list_header_id = p_import_list_header_id;
2207                  commit;
2208     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
2209     FND_MESSAGE.Set_Token('ROW','Error in TCA load program ' || SQLERRM||' '||SQLCODE);
2210     AMS_Utility_PVT.Create_Log (
2211       x_return_status   => l_return_status,
2212       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2213       p_log_used_by_id  => p_import_list_header_id,
2214       p_msg_data        => FND_MESSAGE.get,
2215       p_msg_type        => 'DEBUG'
2216    );
2217 end list_import_to_hz;
2218 
2219 -- --------------------------------------------------------
2220 -- This program invokes sql*loader from concurrent program
2221 -- to populate the data from the data file to the OMO application.
2222 --
2223 
2224 PROCEDURE load_to_ams(
2225                     Errbuf                     OUT NOCOPY   VARCHAR2,
2226                     Retcode                    OUT NOCOPY   VARCHAR2,
2227                     p_import_list_header_id    IN    NUMBER,     -- To be used as part of executable name.
2228                     p_control_file             IN    VARCHAR2,   -- Name of file to be used by the SQL*Loader process.
2229                     p_staged_only              IN    VARCHAR2 , -- Used for staged table import.
2230                     p_owner_user_id            IN    NUMBER,     -- Used for list generation (resource_id),
2231                     p_generate_list            IN    VARCHAR2 ,
2232                     p_list_name                IN    VARCHAR2    --  For list generation name.
2233                      ) IS
2234 
2235    L_SQL_LOADER      		CONSTANT VARCHAR2(30) := 'SQL*Loader';
2236    l_short_name      		 	 VARCHAR2(30);
2237    l_request_id      			 NUMBER;
2238    l_return_status   			 VARCHAR2(1);
2239    l_start_time      			 DATE;
2240    l_import_list_header_name 		 VARCHAR2(120);
2241    l_msg_count 			         NUMBER;
2242    l_msg_data        		         VARCHAR2(2000);
2243    l_msg_buf            		 VARCHAR2(4000);
2244    l_phase              		 VARCHAR2(30);
2245    l_status             		 VARCHAR2(30);
2246    l_dev_phase          		 VARCHAR2(30);
2247    l_dev_status         		 VARCHAR2(30);
2248    l_message            		 VARCHAR2(240);
2249    l_wait_status        		 BOOLEAN;
2250    l_loaded_rows        		 NUMBER;
2251    l_post_request_id    		 NUMBER;
2252    l_server_flag   			 VARCHAR2(1);
2253    l_dedupe_flag   			 VARCHAR2(1);
2254    l_status_code   			 VARCHAR2(30);
2255    l_st_code     			 VARCHAR2(30);
2256    l_lookup_code     			 VARCHAR2(30);
2257    i_msg_count 			         NUMBER;
2258    i_return_status   			 VARCHAR2(1);
2259    i_msg_data        		         VARCHAR2(2000);
2260    i_msg_buf            		 VARCHAR2(4000);
2261    l_list_header_id                      NUMBER;
2262    l_duplicate_records                   NUMBER;
2263    l_user_status_id                      NUMBER;
2264    l_imp_type     			 VARCHAR2(30);
2265    l_finish_status                       VARCHAR2(30);
2266    l_execute_mode                        VARCHAR2(1);
2267    l_batch_id                            NUMBER;
2268    l_rec_in_stag_tab                     VARCHAR2(1);
2269    l_load_rows			 	 NUMBER;
2270  l_total_records             NUMBER;
2271    l_mesg_text                 VARCHAR2(2000);
2272    x_import_list_header_id number;
2273    X_RETURN_STATUS      VARCHAR2(1);
2274    x_msg_count          NUMBER;
2275    x_msg_data           VARCHAR2(2000);
2276    x_hz_dup_check  VARCHAR2(60);
2277    l_b2b_flag                            VARCHAR2(1);
2278    l_osr_mapped			VARCHAR2(1);
2279 
2280   CURSOR c_loaded_rows IS
2281       SELECT COUNT(*)
2282       FROM   ams_imp_source_lines
2283       WHERE  import_list_header_id = p_import_list_header_id;
2284 
2285    cursor c_header_name is
2286           select name, server_flag, status_code, import_type, execute_mode from ams_imp_list_headers_all
2287           where import_list_header_id = p_import_list_header_id;
2288 
2289    cursor c_status is
2290           select status_code, nvl(dedupe_flag,'N') from ams_imp_list_headers_all
2291           where import_list_header_id = p_import_list_header_id;
2292 
2293    cursor c_dup_recs is
2294           select count(*) from ams_imp_source_lines
2295           where import_list_header_id = p_import_list_header_id
2296             and duplicate_flag = 'Y';
2297 
2298    cursor c_loaded_rows_for_lead IS
2299           SELECT COUNT(*) FROM ams_imp_source_lines
2300           WHERE import_list_header_id = p_import_list_header_id;
2301 
2302   cursor c_rec_in_stag_tab is
2303   select 'Y' from ams_imp_source_lines
2304   where import_list_header_id = p_import_list_header_id
2305     and load_status in ('ACTIVE','RELOAD')
2306     and rownum < 2;
2307 
2308  cursor c_total_records is
2309    select count(*) from ams_imp_source_lines
2310    where import_list_header_id = p_import_list_header_id
2311      and load_status in ('ACTIVE','RELOAD');
2312 
2313 -- For Mapped osr
2314 cursor osr_mapped is
2315 SELECT 'Y'  FROM ams_list_src_fields sf,
2316 ams_imp_list_headers_all hd
2317 WHERE sf.field_column_name = 'ORIG_SYSTEM_REFERENCE'
2318   AND sf.enabled_flag = 'Y'
2319   AND sf.list_source_type_id = hd.list_source_type_id
2320   and hd.import_type in ('B2B','B2C')
2321   AND hd.import_list_header_id = p_import_list_header_id;
2322 BEGIN
2323 
2324 --
2325 -- For SQL*Loader programs, the executable file name is equivalent to the
2326 -- control file.  The field "Executable" on the screen is the same as "program"
2327 -- in the API.  We will use the short name for both program and program short name.
2328 --
2329    l_short_name := 'AMS' || FND_GLOBAL.LOGIN_ID || 'IMP' || p_import_list_header_id;
2330  x_import_list_header_id := p_import_list_header_id;
2331     x_hz_dup_check          := fnd_profile.value('AMS_HZ_DEDUPE_RULE');
2332      if x_hz_dup_check <> 'Y' then
2333        x_hz_dup_check := 'N';
2334      end if;
2335 
2336 --
2337    open  c_header_name;
2338    fetch c_header_name into l_import_list_header_name, l_server_flag, l_status_code, l_imp_type, l_execute_mode;
2339    close c_header_name;
2340 
2341    if l_execute_mode = 'R' then
2342          l_lookup_code := 'STAGED';
2343          l_status_code := 'STAGED';
2344          l_user_status_id := null;
2345          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2346          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2347          system_status_code = 'STAGED' and default_flag = 'Y';
2348 
2349          select as_import_interface_s.nextval into l_batch_id from dual;
2350 
2351          UPDATE ams_imp_list_headers_all
2352          set status_code      =  l_lookup_code,
2353             user_status_id    =  l_user_status_id,
2354             batch_id          =  l_batch_id,
2355             status_date       =  sysdate
2356          where import_list_header_id = p_import_list_header_id;
2357 
2358          UPDATE ams_imp_source_lines
2359             set batch_id          =  l_batch_id,
2360                 request_id        =  NULL
2361          where import_list_header_id = p_import_list_header_id
2362            and load_status in ('RELOAD','ACTIVE');
2363 
2364 
2365 
2366               AMS_Utility_PVT.Create_Log (
2367               x_return_status   => l_return_status,
2368               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2369               p_log_used_by_id  => p_import_list_header_id,
2370               p_msg_data        => 'Starting List Import in RELOAD Mode.',
2371               p_msg_type        => 'DEBUG'
2372               );
2373     end if;
2374 
2375  --  commented by ndadwal for Bug 5113207
2376  /*  if l_status_code = 'NEW' then
2377    if l_server_flag = 'Y' then
2378     if p_staged_only = 'Y' then
2379      UPDATE ams_imp_list_headers_all
2380         set loaded_no_of_rows =  l_loaded_rows,
2381             loaded_date       =  sysdate,
2382             status_code       =  'STAGING',
2383             status_date       =  sysdate
2384       where import_list_header_id = p_import_list_header_id;
2385        commit;
2386     end if;
2387 
2388 */
2389 -- added by ndadwal for Bug 5113207
2390    if l_status_code = 'NEW' then
2391    if l_server_flag = 'Y' then
2392     if p_staged_only = 'Y' then
2393      UPDATE ams_imp_list_headers_all
2394         set loaded_no_of_rows =  l_loaded_rows,
2395             loaded_date       =  sysdate,
2396             status_code       =  'STAGED',
2397             status_date       =  sysdate
2398       where import_list_header_id = p_import_list_header_id;
2399        commit;
2400     end if;
2401 
2402     l_lookup_code    := 'STAGED';
2403     l_user_status_id := null;
2404     SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2405     WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2406     system_status_code = 'STAGED' and default_flag = 'Y';
2407 
2408     UPDATE ams_imp_list_headers_all
2409        set loaded_no_of_rows =  l_loaded_rows,
2410            loaded_date       =  sysdate,
2411            status_code       =  l_lookup_code,
2412            user_status_id    =  l_user_status_id,
2413            status_date       =  sysdate
2414      where import_list_header_id = p_import_list_header_id;
2415 -- end ndadwal changes
2416 
2417        AMS_Utility_PVT.Create_Log (
2418          x_return_status   => l_return_status,
2419          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2420          p_log_used_by_id  => p_import_list_header_id,
2421          p_msg_data        => 'Starting SQL*LOADER program to load the data.',
2422          p_msg_type        => 'DEBUG'
2423        );
2424 
2425     -- Create the Executable entry.
2426     FND_PROGRAM.EXECUTABLE (
2427       executable           => l_short_name,
2428       application          => 'AMS',
2429       short_name           => l_short_name,
2430       description          => l_import_list_header_name,
2431       execution_method     => L_SQL_LOADER,
2432       execution_file_name  => p_control_file,
2433       language_code        => USERENV ('LANG')
2434       );
2435 
2436     --
2437     -- Register the concurrent program.
2438     FND_PROGRAM.REGISTER (
2439       program                 => l_short_name,
2440       application             => 'AMS',
2441       enabled                 => 'Y',
2442       short_name              => l_short_name,
2443       executable_short_name   => l_short_name,
2444       executable_application  => 'AMS',
2445       language_code           => USERENV ('LANG')
2446       );
2447 
2448     --
2449     -- Since this is a SQL*Loader concurrent program,
2450     -- we don't need to specify other parameters.  The
2451     -- only other parameter would be the data file name,
2452     -- but we will include that in the control file.
2453     --
2454      l_request_id := FND_REQUEST.SUBMIT_REQUEST (
2455                       application      => 'AMS',
2456                       program          => l_short_name,
2457                       start_time       => l_start_time
2458                    );
2459 
2460      IF l_request_id = 0 THEN
2461                     l_mesg_text := fnd_message.get;
2462                AMS_Utility_PVT.Create_Log (
2463                 x_return_status   => l_return_status,
2464                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2465                 p_log_used_by_id  => p_import_list_header_id,
2466                 p_msg_data        => l_mesg_text,
2467                 p_msg_type        => 'DEBUG' );
2468 
2469                 l_user_status_id := null;
2470                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2471                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2472                 system_status_code = 'ERROR'  and default_flag = 'Y';
2473                 UPDATE ams_imp_list_headers_all
2474                 set status_code       =  l_lookup_code,
2475                 user_status_id    =  l_user_status_id,
2476                 status_date       =  sysdate
2477                 where import_list_header_id = p_import_list_header_id;
2478                  commit;
2479           RAISE FND_API.g_exc_unexpected_error;
2480        ELSE
2481          FND_MESSAGE.set_name ('AMS', 'AMS_IMP_LOAD_REQUEST_ID');
2482          FND_MESSAGE.set_token ('REQUEST_ID', l_request_id);
2483 
2484         Ams_Utility_PVT.Create_Log (
2485          x_return_status   => l_return_status,
2486          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2487          p_log_used_by_id  => p_import_list_header_id,
2488          p_msg_data        => FND_MESSAGE.get,
2489          p_msg_type        => 'MILESTONE'
2490         );
2491      END IF;
2492      Commit;
2493        AMS_Utility_PVT.Create_Log (
2494          x_return_status   => l_return_status,
2495          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2496          p_log_used_by_id  => p_import_list_header_id,
2497          p_msg_data        => 'SQL*LOADER -- For details Please check the log file '||p_control_file||'.log',
2498          p_msg_type        => 'DEBUG'
2499        );
2500 
2501        AMS_Utility_PVT.Create_Log (
2502          x_return_status   => l_return_status,
2503          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2504          p_log_used_by_id  => p_import_list_header_id,
2505          p_msg_data        => 'SQL*LOADER -- For bad records Please check the bad file '||p_control_file||'.bad',
2506          p_msg_type        => 'DEBUG'
2507        );
2508 
2509 
2510      --
2511 
2512      -- The sql*loader concurrent program MUST finish
2513      -- before invoking the destination application
2514      -- concurrent program like TCA or LEADS.
2515      -- This is also required for the clean up process.
2516 
2517       l_wait_status := FND_CONCURRENT.WAIT_FOR_REQUEST (
2518                         request_id        => l_request_id,
2519                         phase             => l_phase,
2520                         status            => l_status,
2521                         dev_phase         => l_dev_phase,
2522                         dev_status        => l_dev_status,
2523                         message           => l_message
2524                         );
2525 
2526      ---------------------------------------------
2527      -- WAIT_STATUS should only come back as
2528      -- TRUE.  It only comes back as FALSE if
2529      -- the conc request was not successfully
2530      -- submitted.
2531      ---------------------------------------------
2532      IF NOT l_wait_status THEN
2533                     l_mesg_text := fnd_message.get;
2534                AMS_Utility_PVT.Create_Log (
2535                 x_return_status   => l_return_status,
2536                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2537                 p_log_used_by_id  => p_import_list_header_id,
2538                 p_msg_data        => l_mesg_text,
2539                 p_msg_type        => 'DEBUG' );
2540 
2541                 l_user_status_id := null;
2542                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2543                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2544                 system_status_code = 'ERROR' and default_flag = 'Y';
2545                 UPDATE ams_imp_list_headers_all
2546                 set status_code       =  l_lookup_code,
2547                 user_status_id    =  l_user_status_id,
2548                 status_date       =  sysdate
2549                 where import_list_header_id = p_import_list_header_id;
2550                 commit;
2551         RAISE FND_API.g_exc_unexpected_error;
2552      END IF;
2553 
2554      ---------------------------------------------
2555           OPEN c_loaded_rows;
2556           FETCH c_loaded_rows INTO l_loaded_rows;
2557           CLOSE c_loaded_rows;
2558 
2559      FND_MESSAGE.set_name ('AMS', 'AMS_IMP_LOADED_NO_ROWS');
2560      FND_MESSAGE.set_token ('NUM_ROWS', l_loaded_rows);
2561 
2562      Ams_Utility_PVT.Create_Log (
2563       x_return_status   => l_return_status,
2564       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2565       p_log_used_by_id  => p_import_list_header_id,
2566       p_msg_data        => FND_MESSAGE.get,
2567       p_msg_level       => 80,
2568       p_msg_type        => 'MILESTONE'
2569      );
2570 
2571      l_lookup_code    := 'STAGED';
2572      l_user_status_id := null;
2573      SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2574      WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2575      system_status_code = 'STAGED' and default_flag = 'Y';
2576 
2577      UPDATE ams_imp_list_headers_all
2578         set loaded_no_of_rows =  l_loaded_rows,
2579             loaded_date       =  sysdate,
2580             status_code       =  l_lookup_code,
2581             user_status_id    =  l_user_status_id,
2582             status_date       =  sysdate
2583       where import_list_header_id = p_import_list_header_id;
2584 
2585      --
2586      -- Clean-up the concurrent programs which were created
2587      -- during program execution.
2588      FND_PROGRAM.DELETE_PROGRAM (
2589           program_short_name   => l_short_name,
2590           application          => 'AMS'
2591      );
2592 
2593      --
2594      -- The "executable" will be the same as the program short name
2595      -- for all run-time generated concurrent programs.  The registered
2596      -- program must be deleted before the executable can be.
2597      FND_PROGRAM.DELETE_EXECUTABLE (
2598         executable_short_name      => l_short_name,
2599         application                => 'AMS'
2600      );
2601   end if; -- for server_flag
2602   end if; -- for status_code
2603 
2604  -- for post processing here the data is populated to the TCA and OSM
2605  -- applications using concurrent programs.
2606 
2607     open c_status;
2608     fetch c_status into l_st_code, l_dedupe_flag;
2609     close c_status;
2610 
2611 
2612   open c_rec_in_stag_tab;
2613    fetch c_rec_in_stag_tab into l_rec_in_stag_tab;
2614    close c_rec_in_stag_tab;
2615    if l_rec_in_stag_tab is NULL then
2616      AMS_Utility_PVT.Create_Log (
2617          x_return_status   => l_return_status,
2618          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2619          p_log_used_by_id  => p_import_list_header_id,
2620          p_msg_data        => 'Aborting import process, Staging table not populated.',
2621          p_msg_type        => 'DEBUG'
2622        );
2623        l_lookup_code := 'ERROR';
2624                 l_user_status_id := null;
2625                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2626                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2627                 system_status_code = 'ERROR' and default_flag = 'Y';
2628 
2629                 UPDATE ams_imp_list_headers_all
2630                 set status_code       =  l_lookup_code,
2631                 user_status_id    =  l_user_status_id,
2632                 status_date       =  sysdate
2633                 where import_list_header_id = p_import_list_header_id;
2634       return;
2635    end if;
2636 
2637 -- ------------------------------------------------------
2638 -- ------------RAISE PRE BUSINESS EVENT START ---------------------
2639 
2640               Raise_Business_event(p_import_list_header_id,
2641                                         'oracle.apps.ams.list.ListImportPreEvent');
2642 
2643 -- ------------RAISE PRE BUSINESS EVENT END ---------------------
2644 -- ------------------------------------------------------
2645 
2646 
2647    open osr_mapped;
2648    fetch osr_mapped into l_osr_mapped;
2649    close osr_mapped;
2650 -- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2651    gen_transposed_phone_number( x_import_list_header_id, x_return_status,
2652                                 x_msg_count, x_msg_data );
2653 
2654 if l_imp_type = 'B2B' then
2655 --if party_id is provided and if its of type relationship
2656 --update org_party_id and ocont_party_id
2657 update ams_hz_b2b_mapping_v b2b
2658 set (org_party_id, ocont_party_id) = (select object_id, subject_id from hz_relationships
2659 where party_id = b2b.party_id and object_type = 'ORGANIZATION'
2660 and subject_type = 'PERSON' and relationship_type = 'CONTACT'
2661 and nvl(status,'A') = 'A')
2662 where import_list_header_id = p_import_list_header_id
2663 and party_id is not null
2664 and org_party_id is null;
2665 
2666 --if party_id is of type organization then update org_party_id with party_id
2667 update ams_hz_b2b_mapping_v b2b
2668 set org_party_id = party_id
2669 where import_list_header_id = p_import_list_header_id
2670 and party_id is not null
2671 and org_party_id is null;
2672 
2673 update ams_hz_b2b_mapping_v
2674 set org_exist = 'Y'
2675 where import_list_header_id = p_import_list_header_id
2676 and org_party_id is not null;
2677 
2678 update ams_hz_b2b_mapping_v
2679 set ocont_exist = 'Y'
2680 where import_list_header_id = p_import_list_header_id
2681 and ocont_party_id is not null;
2682 
2683 elsif l_imp_type = 'B2C' then
2684 
2685     --aanjaria: bug 4913239: copy party_id to person_party_id so that existence check is by passed
2686        UPDATE ams_hz_b2c_mapping_v
2687           SET person_party_id = party_id,
2688 	      person_exist = 'Y'
2689 	WHERE import_list_header_id = p_import_list_header_id
2690 	  AND party_id is not null
2691 	  AND person_party_id is null;
2692 end if;
2693 
2694 commit;
2695 
2696  if x_hz_dup_check = 'Y' then
2697    if l_imp_type = 'B2B' then
2698      if l_osr_mapped = 'Y' then
2699        org_existence_checking_osr(x_import_list_header_id,
2700                           x_return_status,x_msg_count,x_msg_data);
2701      end if;
2702       org_existence_checking(x_import_list_header_id,
2703                           x_return_status,x_msg_count,x_msg_data);
2704       if x_return_status <> 'S' then
2705         AMS_Utility_PVT.Create_Log (
2706          x_return_status   => l_return_status,
2707          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2708          p_log_used_by_id  => p_import_list_header_id,
2709          p_msg_data        => 'Aborting org_existence_checking.',
2710          p_msg_type        => 'DEBUG');
2711          l_lookup_code := 'ERROR';
2712                 l_user_status_id := null;
2713                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2714                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2715                 system_status_code = 'ERROR' and default_flag = 'Y';
2716 
2717                 UPDATE ams_imp_list_headers_all
2718                 set status_code       =  l_lookup_code,
2719                 user_status_id    =  l_user_status_id,
2720                 status_date       =  sysdate
2721                 where import_list_header_id = p_import_list_header_id;
2722          return;
2723       end if;
2724 
2725      if l_osr_mapped = 'Y' then
2726       org_cont_existence_chk_osr(x_import_list_header_id,
2727                           x_return_status,x_msg_count,x_msg_data);
2728      end if;
2729       org_cont_existence_checking(x_import_list_header_id,
2730                           x_return_status,x_msg_count,x_msg_data);
2731       if x_return_status <> 'S' then
2732         AMS_Utility_PVT.Create_Log (
2733          x_return_status   => l_return_status,
2734          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2735          p_log_used_by_id  => p_import_list_header_id,
2736          p_msg_data        => 'Aborting org_cont_existence_checking.',
2737          p_msg_type        => 'DEBUG');
2738          l_lookup_code := 'ERROR';
2739                 l_user_status_id := null;
2740                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2741                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2742                 system_status_code = 'ERROR' and default_flag = 'Y';
2743                 UPDATE ams_imp_list_headers_all
2744                 set status_code       =  l_lookup_code,
2745                 user_status_id    =  l_user_status_id,
2746                 status_date       =  sysdate
2747                 where import_list_header_id = p_import_list_header_id;
2748          return;
2749       end if;
2750 
2751       org_address_existence_checking(x_import_list_header_id,
2752                           x_return_status,x_msg_count,x_msg_data);
2753       if x_return_status <> 'S' then
2754         AMS_Utility_PVT.Create_Log (
2755          x_return_status   => l_return_status,
2756          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2757          p_log_used_by_id  => p_import_list_header_id,
2758          p_msg_data        => 'Aborting org_address_existence_checking.',
2759          p_msg_type        => 'DEBUG');
2760          l_lookup_code := 'ERROR';
2761                 l_user_status_id := null;
2762                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2763                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2764                 system_status_code = 'ERROR' and default_flag = 'Y';
2765                 UPDATE ams_imp_list_headers_all
2766                 set status_code       =  l_lookup_code,
2767                 user_status_id    =  l_user_status_id,
2768                 status_date       =  sysdate
2769                 where import_list_header_id = p_import_list_header_id;
2770          return;
2771       end if;
2772 
2773       org_address1_exist_checking(x_import_list_header_id,
2774                           x_return_status,x_msg_count,x_msg_data);
2775       if x_return_status <> 'S' then
2776         AMS_Utility_PVT.Create_Log (
2777          x_return_status   => l_return_status,
2778          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2779          p_log_used_by_id  => p_import_list_header_id,
2780          p_msg_data        => 'Aborting org_address1_exist_checking.',
2781          p_msg_type        => 'DEBUG');
2782          l_lookup_code := 'ERROR';
2783                 l_user_status_id := null;
2784                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2785                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2786                 system_status_code = 'ERROR' and default_flag = 'Y';
2787                 UPDATE ams_imp_list_headers_all
2788                 set status_code       =  l_lookup_code,
2789                 user_status_id    =  l_user_status_id,
2790                 status_date       =  sysdate
2791                 where import_list_header_id = p_import_list_header_id;
2792          return;
2793       end if;
2794 
2795     ELSE
2796 
2797      if l_osr_mapped = 'Y' then
2798       per_existence_checking_osr(x_import_list_header_id,
2799                           x_return_status,x_msg_count,x_msg_data);
2800      end if;
2801       per_existence_checking(x_import_list_header_id,
2802                           x_return_status,x_msg_count,x_msg_data);
2803       if x_return_status <> 'S' then
2804         AMS_Utility_PVT.Create_Log (
2805          x_return_status   => l_return_status,
2806          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2807          p_log_used_by_id  => p_import_list_header_id,
2808          p_msg_data        => 'Aborting per_existence_checking.',
2809          p_msg_type        => 'DEBUG');         l_lookup_code := 'ERROR';
2810                 l_user_status_id := null;
2811                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2812                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2813                 system_status_code = 'ERROR' and default_flag = 'Y';
2814 
2815                 UPDATE ams_imp_list_headers_all
2816                 set status_code       =  l_lookup_code,
2817                 user_status_id    =  l_user_status_id,
2818                 status_date       =  sysdate
2819                 where import_list_header_id = p_import_list_header_id;
2820          return;
2821       end if;
2822 
2823       per_address_existence_checking(x_import_list_header_id,
2824                           x_return_status,x_msg_count,x_msg_data);
2825       if x_return_status <> 'S' then
2826         AMS_Utility_PVT.Create_Log (
2827          x_return_status   => l_return_status,
2828          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2829          p_log_used_by_id  => p_import_list_header_id,
2830          p_msg_data        => 'Aborting per_address_existence_checking.',
2831          p_msg_type        => 'DEBUG');
2832          l_lookup_code := 'ERROR';
2833                 l_user_status_id := null;
2834                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
2835                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
2836                 system_status_code = 'ERROR' and default_flag = 'Y';
2837 
2838                 UPDATE ams_imp_list_headers_all
2839                 set status_code       =  l_lookup_code,
2840                 user_status_id    =  l_user_status_id,
2841                 status_date       =  sysdate
2842                 where import_list_header_id = p_import_list_header_id;
2843          return;
2844       end if;
2845 end if;    -- l_imp_type
2846 end if;    --  if x_hz_dup_check = 'Y' then
2847 -- >>>>>>>>>>>>>
2848 
2849     if l_dedupe_flag = 'Y' then
2850               AMS_Utility_PVT.Create_Log (
2851               x_return_status   => l_return_status,
2852               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2853               p_log_used_by_id  => p_import_list_header_id,
2854               p_msg_data        => 'Starting De-Duplicate check in the Marketing tables .',
2855               p_msg_type        => 'DEBUG'
2856               );
2857 
2858               dedup_check( p_import_list_header_id);
2859 
2860               open c_dup_recs;
2861               fetch c_dup_recs into l_duplicate_records;
2862               close c_dup_recs;
2863               update ams_imp_list_headers_all
2864               set number_of_duplicate_records = l_duplicate_records
2865               where import_list_header_id = p_import_list_header_id;
2866 
2867               AMS_Utility_PVT.Create_Log (
2868               x_return_status   => l_return_status,
2869               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2870               p_log_used_by_id  => p_import_list_header_id,
2871               p_msg_data        => 'END De-Duplicate check in the Marketing tables .',
2872               p_msg_type        => 'DEBUG'
2873               );
2874     end if;
2875 
2876         if p_staged_only = 'N' then
2877             if l_st_code = 'STAGED' then
2878               AMS_Utility_PVT.Create_Log (
2879               x_return_status   => l_return_status,
2880               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2881               p_log_used_by_id  => p_import_list_header_id,
2882               p_msg_data        => 'Starting TCA/LEAD/EVENT program to load the data.',
2883               p_msg_type        => 'DEBUG'
2884               );
2885               open c_total_records;
2886               fetch c_total_records into l_total_records;
2887               close c_total_records;
2888               AMS_Utility_PVT.Create_Log (
2889                   x_return_status   => l_return_status,
2890                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2891                   p_log_used_by_id  => p_import_list_header_id,
2892                   p_msg_data  => 'Total Number of records available for processing: '||to_char(l_total_records),
2893                   p_msg_type        => 'DEBUG'
2894                 );
2895        execute_reltnship_validation( p_import_list_header_id, l_return_status);
2896            l_total_records := 0;
2897            open c_total_records;
2898            fetch c_total_records into l_total_records;
2899            close c_total_records;
2900            if l_total_records = 0 then
2901                 update_cust_import_status(p_import_list_header_id);
2902                 return;
2903            end if;
2904 
2905              list_loader ( p_import_list_header_id ,
2906                            l_post_request_id
2907                          );
2908              l_total_records := 0;
2909              open c_total_records;
2910              fetch c_total_records into l_total_records;
2911              close c_total_records;
2912              AMS_Utility_PVT.Create_Log (
2913                   x_return_status   => l_return_status,
2914                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2915                   p_log_used_by_id  => p_import_list_header_id,
2916                   p_msg_data  => 'Total Number of records not processed: '||to_char(l_total_records),
2917                   p_msg_type        => 'DEBUG'
2918                 );
2919 
2920 
2921 --aanjaria: bug 3888657
2922 -- commenting out follwoing code as list gen was already called by AMSILHZC conc prog
2923 -- spawned from within list_loader API. This was generating a duplicate list.
2924 /*
2925              if p_generate_list = 'Y' then
2926               AMS_Utility_PVT.Create_Log (
2927               x_return_status   => l_return_status,
2928               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2929               p_log_used_by_id  => p_import_list_header_id,
2930               p_msg_data        => 'Starting List Generation for List Import.',
2931               p_msg_type        => 'DEBUG'
2932               );
2933               l_load_rows := 0;
2934               select LOADED_NO_OF_ROWS into l_load_rows from ams_imp_list_headers_all
2935               where import_list_header_id = p_import_list_header_id;
2936 
2937              if l_load_rows > 0 then
2938 
2939 
2940              AMS_ListGeneration_PKG.create_import_list
2941                 ( 1,
2942                   'T',
2943                   'T',
2944                   FND_API.G_VALID_LEVEL_FULL,
2945                   p_owner_user_id,
2946                   p_import_list_header_id,
2947                   i_return_status,
2948                   i_msg_count,
2949                   i_msg_data,
2950                   l_list_header_id,
2951                   p_list_name) ;
2952 
2953              If i_return_status <> 'S' then
2954               AMS_Utility_PVT.Create_Log (
2955               x_return_status   => l_return_status,
2956               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2957               p_log_used_by_id  => p_import_list_header_id,
2958               p_msg_data        => 'Error in List Generation --'||i_msg_data,
2959               p_msg_type        => 'DEBUG'
2960               );
2961              End if;
2962              end if;
2963              AMS_Utility_PVT.Create_Log (
2964               x_return_status   => l_return_status,
2965               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2966               p_log_used_by_id  => p_import_list_header_id,
2967               p_msg_data        => 'End List Generation for List Import.',
2968               p_msg_type        => 'DEBUG'
2969               );
2970              end if; */
2971             end if;
2972         end if;
2973 
2974 
2975      -- Import completed successfully
2976      FND_MESSAGE.set_name ('AMS', 'AMS_IMP_LOAD_COMPLETE');
2977      FND_MESSAGE.set_token ('REQUEST_ID', l_request_id);
2978 
2979      AMS_Utility_PVT.Create_Log (
2980       x_return_status   => l_return_status,
2981       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2982       p_log_used_by_id  => p_import_list_header_id,
2983       p_msg_data        => FND_MESSAGE.get,
2984       p_msg_type        => 'DEBUG'
2985      );
2986 
2987    errbuf := SUBSTR (FND_MESSAGE.GET, 1, 240);
2988    retcode := 0;  -- no problems.
2989 
2990 EXCEPTION
2991    WHEN OTHERS THEN
2992       AMS_Utility_PVT.Create_Log (
2993          x_return_status   => l_return_status,
2994          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
2995          p_log_used_by_id  => p_import_list_header_id,
2996          p_msg_data        => sqlerrm ,
2997          p_msg_type        => 'DEBUG'
2998       );
2999       FND_MESSAGE.set_name ('AMS', 'AMS_IMP_LOAD_FAILED');
3000       FND_MESSAGE.set_token ('REQUEST_ID', l_request_id);
3001       l_msg_buf := FND_MESSAGE.get;
3002 
3003       AMS_Utility_PVT.Create_Log (
3004          x_return_status   => l_return_status,
3005          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3006          p_log_used_by_id  => p_import_list_header_id,
3007          p_msg_data        => l_msg_buf,
3008          p_msg_type        => 'DEBUG'
3009       );
3010       errbuf := SUBSTR (l_msg_buf, 1, 240);
3011       retcode := 2;
3012 
3013 END load_to_ams;
3014 
3015 -- ------------------------------------------------------
3016 -- This program calls concurrent programs for TCA , Leads
3017 -- etc to populate the data.
3018 --
3019 
3020 PROCEDURE list_loader (
3021                       p_import_list_header_id NUMBER,
3022                       x_request_id   OUT NOCOPY NUMBER
3023                      ) IS
3024 
3025    l_request_id         NUMBER;
3026    l_return_status      VARCHAR2(1);
3027    l_import_type        VARCHAR2(30);
3028    l_conc_prog_name     VARCHAR2(60);
3029    l_lookup_code        VARCHAR2(30);
3030    l_user_status_id     NUMBER;
3031 
3032    l_phase              VARCHAR2(30);
3033    l_appli              VARCHAR2(30);
3034    l_prog               VARCHAR2(30);
3035    l_status             VARCHAR2(30);
3036    l_dev_phase          VARCHAR2(30);
3037    l_dev_status         VARCHAR2(30);
3038    l_message            VARCHAR2(240);
3039    l_rstatus            BOOLEAN;
3040    l_wait_status        BOOLEAN;
3041    l_batch_id           NUMBER;
3042    l_validate_file      VARCHAR2(1);
3043    l_error_exist        VARCHAR2(1);
3044    l_loaded_records     NUMBER;
3045    l_failed_records     NUMBER;
3046 
3047    i_msg_buf            VARCHAR2(4000);
3048    i_msg_code           NUMBER;
3049    l_mesg_text          VARCHAR2(2000);
3050    l_numb_of_inst       number;
3051 
3052 
3053    cursor c_import_type is
3054    select import_type,VALIDATE_FILE,NUMBER_OF_INSTANCES from ams_imp_list_headers_all
3055    where import_list_header_id = p_import_list_header_id;
3056 
3057    cursor c_conc_name is
3058    SELECT concurrent_program FROM ams_imp_list_import_types
3059    where  import_type = l_import_type;
3060 
3061    cursor c_error_exist is
3062          select 'Y' from ams_list_import_errors
3063             where import_list_header_id = p_import_list_header_id
3064             and error_type = 'E'
3065             and rownum < 2;
3066 
3067  cursor c_loaded_records is
3068    select count(*) from ams_imp_source_lines
3069    where import_list_header_id = p_import_list_header_id
3070      and load_status = G_STATUS_SUCCESS;
3071 
3072  cursor c_failed_records is
3073    select count(*) from ams_imp_source_lines
3074    where import_list_header_id = p_import_list_header_id
3075      and load_status = G_STATUS_ERROR;
3076 
3077 
3078 
3079 begin
3080 
3081    open  c_import_type;
3082    fetch c_import_type into l_import_type,l_validate_file,l_numb_of_inst;
3083    close c_import_type;
3084    open  c_conc_name;
3085    fetch c_conc_name into l_conc_prog_name;
3086    close c_conc_name;
3087 
3088       l_lookup_code    := 'SCHEDULED';
3089       l_user_status_id := null;
3090      SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3091      WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3092      system_status_code = 'SCHEDULED' and default_flag = 'Y';
3093 
3094 
3095       UPDATE ams_imp_list_headers_all
3096         set status_code       =  l_lookup_code,
3097             user_status_id    =  l_user_status_id,
3098             status_date       =  sysdate
3099       where import_list_header_id = p_import_list_header_id;
3100 
3101    -- if l_import_type = 'CUSTOMER' then
3102    if (l_import_type = 'B2B' or l_import_type = 'B2C') then
3103         -- Call the Validate Process
3104         if l_validate_file = 'Y' then
3105              AMS_Utility_PVT.Create_Log (
3106                   x_return_status   => l_return_status,
3107                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3108                   p_log_used_by_id  => p_import_list_header_id,
3109                   p_msg_data        => 'Starting Validation for Customer data.',
3110                   p_msg_type        => 'DEBUG'
3111                 );
3112 
3113              -- Delete all the errors from the errors table which are reloaded.
3114 		 delete from ams_list_import_errors where import_list_header_id
3115                 = p_import_list_header_id and import_source_line_id = 0;
3116                 delete from ams_list_import_errors where import_list_header_id
3117                 = p_import_list_header_id and import_source_line_id in
3118                 (select import_source_line_id from ams_imp_source_lines where
3119                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_RELOAD);
3120 /*
3121                 if l_file_type = 'XML' then
3122                      update_xml_error_text (
3123                                         p_import_list_header_id,
3124                                         l_import_type);
3125                 end if;
3126 */
3127                 l_return_status := null;
3128                 execute_cust_data_validation ( p_import_list_header_id, l_return_status);
3129              if l_return_status <> 'S' then
3130               AMS_Utility_PVT.Create_Log (
3131                   x_return_status   => l_return_status,
3132                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3133                   p_log_used_by_id  => p_import_list_header_id,
3134                   p_msg_data        => 'Customer import terminated because of error in Data validation process.',
3135                   p_msg_type        => 'DEBUG'
3136                 );
3137 
3138                 l_lookup_code := 'ERROR';
3139                 l_user_status_id := null;
3140                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3141                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3142                 system_status_code = 'ERROR' and default_flag = 'Y';
3143 
3144                 UPDATE ams_imp_list_headers_all
3145                 set status_code       =  l_lookup_code,
3146                 user_status_id    =  l_user_status_id,
3147                 status_date       =  sysdate
3148                 where import_list_header_id = p_import_list_header_id;
3149                 return;
3150              end if;
3151 
3152              AMS_Utility_PVT.Create_Log (
3153                   x_return_status   => l_return_status,
3154                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3155                   p_log_used_by_id  => p_import_list_header_id,
3156                   p_msg_data        => 'End Validation for Customer data.',
3157                   p_msg_type        => 'DEBUG'
3158                 );
3159         end if;
3160 
3161       l_request_id := FND_REQUEST.SUBMIT_REQUEST (
3162                       application       => 'AMS',
3163                       program           => l_conc_prog_name,    -- 'AMSILHZC',
3164                       argument1         => p_import_list_header_id,
3165 		      argument2         => l_numb_of_inst
3166                    );
3167 
3168               AMS_Utility_PVT.Create_Log (
3169               x_return_status   => l_return_status,
3170               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3171               p_log_used_by_id  => p_import_list_header_id,
3172               p_msg_data        => 'Starting TCA program (AMSILHZC) -- concurrent program_id is '||to_char(l_request_id),
3173               p_msg_type        => 'DEBUG'
3174               );
3175 
3176    end if;
3177 
3178      IF l_request_id = 0 THEN
3179                     l_mesg_text := fnd_message.get;
3180                AMS_Utility_PVT.Create_Log (
3181                 x_return_status   => l_return_status,
3182                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3183                 p_log_used_by_id  => p_import_list_header_id,
3184                 p_msg_data        => l_mesg_text,
3185                 p_msg_type        => 'DEBUG' );
3186 
3187                 l_user_status_id := null;
3188                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3189                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3190                 system_status_code = 'ERROR' and default_flag = 'Y';
3191                 UPDATE ams_imp_list_headers_all
3192                 set status_code       =  l_lookup_code,
3193                 user_status_id    =  l_user_status_id,
3194                 status_date       =  sysdate
3195                 where import_list_header_id = p_import_list_header_id;
3196                 commit;
3197           RAISE FND_API.g_exc_unexpected_error;
3198      end if;
3199 
3200     if l_import_type = 'LEAD' then
3201 /*
3202       SELECT batch_id into l_batch_id FROM as_import_interface
3203       WHERE IMP_LIST_HEADER_NUMBER =  p_import_list_header_id AND ROWNUM < 2;
3204       l_request_id := FND_REQUEST.SUBMIT_REQUEST (
3205                       application       => 'AS',             -- 'AST',
3206                       program           => l_conc_prog_name, -- ' ASXSLIMP' 'AST_LEAD_IMPORT',
3207                       argument1         => 'NEW',            -- 'ORACLE.COM',
3208                       argument2         => NULL,
3209                       argument3         => l_batch_id,       --  NULL,
3210                       argument4         => 'N'
3211                    );
3212 */
3213         execute_lead_import ( p_import_list_header_id);
3214 /*
3215         l_request_id := FND_REQUEST.SUBMIT_REQUEST (
3216                       application       => 'AMS',
3217                       program           => 'AMSILLDC',
3218                       argument1         => p_import_list_header_id
3219                    );
3220              AMS_Utility_PVT.Create_Log (
3221               x_return_status   => l_return_status,
3222               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3223               p_log_used_by_id  => p_import_list_header_id,
3224              p_msg_data        => 'Starting LEAD program (ASXSLIMP) -- concurrent program_id is '||to_char(l_request_id),
3225               p_msg_type        => 'DEBUG'
3226               );
3227 */
3228    end if;
3229 /*
3230     IF l_request_id = 0 THEN
3231           RAISE FND_API.g_exc_unexpected_error;
3232      end if;
3233 */
3234     if l_import_type = 'EVENT' then
3235         -- Call the Validate Process
3236         if l_validate_file = 'Y' then
3237              AMS_Utility_PVT.Create_Log (
3238                   x_return_status   => l_return_status,
3239                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3240                   p_log_used_by_id  => p_import_list_header_id,
3241                   p_msg_data        => 'Starting Validation for Event data.',
3242                   p_msg_type        => 'DEBUG'
3243                 );
3244 
3245              -- Delete all the errors from the errors table which are reloaded.
3246                  delete from ams_list_import_errors where import_list_header_id
3247                 = p_import_list_header_id and import_source_line_id = 0;
3248                 delete from ams_list_import_errors where import_list_header_id
3249                 = p_import_list_header_id and import_source_line_id in
3250                 (select import_source_line_id from ams_imp_source_lines where
3251                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_RELOAD);
3252 
3253                 l_return_status := null;
3254                 execute_event_data_validation ( p_import_list_header_id, l_return_status);
3255              if l_return_status <> 'S' then
3256               AMS_Utility_PVT.Create_Log (
3257                   x_return_status   => l_return_status,
3258                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3259                   p_log_used_by_id  => p_import_list_header_id,
3260                   p_msg_data        => 'Event import terminated because of error in Data validation process.',
3261                   p_msg_type        => 'DEBUG'
3262                 );
3263 
3264                 l_lookup_code := 'ERROR';
3265                 l_user_status_id := null;
3266                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3267                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3268                 system_status_code = 'ERROR' and default_flag = 'Y';
3269 
3270                 UPDATE ams_imp_list_headers_all
3271                 set status_code       =  l_lookup_code,
3272                 user_status_id    =  l_user_status_id,
3273                 status_date       =  sysdate
3274                 where import_list_header_id = p_import_list_header_id;
3275                 return;
3276              end if;
3277 
3278              AMS_Utility_PVT.Create_Log (
3279                   x_return_status   => l_return_status,
3280                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3281                   p_log_used_by_id  => p_import_list_header_id,
3282                   p_msg_data        => 'End Validation for Event data.',
3283                   p_msg_type        => 'DEBUG'
3284                 );
3285         end if;
3286 
3287       l_request_id := FND_REQUEST.SUBMIT_REQUEST (
3288                       application       => 'AMS',             -- 'AST',
3289                       program           => l_conc_prog_name, -- ' AMSERIMP',
3290                       argument1         => p_import_list_header_id
3291                    );
3292 
3293            AMS_Utility_PVT.Create_Log (
3294               x_return_status   => l_return_status,
3295               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3296               p_log_used_by_id  => p_import_list_header_id,
3297             p_msg_data        => 'Starting EVENT program (AMSERIMP) -- concurrent program_id is '||to_char(l_request_id),
3298               p_msg_type        => 'DEBUG'
3299               );
3300 
3301    end if;
3302      commit;
3303      -- The sql*loader concurrent program MUST finish
3304      -- before updating the status_code
3305 
3306       l_wait_status := FND_CONCURRENT.WAIT_FOR_REQUEST (
3307                         request_id        => l_request_id,
3308                         phase             => l_phase,
3309                         status            => l_status,
3310                         dev_phase         => l_dev_phase,
3311                         dev_status        => l_dev_status,
3312                         message           => l_message
3313                         );
3314 
3315      ---------------------------------------------
3316      -- WAIT_STATUS should only come back as
3317      -- TRUE.  It only comes back as FALSE if
3318      -- the conc request was not successfully
3319      -- submitted.
3320      ---------------------------------------------
3321      IF NOT l_wait_status THEN
3322                     l_mesg_text := fnd_message.get;
3323                AMS_Utility_PVT.Create_Log (
3324                 x_return_status   => l_return_status,
3325                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3326                 p_log_used_by_id  => p_import_list_header_id,
3327                 p_msg_data        => l_mesg_text,
3328                 p_msg_type        => 'DEBUG' );
3329 
3330                 l_user_status_id := null;
3331                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3332                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3333                 system_status_code = 'ERROR' and default_flag = 'Y';
3334                 UPDATE ams_imp_list_headers_all
3335                 set status_code       =  l_lookup_code,
3336                 user_status_id    =  l_user_status_id,
3337                 status_date       =  sysdate
3338                 where import_list_header_id = p_import_list_header_id;
3339                 commit;
3340         RAISE FND_API.g_exc_unexpected_error;
3341      END IF;
3342 /*
3343     if l_import_type = 'LEAD' then
3344           capture_lead_error(p_import_list_header_id);
3345     end if;
3346 */
3347      l_rstatus := FND_CONCURRENT.get_REQUEST_status (
3348                         request_id        => l_request_id,
3349                         APPL_SHORTNAME    => l_appli,
3350                         program           => l_prog,
3351                         phase             => l_phase,
3352                         status            => l_status,
3353                         dev_phase         => l_dev_phase,
3354                         dev_status        => l_dev_status,
3355                         message           => l_message
3356                         );
3357 
3358      if l_dev_phase = 'COMPLETE' then
3359       if l_dev_status = 'NORMAL' then
3360        l_lookup_code    := 'COMPLETED';
3361        l_user_status_id := null;
3362        SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3363        WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3364        system_status_code = 'COMPLETED' and default_flag = 'Y';
3365       end if;
3366       if l_dev_status = 'ERROR' then
3367        l_lookup_code    := 'ERROR';
3368        l_user_status_id := null;
3369        SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3370        WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3371        system_status_code = 'ERROR' and default_flag = 'Y';
3372       end if;
3373 
3374        UPDATE ams_imp_list_headers_all
3375         set status_code       = l_lookup_code,
3376             user_status_id    = l_user_status_id,
3377             status_date       =  sysdate
3378        where import_list_header_id = p_import_list_header_id;
3379      end if;
3380 
3381          -- Delete all the errors from the errors table which are sucessful.
3382                 delete from ams_list_import_errors where import_list_header_id
3383                 = p_import_list_header_id and import_source_line_id in
3384                 (select import_source_line_id from ams_imp_source_lines where
3385                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_SUCCESS);
3386 
3387      open c_loaded_records;
3388      fetch c_loaded_records into l_loaded_records;
3389      close c_loaded_records;
3390      open c_failed_records;
3391      fetch c_failed_records into l_failed_records;
3392      close c_failed_records;
3393      UPDATE ams_imp_list_headers_all
3394         SET loaded_no_of_rows = l_loaded_records,
3395             number_of_failed_records = l_failed_records,
3396             loaded_date = sysdate
3397       WHERE import_list_header_id = p_import_list_header_id;
3398 
3399 
3400    COMMIT;
3401    x_request_id := l_request_id;
3402      open c_error_exist;
3403       fetch c_error_exist into l_error_exist;
3404       close c_error_exist;
3405       if l_error_exist = 'Y' then
3406          l_lookup_code := 'ERROR';
3407          l_user_status_id := null;
3408          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3409          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3410          system_status_code = 'ERROR' and default_flag = 'Y';
3411 
3412          UPDATE ams_imp_list_headers_all
3413          set status_code       =  l_lookup_code,
3414             user_status_id    =  l_user_status_id,
3415             status_date       =  sysdate
3416          where import_list_header_id = p_import_list_header_id;
3417       end if;
3418 
3419 EXCEPTION
3420        WHEN  others THEN
3421         AMS_Utility_PVT.Create_Log (
3422          x_return_status   => l_return_status,
3423          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3424          p_log_used_by_id  => p_import_list_header_id,
3425          p_msg_data        => sqlerrm ,
3426          p_msg_type        => 'DEBUG'
3427         );
3428         raise;
3429 
3430 end list_loader;
3431 
3432 -- --------------------------------------------
3433 --
3434 -- This is the main program which calls all the concurrent programs
3435 -- to populate the data in OMO and then other destination application
3436 -- like TCA or Oracle sales etc.
3437 --
3438 PROCEDURE Import_process (
3439    p_import_list_header_id    IN    NUMBER,
3440    p_start_time               IN    DATE,
3441    p_control_file             IN    VARCHAR2,   -- Name of file to be used by the SQL*Loader process.
3442    p_staged_only              IN    VARCHAR2 , -- Used for staged table import.
3443    p_owner_user_id            IN    NUMBER,     -- Used for list generation (resource_id)
3444    p_generate_list            IN    VARCHAR2 ,
3445    p_list_name                IN    VARCHAR2,   -- For list generation name.
3446    x_request_id               OUT NOCOPY   NUMBER     -- Used for concurrent program monitoring (for sql*loader).
3447 ) IS
3448 
3449    l_request_id    	NUMBER;
3450    l_message            VARCHAR2(240);
3451    l_return_status      VARCHAR2(1);
3452    l_ret_status         VARCHAR2(1);
3453    l_msg_count          NUMBER;
3454    l_msg_data           VARCHAR2(2000);
3455    l_msg_buf            VARCHAR2(4000);
3456    l_file_type          VARCHAR2(30);
3457    L_LOOKUP_CODE        VARCHAR2(30);
3458    L_USER_STATUS_ID     NUMBER;
3459    x_imp_type           VARCHAR2(240);
3460       L_MESG_TEXT		VARCHAR2(2000);
3461 
3462 
3463  cursor c_file_type is
3464  select file_type from ams_imp_documents where import_list_header_id = p_import_list_header_id;
3465 
3466 cursor c_imptype is
3467 select import_type from ams_imp_list_headers_all where import_list_header_id = p_import_list_header_id;
3468 
3469 
3470 begin
3471 
3472        AMS_Utility_PVT.Create_Log (
3473          x_return_status   => l_ret_status,
3474          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3475          p_log_used_by_id  => p_import_list_header_id,
3476          p_msg_data        => 'Starting List Import Process',
3477          p_msg_type        => 'DEBUG'
3478        );
3479         update ams_imp_list_headers_all
3480            set GENERATE_LIST = decode(p_generate_list,'Y','Y','DUMMY','N','N'),
3481                GENERATED_LIST_NAME = p_list_name
3482         where import_list_header_id = p_import_list_header_id;
3483         commit;
3484 
3485      open c_file_type;
3486      fetch c_file_type into l_file_type;
3487      close c_file_type;
3488    if l_file_type is NULL then
3489      AMS_Utility_PVT.Create_Log (
3490          x_return_status   => l_return_status,
3491          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3492          p_log_used_by_id  => p_import_list_header_id,
3493          p_msg_data        => 'Aborting import process, File type missing.',
3494          p_msg_type        => 'DEBUG'
3495        );
3496        l_lookup_code := 'ERROR';
3497                 l_user_status_id := null;
3498                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3499                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3500                 system_status_code = 'ERROR' and default_flag = 'Y';
3501 
3502                 UPDATE ams_imp_list_headers_all
3503                 set status_code       =  l_lookup_code,
3504                 user_status_id    =  l_user_status_id,
3505                 status_date       =  sysdate
3506                 where import_list_header_id = p_import_list_header_id;
3507       return;
3508    end if;
3509 
3510     open c_imptype;
3511     fetch c_imptype into x_imp_type;
3512     close c_imptype;
3513     if (l_file_type = 'XML' and x_imp_type in ('LEAD','EVENT')) then
3514      AMS_Utility_PVT.Create_Log (
3515          x_return_status   => l_return_status,
3516          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3517          p_log_used_by_id  => p_import_list_header_id,
3518          p_msg_data        => 'XML import is not available for EVENT and LEADS, Aborting import process',
3519          p_msg_type        => 'DEBUG'
3520        );
3521                 l_user_status_id := null;
3522                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3523                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3524                 system_status_code = 'ERROR' and default_flag = 'Y';
3525 
3526                 UPDATE ams_imp_list_headers_all
3527                 set status_code   =  'ERROR',
3528                 user_status_id    =  l_user_status_id,
3529                 status_date       =  sysdate
3530                 where import_list_header_id = p_import_list_header_id;
3531       return;
3532     end if;
3533 
3534   if l_file_type = 'CSV' then
3535   --
3536   -- SQL*LOADER call to populate the data in OMO tables.
3537   --
3538    l_request_id := FND_REQUEST.SUBMIT_REQUEST (
3539                       application   => 'AMS',
3540                       program       => 'AMSILOMC',
3541                       argument1     => p_import_list_header_id,
3542                       argument2     => p_control_file,
3543                       argument3     => p_staged_only,
3544                       argument4     => p_owner_user_id,
3545                       argument5     => p_generate_list,
3546                       argument6     => p_list_name
3547                    );
3548      IF l_request_id = 0 THEN
3549                     l_mesg_text := fnd_message.get;
3550                AMS_Utility_PVT.Create_Log (
3551                 x_return_status   => l_return_status,
3552                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3553                 p_log_used_by_id  => p_import_list_header_id,
3554                 p_msg_data        => l_mesg_text,
3555                 p_msg_type        => 'DEBUG' );
3556 
3557                 l_user_status_id := null;
3558                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3559                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3560                 system_status_code = 'ERROR'  and default_flag = 'Y';
3561                 UPDATE ams_imp_list_headers_all
3562                 set status_code       =  l_lookup_code,
3563                 user_status_id    =  l_user_status_id,
3564                 status_date       =  sysdate
3565                 where import_list_header_id = p_import_list_header_id;
3566                 commit;
3567 
3568           RAISE FND_API.g_exc_unexpected_error;
3569      end if;
3570        AMS_Utility_PVT.Create_Log (
3571          x_return_status   => l_ret_status,
3572          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3573          p_log_used_by_id  => p_import_list_header_id,
3574          p_msg_data        => 'List Import Concurrent Program AMSILOMC Started.',
3575          p_msg_type        => 'DEBUG'
3576        );
3577     x_request_id := l_request_id;
3578   end if;
3579   if l_file_type = 'XML' then
3580             client_load_direct (
3581                       p_import_list_header_id,
3582                       p_owner_user_id,
3583                       p_generate_list,
3584                       p_list_name);
3585   end if;
3586 
3587 EXCEPTION
3588        WHEN  others THEN
3589           raise;
3590 
3591 end Import_process;
3592 
3593 
3594 -- ------------------------------------------
3595 
3596 PROCEDURE client_load(
3597                       p_import_list_header_id  IN NUMBER,
3598                       p_owner_user_id          IN NUMBER,
3599                       p_generate_list          IN    VARCHAR2 ,
3600                       p_list_name              IN    VARCHAR2   -- For list generation name.
3601                      ) IS
3602 
3603 x_prof_file_size       VARCHAR2(100);
3604 x_file_type            VARCHAR2(100);
3605 x_imp_type             VARCHAR2(100);
3606 x_client_file_size     NUMBER;
3607 l_return_status        VARCHAR2(1);
3608 l_request_id           NUMBER;
3609 l_user_status_id       number;
3610 L_MESG_TEXT             varchar2(2000);
3611 L_LOOKUP_CODE           varchar2(30);
3612 
3613 cursor c_prof_file_size is
3614 select file_size, file_type from AMS_IMP_DOCUMENTS where import_list_header_id = p_import_list_header_id;
3615 
3616 cursor c_imptype is
3617 select import_type from ams_imp_list_headers_all where import_list_header_id = p_import_list_header_id;
3618 
3619 BEGIN
3620  --   x_prof_file_size := fnd_profile.value('AMS_IMP_CLIENT_FILE_SIZE');
3621     open c_prof_file_size;
3622     fetch c_prof_file_size into x_client_file_size,x_file_type;
3623     close c_prof_file_size;
3624     open c_imptype;
3625     fetch c_imptype into x_imp_type;
3626     close c_imptype;
3627             update ams_imp_list_headers_all
3628            set GENERATE_LIST = decode(p_generate_list,'Y','Y','DUMMY','N','N'),
3629                GENERATED_LIST_NAME = p_list_name
3630         where import_list_header_id = p_import_list_header_id;
3631         commit;
3632 
3633     if (x_file_type = 'XML' and x_imp_type in ('LEAD','EVENT')) then
3634      AMS_Utility_PVT.Create_Log (
3635          x_return_status   => l_return_status,
3636          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3637          p_log_used_by_id  => p_import_list_header_id,
3638          p_msg_data        => 'XML import is not available for EVENT and LEADS, Aborting import process',
3639          p_msg_type        => 'DEBUG'
3640        );
3641                 l_user_status_id := null;
3642                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3643                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3644                 system_status_code = 'ERROR' and default_flag = 'Y';
3645 
3646                 UPDATE ams_imp_list_headers_all
3647                 set status_code   =  'ERROR',
3648                 user_status_id    =  l_user_status_id,
3649                 status_date       =  sysdate
3650                 where import_list_header_id = p_import_list_header_id;
3651       return;
3652     end if;
3653            l_request_id := FND_REQUEST.SUBMIT_REQUEST (
3654                       application       => 'AMS',
3655                       program           => 'AMSIMCCM',
3656                       argument1         => p_import_list_header_id,
3657                       argument2         => p_owner_user_id,
3658                       argument3         => p_generate_list,
3659                       argument4         => p_list_name
3660                       );
3661            AMS_Utility_PVT.Create_Log (
3662            x_return_status   => l_return_status,
3663            p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3664            p_log_used_by_id  => p_import_list_header_id,
3665            p_msg_data        => 'Starting client side import program (AMSIMCCM) -- concurrent program_id is '||to_char(l_request_id),
3666            p_msg_type        => 'DEBUG');
3667            commit;
3668            IF l_request_id = 0 THEN
3669 	                  l_mesg_text := fnd_message.get;
3670                AMS_Utility_PVT.Create_Log (
3671                 x_return_status   => l_return_status,
3672                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3673                 p_log_used_by_id  => p_import_list_header_id,
3674                 p_msg_data        => l_mesg_text,
3675                 p_msg_type        => 'DEBUG' );
3676 
3677                 l_user_status_id := null;
3678                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
3679                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
3680                 system_status_code = 'ERROR' and default_flag = 'Y';
3681                 UPDATE ams_imp_list_headers_all
3682                 set status_code       =  l_lookup_code,
3683                 user_status_id    =  l_user_status_id,
3684                 status_date       =  sysdate
3685                 where import_list_header_id = p_import_list_header_id;
3686                 commit;
3687               RAISE FND_API.g_exc_unexpected_error;
3688            end if;
3689 
3690 EXCEPTION
3691        WHEN  others THEN
3692         AMS_Utility_PVT.Create_Log (
3693          x_return_status   => l_return_status,
3694          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3695          p_log_used_by_id  => p_import_list_header_id,
3696          p_msg_data        => sqlerrm ,
3697          p_msg_type        => 'DEBUG'
3698         );
3699           raise;
3700 end client_load;
3701 
3702 
3703 -- -------------------------------------------
3704 --
3705 -- This progam checkes the de-duplication rules
3706 
3707 PROCEDURE dedup_check(
3708                       p_import_list_header_id NUMBER
3709                      ) IS
3710 
3711   i_rule_id        NUMBER;
3712   i                NUMBER := 0;
3713   i_col_string     VARCHAR2(2000);
3714   i_string         VARCHAR2(4000);
3715   i_str            VARCHAR2(4000);
3716   i_str1           VARCHAR2(4000);
3717   i_str2           VARCHAR2(4000);
3718   i_column         VARCHAR2(60);
3719   i_table_name     VARCHAR2(60);
3720   l_return_status  VARCHAR2(1);
3721   l_word_replace   VARCHAR2(1);
3722   l_b2b_flag       VARCHAR2(1);
3723   i_org_value      VARCHAR2(60);
3724   i_rep_value      VARCHAR2(60);
3725   i_replace_value  VARCHAR2(60);
3726   i_imp_src_line_id        NUMBER;
3727   i_word_rep_type  VARCHAR2(60);
3728   i_file_type  VARCHAR2(60);
3729   i_xml_element_id        NUMBER;
3730   l_rule_type VARCHAR2(30);
3731 
3732 
3733 /* mayjain bug 5235979 */
3734   cursor c_rule_type is
3735          SELECT 'IMPORT_CUST_' || import_type
3736          FROM ams_imp_list_headers_all
3737          where import_list_header_id = p_import_list_header_id;
3738 
3739   cursor c_ruleid (p_rule_type VARCHAR2) is
3740          SELECT us.list_rule_id
3741          FROM ams_list_rule_usages us, ams_list_rules_all rules
3742          WHERE us.list_header_id = p_import_list_header_id
3743          AND us.list_rule_id = rules.list_rule_id
3744          AND rules.list_rule_type = p_rule_type;
3745 /* mayjain bug 5235979 */
3746 
3747   cursor c_rule_field is
3748          SELECT field_column_name, WORD_REPLACEMENT_CODE
3749          FROM ams_list_rule_fields
3750          WHERE list_rule_id =  i_rule_id;
3751 
3752   cursor c_table_name is
3753          SELECT field_table_name FROM ams_list_rule_fields
3754          WHERE list_rule_id =  i_rule_id;
3755 
3756   cursor c_word is
3757          select nvl(ENABLE_WORD_REPLACEMENT_FLAG,'N'), nvl(b2b_flag,'N') from
3758          ams_imp_list_headers_all
3759          WHERE import_list_header_id = p_import_list_header_id;
3760 
3761   cursor c_imp_src is
3762          select import_source_line_id from ams_imp_source_lines
3763          WHERE import_list_header_id = p_import_list_header_id
3764          AND load_status <> 'DUPLICATE';
3765 
3766   cursor c_file_type is
3767 	 select file_type from ams_imp_documents
3768 	 where import_list_header_id = p_import_list_header_id;
3769 
3770   cursor c_dup_recs is
3771 	 select COL68 from ams_imp_source_lines
3772 	 where load_status = 'DUPLICATE'
3773            AND import_list_header_id = p_import_list_header_id;
3774 
3775 
3776 begin
3777   /* mayjain bug 5235979 */
3778   open c_rule_type ;
3779   fetch c_rule_type into l_rule_type;
3780   close c_rule_type;
3781 
3782   AMS_Utility_PVT.Create_Log (
3783            x_return_status   => l_return_status,
3784            p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3785            p_log_used_by_id  => p_import_list_header_id,
3786            p_msg_data        => 'Dedupe Check Rule Type '||l_rule_type,
3787            p_msg_type        => 'DEBUG');
3788   commit;
3789 
3790   open c_ruleid (l_rule_type);
3791   fetch c_ruleid into i_rule_id;
3792   close c_ruleid;
3793 
3794   AMS_Utility_PVT.Create_Log (
3795            x_return_status   => l_return_status,
3796            p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3797            p_log_used_by_id  => p_import_list_header_id,
3798            p_msg_data        => 'Dedupe Check Rule Id '||i_rule_id,
3799            p_msg_type        => 'DEBUG');
3800   commit;
3801   /* mayjain bug 5235979 */
3802 
3803   open c_table_name;
3804   fetch c_table_name into i_table_name;
3805   close c_table_name;
3806 
3807   open c_word;
3808   fetch c_word into l_word_replace, l_b2b_flag;
3809   close c_word;
3810 
3811   open c_file_type;
3812   fetch c_file_type into i_file_type;
3813   close c_file_type;
3814 
3815   i_string := 'update '||i_table_name||' set dedupe_key = ';
3816 
3817  if l_word_replace = 'N' then
3818   open c_rule_field;
3819   LOOP
3820     fetch c_rule_field into i_column, i_word_rep_type;
3821     exit when c_rule_field%notfound;
3822     if i = 0 then
3823         i_string := i_string||i_column;
3824       else
3825         i_string := i_string||'||'||'''.'''||'||'||i_column;
3826     end if;
3827     i := 1;
3828   END LOOP;
3829   close c_rule_field;
3830   i_string := i_string||'' ;
3831   i_string := i_string||' where import_list_header_id = :1';
3832 
3833    EXECUTE IMMEDIATE i_string USING IN p_import_list_header_id;
3834  end if ; -- l_word_replace = 'N;
3835 
3836 
3837  if l_word_replace = 'Y' then
3838   open c_imp_src;
3839   LOOP
3840   fetch c_imp_src into i_imp_src_line_id;
3841     exit when c_imp_src%notfound;
3842   i_string := 'update '||i_table_name||' set dedupe_key = ';
3843   i := 0;
3844   open c_rule_field;
3845   LOOP
3846     fetch c_rule_field into i_column, i_word_rep_type;
3847     exit when c_rule_field%notfound;
3848     i_org_value := null;
3849     i_rep_value := null;
3850     i_replace_value := null;
3851      i_str := 'select '||i_column||' from '||i_table_name;
3852      i_str := i_str||' where import_source_line_id = :i_imp_src_line_id ';
3853 
3854     EXECUTE IMMEDIATE i_str INTO i_org_value using i_imp_src_line_id;
3855 
3856     i_rep_value := AMS_ListDedupe_PVT.Replace_Word(upper(i_org_value),i_word_rep_type);
3857     if i_rep_value is not null then
3858       i_replace_value := '''';
3859       i_replace_value := i_replace_value||i_rep_value;
3860       i_replace_value := i_replace_value||'''';
3861       i_column := i_replace_value;
3862     end if;
3863     if i = 0 then
3864         i_string := i_string||i_column;
3865       else
3866         i_string := i_string||'||'||'''.'''||'||'||i_column;
3867     end if;
3868     i := 1;
3869   END LOOP;
3870   close c_rule_field;
3871   i_string := i_string||'' ;
3872   i_string := i_string||' where import_list_header_id = :p_import_list_header_id ';
3873   i_string := i_string||' and    import_source_line_id = :i_imp_src_line_id ';
3874 
3875     EXECUTE IMMEDIATE i_string USING p_import_list_header_id, i_imp_src_line_id;
3876    i_string    := null;
3877   END LOOP;
3878   close c_imp_src;
3879  end if ; -- l_word_replace = 'y  ;
3880 
3881 
3882   UPDATE ams_imp_source_lines a SET a.duplicate_flag = 'Y' , load_status = 'DUPLICATE'
3883   WHERE a.import_list_header_id = p_import_list_header_id
3884     AND a.ROWID > (SELECT MIN(b.ROWID) FROM ams_imp_source_lines b
3885                       WHERE b.import_list_header_id = a.import_list_header_id
3886   		        AND b.dedupe_key = a.dedupe_key
3887 		        AND b.import_list_header_id = p_import_list_header_id
3888                    );
3889   exception
3890      when others then
3891        AMS_Utility_PVT.Create_Log (
3892          x_return_status   => l_return_status,
3893          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3894          p_log_used_by_id  => p_import_list_header_id,
3895          p_msg_data        => sqlerrm ,
3896          p_msg_type        => 'DEBUG'
3897         );
3898         raise;
3899 
3900 end dedup_check;
3901 
3902 PROCEDURE capture_lead_error(
3903    p_import_list_header_id  IN    NUMBER
3904                             ) IS
3905 
3906 i_lead_error      VARCHAR2(2000);
3907 l_ret_status      varchar(1);
3908 
3909 cursor c_error is
3910  	SELECT error.error_text
3911 	FROM as_lead_import_errors error,
3912      	     as_import_interface inter
3913 	WHERE error.batch_id = inter.batch_id
3914   	AND inter.IMP_LIST_HEADER_NUMBER = p_import_list_header_id;
3915 
3916 BEGIN
3917 
3918  OPEN c_error;
3919  LOOP
3920     FETCH c_error into i_lead_error;
3921     exit when c_error%notfound;
3922     AMS_Utility_PVT.Create_Log (
3923        x_return_status   => l_ret_status,
3924        p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3925        p_log_used_by_id  => p_import_list_header_id,
3926        p_msg_data        => 'Lead Error- '||i_lead_error,
3927        p_msg_type        => 'DEBUG'
3928     );
3929  END LOOP;
3930  CLOSE c_error;
3931  exception
3932      when others then
3933        AMS_Utility_PVT.Create_Log (
3934          x_return_status   => l_ret_status,
3935          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
3936          p_log_used_by_id  => p_import_list_header_id,
3937          p_msg_data        => sqlerrm ,
3938          p_msg_type        => 'DEBUG'
3939         );
3940         raise;
3941 END capture_lead_error;
3942 --
3943 
3944 PROCEDURE execute_lead_import (
3945           --                  Errbuf          OUT NOCOPY     VARCHAR2,
3946           --                  Retcode         OUT NOCOPY     VARCHAR2,
3947                             p_import_list_header_id NUMBER
3948                             ) IS
3949 
3950    l_phase              VARCHAR2(30);
3951    l_appli              VARCHAR2(30);
3952    l_prog               VARCHAR2(30);
3953    l_status             VARCHAR2(30);
3954    l_dev_phase          VARCHAR2(30);
3955    l_dev_status         VARCHAR2(30);
3956    l_message            VARCHAR2(240);
3957    l_rstatus            BOOLEAN;
3958    l_wait_status        BOOLEAN;
3959 
3960    l_source_system      VARCHAR2(100);
3961    l_lead_status        VARCHAR2(30);
3962    i_processed_records  NUMBER;
3963    i_failed_records     NUMBER;
3964    l_request_id         NUMBER;
3965    l_conc_prog_name     VARCHAR2(60);
3966 
3967    l_ret_status      varchar(1);
3968 
3969    l_import_type        VARCHAR2(30);
3970    l_batch_id           NUMBER;
3971    l_lookup_code        VARCHAR2(30);
3972    l_return_status      VARCHAR2(1);
3973    l_user_status_id     NUMBER;
3974    l_execute_mode	VARCHAR2(1);
3975    l_validate_file	VARCHAR2(1);
3976    x_return_status      VARCHAR2(1);
3977    l_error_exist        VARCHAR2(1);
3978    l_rec_in_ams		NUMBER;
3979    l_rec_failed_in_ams	NUMBER;
3980    l_rec_in_as		NUMBER;
3981    l_rec_succ_in_as	NUMBER;
3982    l_rec_fail_in_as     NUMBER;
3983    l_loaded_records     NUMBER;
3984    l_failed_records     NUMBER;
3985    l_rec_dup_in_as      NUMBER;
3986  L_MESG_TEXT          varchar2(2000);
3987 
3988   cursor c_lead_status is
3989    SELECT distinct load_status FROM as_import_interface
3990    WHERE load_status = 'ERROR' AND batch_id = l_batch_id;
3991 
3992    cursor c_lead_status_sucess is
3993    SELECT distinct load_status FROM as_import_interface
3994    WHERE load_status = 'SUCCESS' AND batch_id = l_batch_id;
3995 
3996    cursor c_event_status is
3997    select nvl(PROCESSED_ROWS,0), nvl(NUMBER_OF_FAILED_RECORDS,0)
3998    from ams_imp_list_headers_all
3999    where import_list_header_id = p_import_list_header_id;
4000 
4001   cursor c_conc_name is
4002    SELECT concurrent_program FROM ams_imp_list_import_types
4003    where  import_type = 'LEAD';
4004 
4005   cursor c_lead_process is
4006       SELECT batch_id, VALIDATE_FILE, EXECUTE_MODE FROM ams_imp_list_headers_all
4007       WHERE import_list_header_id =  p_import_list_header_id ;
4008 
4009   cursor c_lead_source_system is
4010   select source_system from ams_lead_mapping_v
4011   where import_list_header_id =  p_import_list_header_id
4012     and load_status in ('ACTIVE','RELOAD')
4013     and source_system is not NULL
4014     and rownum < 2;
4015 
4016 /*
4017   cursor c_error_exist is
4018    select 'Y' from ams_imp_source_lines -- ams_list_import_errors
4019    where import_list_header_id = p_import_list_header_id
4020      and load_status = 'ERROR'
4021      -- and error_type = 'E'
4022      and rownum < 2;
4023 */
4024  cursor c_error_exist is
4025    select 'Y' from ams_list_import_errors
4026    where import_list_header_id = p_import_list_header_id
4027      and error_type = 'E'
4028      and col1 <> 'This is a duplicate lead.'
4029      and rownum < 2;
4030 
4031   cursor c_rec_in_ams is
4032   select count(*) from ams_imp_source_lines
4033   where import_list_header_id = p_import_list_header_id
4034     and load_status in ('ACTIVE','RELOAD');
4035 
4036   cursor c_rec_failed_in_ams is
4037   select count(*) from ams_imp_source_lines lines
4038   where lines.import_list_header_id = p_import_list_header_id
4039     and lines.load_status = G_STATUS_ERROR;
4040 
4041 /*
4042   cursor c_rec_failed_in_ams is
4043   select count(*) from ams_imp_source_lines lines,
4044                        ams_list_import_errors errors
4045   where lines.import_list_header_id = p_import_list_header_id
4046     and lines.load_status = 'ERROR'
4047     and lines.import_list_header_id = errors.import_list_header_id
4048     and lines.IMPORT_SOURCE_LINE_ID = errors.IMPORT_SOURCE_LINE_ID
4049     and errors.batch_id = l_batch_id
4050     and errors.error_type = 'E';
4051 */
4052 
4053   cursor c_rec_uploaded_in_as is
4054   select count(*) from as_import_interface
4055   where batch_id = l_batch_id;
4056 
4057   cursor c_rec_pro_succ_in_as is
4058   select count(*) from as_import_interface
4059   where batch_id = l_batch_id
4060     and load_status = 'SUCCESS';
4061 
4062  cursor c_rec_pro_fail_in_as is
4063   select count(*) from as_import_interface
4064   where batch_id = l_batch_id
4065     and load_status in ('ERROR','T-ERROR','UNEXP_ERROR');
4066 
4067 
4068  cursor c_loaded_records is
4069    select count(*) from ams_imp_source_lines
4070    where import_list_header_id = p_import_list_header_id
4071      and load_status = G_STATUS_SUCCESS;
4072 
4073  cursor c_failed_records is
4074    select count(*) from ams_imp_source_lines
4075    where import_list_header_id = p_import_list_header_id
4076    and load_status = G_STATUS_ERROR;
4077 
4078   cursor c_rec_pro_dup_in_as is
4079   select count(*) from as_import_interface
4080   where batch_id = l_batch_id
4081     and load_status = 'DUPLICATE';
4082 
4083 
4084 BEGIN
4085 
4086       AMS_Utility_PVT.Create_Log (
4087          x_return_status   => l_return_status,
4088          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4089          p_log_used_by_id  => p_import_list_header_id,
4090          p_msg_data        => 'Starting import for LEAD.',
4091          p_msg_type        => 'DEBUG'
4092        );
4093 
4094      open  c_conc_name;
4095      fetch c_conc_name into l_conc_prog_name;
4096      close c_conc_name;
4097 
4098    open c_rec_in_ams;
4099    fetch c_rec_in_ams into l_rec_in_ams;
4100    close c_rec_in_ams;
4101 
4102 /*
4103       SELECT batch_id into l_batch_id FROM as_import_interface
4104       WHERE IMP_LIST_HEADER_NUMBER =  p_import_list_header_id AND ROWNUM < 2;
4105        as_import_sl_pvt.main(l_msg_buf,
4106                              l_msg_code,
4107                              'NEW', -- 'MARKETING',
4108                               sysdate,
4109                               l_batch_id,
4110                               'N'
4111                              );
4112        capture_lead_error(p_import_list_header_id);
4113 */
4114 	open c_lead_process;
4115         fetch c_lead_process into l_batch_id,l_validate_file, l_execute_mode;
4116 	close c_lead_process;
4117 
4118 	-- Call the Validate Process
4119 	if l_validate_file = 'Y' then
4120 	     AMS_Utility_PVT.Create_Log (
4121        		  x_return_status   => l_return_status,
4122         	  p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4123         	  p_log_used_by_id  => p_import_list_header_id,
4124          	  p_msg_data        => 'Starting Validation for LEAD data.',
4125          	  p_msg_type        => 'DEBUG'
4126        		);
4127 
4128 	-- Delete all the errors from the errors table which are reloaded.
4129                  delete from ams_list_import_errors where import_list_header_id
4130                 = p_import_list_header_id and import_source_line_id = 0;
4131 		delete from ams_list_import_errors where import_list_header_id
4132 		= p_import_list_header_id and import_source_line_id in
4133 		(select import_source_line_id from ams_imp_source_lines where
4134 		import_list_header_id = p_import_list_header_id and load_status = G_STATUS_RELOAD);
4135 
4136                 x_return_status := null;
4137 		execute_lead_data_validation ( p_import_list_header_id,x_return_status );
4138              if x_return_status <> 'S' then
4139               AMS_Utility_PVT.Create_Log (
4140                   x_return_status   => l_return_status,
4141                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4142                   p_log_used_by_id  => p_import_list_header_id,
4143                   p_msg_data        => 'Lead import terminated because of error in Data validation process.',
4144                   p_msg_type        => 'DEBUG'
4145                 );
4146 
4147                 l_lookup_code := 'ERROR';
4148                 l_user_status_id := null;
4149                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4150                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4151                 system_status_code = 'ERROR' and default_flag = 'Y';
4152 
4153                 UPDATE ams_imp_list_headers_all
4154                 set status_code       =  l_lookup_code,
4155                 user_status_id    =  l_user_status_id,
4156                 status_date       =  sysdate
4157                 where import_list_header_id = p_import_list_header_id;
4158                 return;
4159              end if;
4160 
4161 	     AMS_Utility_PVT.Create_Log (
4162        		  x_return_status   => l_return_status,
4163         	  p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4164         	  p_log_used_by_id  => p_import_list_header_id,
4165          	  p_msg_data        => 'End Validation for LEAD data.',
4166          	  p_msg_type        => 'DEBUG'
4167        		);
4168 	end if;
4169    	open c_rec_failed_in_ams;
4170    	fetch c_rec_failed_in_ams into l_rec_failed_in_ams;
4171    	close c_rec_failed_in_ams;
4172 
4173 	-- Uploads the Lead's interface table.
4174 	     AMS_Utility_PVT.Create_Log (
4175        		  x_return_status   => l_return_status,
4176         	  p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4177         	  p_log_used_by_id  => p_import_list_header_id,
4178          	  p_msg_data        => 'Starting LEAD data upload.',
4179          	  p_msg_type        => 'DEBUG'
4180        		);
4181 	     AMS_ImportClient_PVT.Load_Lead_Data_To_Interface(p_import_list_header_id,x_return_status);
4182 	     AMS_Utility_PVT.Create_Log (
4183        		  x_return_status   => l_return_status,
4184         	  p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4185         	  p_log_used_by_id  => p_import_list_header_id,
4186          	  p_msg_data        => 'End LEAD data upload.',
4187          	  p_msg_type        => 'DEBUG'
4188        		);
4189 
4190               if x_return_status <> 'S' then
4191               AMS_Utility_PVT.Create_Log (
4192                   x_return_status   => l_return_status,
4193                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4194                   p_log_used_by_id  => p_import_list_header_id,
4195                   p_msg_data        => 'Lead import terminated because of Data upload error.',
4196                   p_msg_type        => 'DEBUG'
4197                 );
4198 
4199 	        l_lookup_code := 'ERROR';
4200          	l_user_status_id := null;
4201          	SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4202          	WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4203          	system_status_code = 'ERROR' and default_flag = 'Y';
4204 
4205          	UPDATE ams_imp_list_headers_all
4206          	set status_code       =  l_lookup_code,
4207             	user_status_id    =  l_user_status_id,
4208             	status_date       =  sysdate
4209          	where import_list_header_id = p_import_list_header_id;
4210 		return;
4211 	     end if;
4212 
4213 	     open c_lead_source_system;
4214      	     fetch c_lead_source_system into l_source_system;
4215       	     close c_lead_source_system;
4216      	     if l_source_system is NULL then
4217          	AMS_Utility_PVT.Create_Log (
4218          	x_return_status   => l_return_status,
4219          	p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4220          	p_log_used_by_id  => p_import_list_header_id,
4221          	p_msg_data        => 'Aborting import process because SOURCE_SYSTEM is NULL.',
4222          	p_msg_type        => 'DEBUG'
4223        		);
4224                 open c_rec_failed_in_ams;
4225                 fetch c_rec_failed_in_ams into l_rec_failed_in_ams;
4226                 close c_rec_failed_in_ams;
4227 
4228          	l_lookup_code := 'ERROR';
4229          	l_user_status_id := null;
4230          	SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4231          	WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4232          	system_status_code = 'ERROR' and default_flag = 'Y';
4233 
4234          	UPDATE ams_imp_list_headers_all
4235          	set status_code       =  l_lookup_code,
4236             	user_status_id    =  l_user_status_id,
4237             	status_date       =  sysdate,
4238                 number_of_failed_records = l_rec_failed_in_ams
4239          	where import_list_header_id = p_import_list_header_id;
4240 
4241        		return;
4242      	     end if;
4243 
4244       l_request_id := FND_REQUEST.SUBMIT_REQUEST (
4245                       application       => 'AS',             -- 'AST',
4246                       program           => l_conc_prog_name, -- ' ASXSLIMP' 'AST_LEAD_IMPORT',
4247                       argument1         => l_source_system, -- 'NEW',    -- 'ORACLE.COM',
4248                       argument2         => NULL,
4249                       argument3         => l_batch_id,       --  NULL,
4250                       argument4         => 'N'
4251                    );
4252 
4253              AMS_Utility_PVT.Create_Log (
4254               x_return_status   => l_return_status,
4255               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4256               p_log_used_by_id  => p_import_list_header_id,
4257              p_msg_data        => 'Starting LEAD program (ASXSLIMP) -- concurrent program_id is '||to_char(l_request_id),
4258               p_msg_type        => 'DEBUG'
4259               );
4260 
4261       IF l_request_id = 0 THEN
4262                           l_mesg_text := fnd_message.get;
4263                AMS_Utility_PVT.Create_Log (
4264                 x_return_status   => l_return_status,
4265                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4266                 p_log_used_by_id  => p_import_list_header_id,
4267                 p_msg_data        => l_mesg_text,
4268                 p_msg_type        => 'DEBUG' );
4269 
4270                 l_user_status_id := null;
4271                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4272                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4273                 system_status_code = 'ERROR'  and default_flag = 'Y';
4274                 UPDATE ams_imp_list_headers_all
4275                 set status_code       =  l_lookup_code,
4276                 user_status_id    =  l_user_status_id,
4277                 status_date       =  sysdate
4278                 where import_list_header_id = p_import_list_header_id;
4279                 commit;
4280           RAISE FND_API.g_exc_unexpected_error;
4281      end if;
4282 
4283      commit;
4284      -- The concurrent program MUST finish
4285      -- before updating the status_code
4286 
4287       l_wait_status := FND_CONCURRENT.WAIT_FOR_REQUEST (
4288                         request_id        => l_request_id,
4289                         phase             => l_phase,
4290                         status            => l_status,
4291                         dev_phase         => l_dev_phase,
4292                         dev_status        => l_dev_status,
4293                         message           => l_message
4294                         );
4295 
4296      ---------------------------------------------
4297      -- WAIT_STATUS should only come back as
4298      -- TRUE.  It only comes back as FALSE if
4299      -- the conc request was not successfully
4300      -- submitted.
4301      ---------------------------------------------
4302      IF NOT l_wait_status THEN
4303         RAISE FND_API.g_exc_unexpected_error;
4304      END IF;
4305 
4306 
4307    l_rstatus := FND_CONCURRENT.get_REQUEST_status (
4308                         request_id        => l_request_id,
4309                         APPL_SHORTNAME    => l_appli,
4310                         program           => l_prog,
4311                         phase             => l_phase,
4312                         status            => l_status,
4313                         dev_phase         => l_dev_phase,
4314                         dev_status        => l_dev_status,
4315                         message           => l_message
4316                         );
4317      if l_dev_phase = 'COMPLETE' then
4318 /*
4319       if l_dev_status = 'NORMAL' then
4320        l_lookup_code    := 'COMPLETED';
4321        l_user_status_id := null;
4322        SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4323        WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4324        system_status_code = 'COMPLETED' and default_flag = 'Y';
4325       end if;
4326 */
4327       if l_dev_status = 'ERROR' then
4328        l_lookup_code    := 'ERROR';
4329        l_user_status_id := null;
4330        SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4331        WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4332        system_status_code = 'ERROR' and default_flag = 'Y';
4333        UPDATE ams_imp_list_headers_all
4334         set status_code       = l_lookup_code,
4335             user_status_id    = l_user_status_id,
4336             status_date       =  sysdate
4337        where import_list_header_id = p_import_list_header_id;
4338            AMS_Utility_PVT.Create_Log (
4339               x_return_status   => l_return_status,
4340               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4341               p_log_used_by_id  => p_import_list_header_id,
4342               p_msg_data        => 'LEAD program completed with errors Please check the log file.',
4343               p_msg_type        => 'DEBUG'
4344               );
4345       end if;
4346 
4347       -- Post process for Lead import.
4348              AMS_Utility_PVT.Create_Log (
4349                   x_return_status   => l_return_status,
4350                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4351                   p_log_used_by_id  => p_import_list_header_id,
4352                   p_msg_data        => 'Starting LEAD post process.',
4353                   p_msg_type        => 'DEBUG'
4354                 );
4355              AMS_ImportClient_PVT.Mark_Insert_Lead_Errors(p_import_list_header_id,x_return_status);
4356              AMS_Utility_PVT.Create_Log (
4357                   x_return_status   => l_return_status,
4358                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4359                   p_log_used_by_id  => p_import_list_header_id,
4360                   p_msg_data        => 'End LEAD post process.',
4361                   p_msg_type        => 'DEBUG'
4362                 );
4363      end if;
4364 
4365        open c_lead_status;
4366        fetch c_lead_status into l_lead_status;
4367        close c_lead_status;
4368        if l_lead_status = 'ERROR' then
4369 /*
4370          l_lookup_code := 'ERROR';
4371          l_user_status_id := null;
4372          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
4373          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
4374          system_status_code = 'ERROR' and default_flag = 'Y';
4375 */
4376           AMS_Utility_PVT.Create_Log (
4377               x_return_status   => l_return_status,
4378               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4379               p_log_used_by_id  => p_import_list_header_id,
4380               p_msg_data        => 'Some of the leads in the batch has errors.',
4381               p_msg_type        => 'DEBUG'
4382               );
4383 /*
4384          UPDATE ams_imp_list_headers_all
4385          set status_code       =  l_lookup_code,
4386             user_status_id    =  l_user_status_id,
4387             status_date       =  sysdate
4388          where import_list_header_id = p_import_list_header_id;
4389 */
4390        end if;
4391 
4392          --  capture_lead_error(p_import_list_header_id);
4393 
4394       AMS_Utility_PVT.Create_Log (
4395          x_return_status   => l_return_status,
4396          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4397          p_log_used_by_id  => p_import_list_header_id,
4398          p_msg_data        => 'End client load for LEAD.',
4399          p_msg_type        => 'DEBUG'
4400        );
4401       AMS_Utility_PVT.Create_Log (
4402          x_return_status   => l_return_status,
4403          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4404          p_log_used_by_id  => p_import_list_header_id,
4405          p_msg_data        => 'Processing is done for Batch : '||to_char(l_batch_id),
4406          p_msg_type        => 'DEBUG'
4407        );
4408 
4409       AMS_Utility_PVT.Create_Log (
4410          x_return_status   => l_return_status,
4411          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4412          p_log_used_by_id  => p_import_list_header_id,
4413          p_msg_data        => 'Records available for process : '||to_char(l_rec_in_ams),
4414          p_msg_type        => 'DEBUG'
4415        );
4416 
4417       AMS_Utility_PVT.Create_Log (
4418          x_return_status   => l_return_status,
4419          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4420          p_log_used_by_id  => p_import_list_header_id,
4421          p_msg_data        => 'Records failed data validation : '||to_char(l_rec_failed_in_ams),
4422          p_msg_type        => 'DEBUG'
4423        );
4424 
4425    open c_rec_uploaded_in_as;
4426    fetch c_rec_uploaded_in_as into l_rec_in_as;
4427    close c_rec_uploaded_in_as;
4428      AMS_Utility_PVT.Create_Log (
4429          x_return_status   => l_return_status,
4430          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4431          p_log_used_by_id  => p_import_list_header_id,
4432          p_msg_data        => 'Records uploaded/available for Lead import process : '||to_char(l_rec_in_as),
4433          p_msg_type        => 'DEBUG'
4434        );
4435 
4436    open c_rec_pro_fail_in_as;
4437    fetch c_rec_pro_fail_in_as into l_rec_fail_in_as;
4438    close c_rec_pro_fail_in_as;
4439      AMS_Utility_PVT.Create_Log (
4440          x_return_status   => l_return_status,
4441          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4442          p_log_used_by_id  => p_import_list_header_id,
4443          p_msg_data        => 'Records failed during Lead import process : '||to_char(l_rec_fail_in_as),
4444          p_msg_type        => 'DEBUG'
4445        );
4446 
4447 
4448    open c_rec_pro_succ_in_as;
4449    fetch c_rec_pro_succ_in_as into l_rec_succ_in_as;
4450    close c_rec_pro_succ_in_as;
4451      AMS_Utility_PVT.Create_Log (
4452          x_return_status   => l_return_status,
4453          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4454          p_log_used_by_id  => p_import_list_header_id,
4455          p_msg_data        => 'Records successfully processed Lead import : '||to_char(l_rec_succ_in_as),
4456          p_msg_type        => 'DEBUG'
4457        );
4458    l_rec_dup_in_as := null;
4459    open c_rec_pro_dup_in_as;
4460    fetch c_rec_pro_dup_in_as into l_rec_dup_in_as;
4461    close c_rec_pro_dup_in_as;
4462      if nvl(l_rec_dup_in_as,0) > 0 then
4463      AMS_Utility_PVT.Create_Log (
4464          x_return_status   => l_return_status,
4465          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4466          p_log_used_by_id  => p_import_list_header_id,
4467          p_msg_data        => 'Duplicate Leads in Lead import process : '||to_char(l_rec_dup_in_as),
4468          p_msg_type        => 'DEBUG'
4469        );
4470       end if;
4471 
4472         -- Delete all the errors from the errors table which are sucessful.
4473                 delete from ams_list_import_errors where import_list_header_id
4474                 = p_import_list_header_id and import_source_line_id in
4475                 (select import_source_line_id from ams_imp_source_lines where
4476                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_SUCCESS);
4477 
4478     -- STATUS CODE PROCESS
4479 
4480      process_status_code (p_import_list_header_id);
4481 
4482 
4483  exception
4484      when others then
4485        AMS_Utility_PVT.Create_Log (
4486          x_return_status   => l_ret_status,
4487          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
4488          p_log_used_by_id  => p_import_list_header_id,
4489          p_msg_data        => sqlerrm ,
4490          p_msg_type        => 'DEBUG'
4491         );
4492         raise;
4493 
4494 END execute_lead_import;
4495 
4496 
4497 --
4498 --
4499 -- This progam updates the party for the rented list
4500 --
4501 PROCEDURE update_rented_list_party (
4502        p_party_id                  IN      NUMBER,
4503        p_return_status             OUT NOCOPY     VARCHAR2,
4504        p_msg_count                 OUT NOCOPY     NUMBER,
4505        p_msg_data                  OUT NOCOPY     VARCHAR2
4506 
4507                      ) IS
4508 
4509 x_b2b                           varchar(30);
4510 x_rented_list_flag              varchar(1);
4511 x_email_address                 varchar2(2000);
4512 x_phone_country_code            VARCHAR2(10);
4513 x_phone_area_code               VARCHAR2(10);
4514 x_phone_number                  VARCHAR2(40);
4515 x_phone_extention               VARCHAR2(20);
4516 x_date1                         DATE := sysdate;
4517 l_last_update_date              DATE;
4518 l_last_update_date1             DATE;
4519 x_profile_id                    NUMBER;
4520 x_return_status                 VARCHAR2(100);
4521 x_msg_count                     NUMBER;
4522 x_msg_data                      VARCHAR2(2000);
4523 x_tmp_var                       VARCHAR2(2000);
4524 x_tmp_var1                      VARCHAR2(2000);
4525 X_PARTY_REL_PARTY_ID            NUMBER;
4526 x_relationship_id               NUMBER;
4527 x_org_contact_id                NUMBER;
4528 x_date_one                      DATE := sysdate;
4529 x_date_two                      DATE := sysdate;
4530 x_date_three                    DATE := sysdate;
4531 x_org_party_id                  NUMBER;
4532 x_person_id                     NUMBER;
4533 x_gen_party_site_number         VARCHAR2(1);
4534 x_hz_dup_check                  VARCHAR2(60);
4535 x_import_list_header_id         NUMBER;
4536 x_location_id                   number;
4537 l_lp_psite_id                   NUMBER;
4538 x_Party_site_id                 number;
4539 x_party_site_number             VARCHAR2(30);
4540 l_phone_exists                  VARCHAR2(1);
4541 l_email_exists                  VARCHAR2(1);
4542 x_contact_point_id              number;
4543 x_per_party_id                  number;
4544 l_object_version		number;
4545 l_object_version2		number;
4546 l_object_version3		number;
4547 -- Cursor for B2B party type
4548 
4549 cursor b2b is
4550  SELECT
4551  IMPORT_SOURCE_LINE_ID,
4552  PARTY_NAME,
4553  FISCAL_YEAREND_MONTH,
4554  DUNS_NUMBER,
4555  EMPLOYEES_TOTAL,
4556  LINE_OF_BUSINESS,
4557  YEAR_ESTABLISHED,
4558  TAX_REFERENCE,
4559  CEO_NAME,
4560  PERSON_FIRST_NAME,
4561  PERSON_MIDDLE_NAME,
4562  PERSON_LAST_NAME,
4563  PERSON_NAME_SUFFIX,
4564  PERSON_name_prefix,
4565  -- BEST_TIME_CONTACT_BEGIN,
4566  -- BEST_TIME_CONTACT_END,
4567  COUNTRY,
4568  ADDRESS1,
4569  ADDRESS2,
4570  CITY,
4571  COUNTY,
4572  STATE,
4573  PROVINCE,
4574  POSTAL_CODE,
4575  -- TIME_ZONE,
4576  EMAIL_ADDRESS,
4577  PHONE_COUNTRY_CODE,
4578  PHONE_AREA_CODE,
4579  PHONE_NUMBER,
4580  PHONE_EXTENTION,
4581  DEPARTMENT,
4582  JOB_TITLE,
4583  DECISION_MAKER_FLAG,
4584  SIC_CODE,
4585  SIC_CODE_TYPE,
4586  -- TOTAL_NUM_OF_ORDERS,
4587  -- TOTAL_ORDERED_AMOUNT,
4588  -- LAST_ORDERED_DATE   ,
4589  ANALYSIS_FY         ,
4590  CURR_FY_POTENTIAL_REVENUE,
4591  NEXT_FY_POTENTIAL_REVENUE,
4592  GSA_INDICATOR_FLAG       ,
4593  MISSION_STATEMENT        ,
4594  ORGANIZATION_NAME_PHONETIC,
4595  CATEGORY_CODE              ,
4596  JGZZ_FISCAL_CODE           ,
4597  -- TAX_NAME                   ,
4598  ADDRESS3                   ,
4599  ADDRESS4                   ,
4600  ADDRESS_LINES_PHONETIC     ,
4601  -- APARTMENT_FLAG             ,
4602  -- bug 4641591: columns obsolete
4603  -- PO_BOX_NUMBER              ,
4604  --  HOUSE_NUMBER               ,
4605  --  STREET_SUFFIX              ,
4606  -- SECONDARY_SUFFIX_ELENENT   ,
4607  --  STREET                     ,
4608  -- RURAL_ROUTE_TYPE           ,
4609  -- RURAL_ROUTE_NUMBER         ,
4610  --  STREET_NUMBER              ,
4611  --  FLOOR                      ,
4612  --  SUITE                      ,
4613  POSTAL_PLUS4_CODE          ,
4614  -- OVERSEAS_ADDRESS_FLAG   ,
4615  identifying_address_flag   ,
4616  to_date(ADDRESS_EFFECTIVE_DATE,'MM/DD/YYYY'),
4617 to_date(ADDRESS_EXPIRATION_DATE,'MM/DD/YYYY'),
4618 --ANNUAL_REVENUE,
4619 --ANNUAL_REVENUE_CURRENCY,
4620 BRANCH_FLAG,
4621 BUSINESS_LINE,
4622 BUSINESS_SCOPE,
4623 CHIEF_EXECUTIVE_TITLE,
4624 CONGRESSIONAL_DISTRICT_CODE,
4625 CONTROL_YEAR,
4626 CORPORATION_CLASS,
4627 CREDIT_SCORE,
4628 CREDIT_SCORE_COMMENTARY,
4629 --CUSTOMER_CATEGORY,
4630 DB_RATING,
4631 to_date(DATE_OF_BIRTH,'MM/DD/YYYY'),
4632 to_date(DATE_OF_DEATH,'MM/DD/YYYY'),
4633 DEBARMENTS_COUNT,
4634 to_date(DEBARTMENTS_DATE,'MM/DD/YYYY'),
4635 DECLARED_ETHNICITY,
4636 DEPARTMENT_INDICATOR,
4637 DESCRIPTION,
4638 DISADVANTAGED_INDICATOR,
4639 ENQUIRY_DUNS,
4640 EXPORT_INDICATOR,
4641 FAILURE_SCORE,
4642 FAILURE_SCORE_COMMENTARY,
4643 FAILURE_SCORE_NATL_PERCENTILE,
4644 FAILURE_SCORE_OVERRIDE_CODE,
4645 --FISCAL_CODE,
4646 GLOBAL_FAILURE_SCORE,
4647 HEADQUARTER_BRANCH_INDICATOR,
4648 HEAD_OF_HOUSEHOLD_FLAG,
4649 HOUSEHOLD_SIZE,
4650 IMPORT_INDICATOR,
4651 ORGANIZATION_KNOWN_AS,
4652 ORGANIZATION_KNOWN_AS2,
4653 ORGANIZATION_KNOWN_AS3,
4654 ORGANIZATION_KNOWN_AS4,
4655 ORGANIZATION_KNOWN_AS5,
4656 PERSON_KNOWN_AS,
4657 PERSON_KNOWN_AS2,
4658 PERSON_KNOWN_AS3,
4659 PERSON_KNOWN_AS4,
4660 PERSON_KNOWN_AS5,
4661 LABOR_SURPLUS_INDICATOR,
4662 LOCAL_ACTIVITY_CODE,
4663 LOCAL_ACTIVITY_CODE_TYPE,
4664 LOCATION_DIRECTIONS ,
4665 --LOCATION_STATUS,
4666 MARITAL_STATUS,
4667 to_date(MARITAL_STATUS_EFFECTIVE_DATE,'MM/DD/YYYY'),
4668 MINORITY_OWNED_INDICATOR,
4669 MINORITY_OWNED_TYPE,
4670 --ORGANIZATION_ALIAS,
4671 ORGANIZATION_TYPE,
4672 ORGANIZATION_URL,
4673 OUT_OF_BUSINESS_INDICATOR,
4674 PERSONAL_INCOME,
4675 PERSON_ACADEMIC_TITLE,
4676 PERSON_FIRST_NAME_PHONETIC,
4677 PERSON_LAST_NAME_PHONETIC,
4678 MIDDLE_NAME_PHONETIC,
4679 PERSON_NAME_PHONETIC,
4680 PERSON_PREVIOUS_TITLE_NAME,
4681 PLACE_OF_BIRTH,
4682 --PREFERRED_NAME,
4683 PRINCIPAL_NAME,
4684 PRINCIPAL_TITLE,
4685 PUBLIC_PRIVATE_OWNERSHIP_FLAG,
4686 RENT_OWNED_INDICATOR,
4687 --RENT_OWNER_INDICATOR,
4688 SECOND_TITLE,
4689 SHORT_DESCRIPTION,
4690 SMALL_BUSINESS_INDICATOR,
4691 TAX_ID,
4692 WOMAN_OWNED_INDICATOR,
4693 ORGANIZATION_ATTRIBUTE1,
4694 ORGANIZATION_ATTRIBUTE2,
4695 ORGANIZATION_ATTRIBUTE3,
4696 ORGANIZATION_ATTRIBUTE4,
4697 ORGANIZATION_ATTRIBUTE5,
4698 ORGANIZATION_ATTRIBUTE6,
4699 ORGANIZATION_ATTRIBUTE7,
4700 ORGANIZATION_ATTRIBUTE8,
4701 ORGANIZATION_ATTRIBUTE9,
4702 ORGANIZATION_ATTRIBUTE10,
4703 ORGANIZATION_ATTRIBUTE11,
4704 ORGANIZATION_ATTRIBUTE12,
4705 ORGANIZATION_ATTRIBUTE13,
4706 ORGANIZATION_ATTRIBUTE14,
4707 ORGANIZATION_ATTRIBUTE15,
4708 PERSON_ATTRIBUTE1,
4709 PERSON_ATTRIBUTE2,
4710 PERSON_ATTRIBUTE3,
4711 PERSON_ATTRIBUTE4,
4712 PERSON_ATTRIBUTE5,
4713 PERSON_ATTRIBUTE6,
4714 PERSON_ATTRIBUTE7,
4715 PERSON_ATTRIBUTE8,
4716 PERSON_ATTRIBUTE9,
4717 PERSON_ATTRIBUTE10,
4718 PERSON_ATTRIBUTE11,
4719 PERSON_ATTRIBUTE12,
4720 PERSON_ATTRIBUTE13,
4721 PERSON_ATTRIBUTE14,
4722 PERSON_ATTRIBUTE15,
4723 ORG_CONTACT_ATTRIBUTE1,
4724 ORG_CONTACT_ATTRIBUTE2,
4725 ORG_CONTACT_ATTRIBUTE3,
4726 ORG_CONTACT_ATTRIBUTE4,
4727 ORG_CONTACT_ATTRIBUTE5,
4728 ORG_CONTACT_ATTRIBUTE6,
4729 ORG_CONTACT_ATTRIBUTE7,
4730 ORG_CONTACT_ATTRIBUTE8,
4731 ORG_CONTACT_ATTRIBUTE9,
4732 ORG_CONTACT_ATTRIBUTE10,
4733 ORG_CONTACT_ATTRIBUTE11,
4734 ORG_CONTACT_ATTRIBUTE12,
4735 ORG_CONTACT_ATTRIBUTE13,
4736 ORG_CONTACT_ATTRIBUTE14,
4737 ORG_CONTACT_ATTRIBUTE15,
4738 ADDRESS_ATTRIBUTE1,
4739 ADDRESS_ATTRIBUTE2,
4740 ADDRESS_ATTRIBUTE3,
4741 ADDRESS_ATTRIBUTE4,
4742 ADDRESS_ATTRIBUTE5,
4743 ADDRESS_ATTRIBUTE6,
4744 ADDRESS_ATTRIBUTE7,
4745 ADDRESS_ATTRIBUTE8,
4746 ADDRESS_ATTRIBUTE9,
4747 ADDRESS_ATTRIBUTE10,
4748 ADDRESS_ATTRIBUTE11,
4749 ADDRESS_ATTRIBUTE12,
4750 ADDRESS_ATTRIBUTE13,
4751 ADDRESS_ATTRIBUTE14,
4752 ADDRESS_ATTRIBUTE15,
4753 FAX_COUNTRY_CODE,
4754 FAX_AREA_CODE,
4755 FAX_NUMBER,
4756 ORG_ATTRIBUTE_CATEGORY,
4757 PERSON_ATTRIBUTE_CATEGORY,
4758 ORG_CONTACT_ATTRIBUTE_CATEGORY,
4759 ADDRESS_ATTRIBUTE_CATEGORY ,
4760 PARTY_SITE_USE
4761 
4762  FROM AMS_HZ_B2B_MAPPING_V
4763  WHERE party_id =  p_party_id
4764  and   load_status = 'SUCCESS';
4765 
4766 -- Cursor B2C Party Type
4767 
4768 CURSOR B2C IS
4769  SELECT
4770  IMPORT_SOURCE_LINE_ID,
4771  PERSON_FIRST_NAME,
4772  PERSON_MIDDLE_NAME,
4773  PERSON_LAST_NAME,
4774  PERSON_NAME_SUFFIX,
4775  PERSON_name_prefix,
4776  -- BEST_TIME_CONTACT_BEGIN,
4777  -- BEST_TIME_CONTACT_END,
4778  COUNTRY,
4779  ADDRESS1,
4780  ADDRESS2,
4781  CITY,
4782  COUNTY,
4783  STATE,
4784  PROVINCE,
4785  POSTAL_CODE,
4786  -- TIME_ZONE,
4787  EMAIL_ADDRESS,
4788  PHONE_COUNTRY_CODE,
4789  PHONE_AREA_CODE,
4790  PHONE_NUMBER,
4791  PHONE_EXTENTION,
4792 --  PERSON_PRE_NAME_ADJUNCT,
4793  SALUTATION,
4794  ADDRESS3                   ,
4795  ADDRESS4                   ,
4796  ADDRESS_LINES_PHONETIC     ,
4797  -- APARTMENT_FLAG             ,
4798  -- bug 4641591: columns obsolete
4799  --  PO_BOX_NUMBER              ,
4800  --  HOUSE_NUMBER               ,
4801  --  STREET_SUFFIX              ,
4802  -- SECONDARY_SUFFIX_ELEMENT   ,
4803  --  STREET                     ,
4804  -- RURAL_ROUTE_TYPE           ,
4805  -- RURAL_ROUTE_NUMBER         ,
4806  --  STREET_NUMBER              ,
4807  --  FLOOR                      ,
4808  --  SUITE                      ,
4809  POSTAL_PLUS4_CODE          ,
4810  -- OVERSEAS_ADDRESS_FLAG   ,
4811  identifying_address_flag   ,
4812   PERSON_LAST_NAME_PHONETIC,
4813  PERSON_FIRST_NAME_PHONETIC ,
4814 --PREFERRED_NAME,
4815 URL,-- replace PREFERRED_NAME with URL
4816 SECOND_TITLE,
4817 to_date(DATE_OF_BIRTH,'MM/DD/YYYY'),
4818 PERSON_ACADEMIC_TITLE,
4819 PERSON_PREVIOUS_TITLE_NAME,
4820 PERSON_KNOWN_AS,
4821 PERSON_KNOWN_AS2,
4822 PERSON_KNOWN_AS3,
4823 PERSON_KNOWN_AS4,
4824 PERSON_KNOWN_AS5,
4825 PERSON_NAME_PHONETIC,
4826 MIDDLE_NAME_PHONETIC,
4827 FISCAL_CODE,
4828 PLACE_OF_BIRTH,
4829 to_date(DATE_OF_DEATH,'MM/DD/YYYY'),
4830 DECLARED_ETHNICITY,
4831 MARITAL_STATUS, PERSONAL_INCOME,
4832 to_date(MARITAL_STATUS_EFFECTIVE_DATE,'MM/DD/YYYY'),
4833 HEAD_OF_HOUSEHOLD_FLAG,
4834 HOUSEHOLD_SIZE, LOCATION_DIRECTIONS,
4835 ADDRESS_EFFECTIVE_DATE, ADDRESS_EXPIRATION_DATE,
4836 PERSON_ATTRIBUTE1, PERSON_ATTRIBUTE2,
4837 PERSON_ATTRIBUTE3, PERSON_ATTRIBUTE4,
4838 PERSON_ATTRIBUTE5, PERSON_ATTRIBUTE6,
4839 PERSON_ATTRIBUTE7, PERSON_ATTRIBUTE8,
4840 PERSON_ATTRIBUTE9, PERSON_ATTRIBUTE10,
4841 PERSON_ATTRIBUTE11, PERSON_ATTRIBUTE12,
4842 PERSON_ATTRIBUTE13, PERSON_ATTRIBUTE14,
4843 PERSON_ATTRIBUTE15, ADDRESS_ATTRIBUTE1,
4844 ADDRESS_ATTRIBUTE2, ADDRESS_ATTRIBUTE3,
4845 ADDRESS_ATTRIBUTE4, ADDRESS_ATTRIBUTE5,
4846 ADDRESS_ATTRIBUTE6, ADDRESS_ATTRIBUTE7,
4847 ADDRESS_ATTRIBUTE8, ADDRESS_ATTRIBUTE9,
4848 ADDRESS_ATTRIBUTE10, ADDRESS_ATTRIBUTE11,
4849 ADDRESS_ATTRIBUTE12, ADDRESS_ATTRIBUTE13,
4850 ADDRESS_ATTRIBUTE14, ADDRESS_ATTRIBUTE15,
4851 FAX_COUNTRY_CODE, FAX_AREA_CODE,
4852 FAX_NUMBER,
4853 PERSON_ATTRIBUTE_CATEGORY,
4854 ADDRESS_ATTRIBUTE_CATEGORY ,
4855 SHORT_DESCRIPTION,
4856 DESCRIPTION,
4857 PARTY_SITE_USE
4858  FROM AMS_HZ_B2C_MAPPING_V
4859  WHERE party_id =  p_party_id
4860  and   load_status = 'SUCCESS';
4861 
4862 
4863 cursor b2borb2c is
4864           select hd.import_type, hd.rented_list_flag, hd.import_list_header_id
4865           from ams_imp_list_headers_all hd, ams_imp_source_lines sr
4866           where hd.import_list_header_id = sr.import_list_header_id
4867             and sr.party_id =  p_party_id;
4868 
4869 cursor c_relationship is
4870           SELECT RELATIONSHIP_ID, OBJECT_VERSION_NUMBER FROM hz_relationships WHERE subject_type = 'PERSON'
4871           AND party_id = p_party_id;
4872 
4873 CURSOR LOCATION_EXISTS IS
4874           SELECT party_site_id FROM hz_party_sites
4875           WHERE party_id = x_org_party_id
4876             AND location_id = x_location_id;
4877 
4878 CURSOR CHECK_PSITE_EXISTS IS
4879 SELECT party_site_id FROM hz_party_sites
4880 WHERE party_id = x_party_rel_party_id
4881   AND location_id = x_location_id;
4882 
4883 CURSOR phone_exists (x_hz_party_id number) IS
4884 SELECT 'Y' FROM hz_contact_points
4885 WHERE contact_point_type          = 'PHONE'
4886   AND phone_line_type             = 'GEN'
4887   AND owner_table_name            = 'HZ_PARTIES'
4888   AND owner_table_id              = x_hz_party_id
4889   AND phone_number                = x_phone_number
4890   AND NVL(phone_country_code,'x') = NVL(x_phone_country_code,'x')
4891   AND NVL(phone_area_code,'x')    = NVL(x_phone_area_code,'x')
4892   AND NVL(phone_extension,'x')    = NVL(x_phone_extention,'x');
4893 
4894 
4895 CURSOR email_exists (x_hz_party_id number) IS
4896 SELECT 'Y' FROM hz_contact_points
4897 WHERE contact_point_type          = 'EMAIL'
4898   AND owner_table_name            = 'HZ_PARTIES'
4899   AND owner_table_id              = x_hz_party_id
4900   AND email_address               = x_email_address;
4901 
4902 CURSOR PER_LOCATION_EXISTS IS
4903 SELECT party_site_id FROM hz_party_sites
4904 WHERE party_id = x_per_party_id
4905   AND location_id = x_location_id;
4906 
4907  party_rec       hz_party_v2pub.party_rec_type;
4908  org_rec         hz_party_v2pub.organization_rec_type;
4909  person_rec      hz_party_v2pub.person_rec_type;
4910  location_rec    hz_location_v2pub.location_rec_type;
4911  psite_rec       hz_party_site_v2pub.party_site_rec_type;
4912  psiteuse_rec    hz_party_site_v2pub.party_site_use_rec_type;
4913  cpoint_rec      hz_contact_point_v2pub.contact_point_rec_type;
4914  email_rec       hz_contact_point_v2pub.email_rec_type;
4915  phone_rec       hz_contact_point_v2pub.phone_rec_type;
4916  ocon_rec        hz_party_contact_v2pub.org_contact_rec_type;
4917  edi_rec         hz_contact_point_v2pub.edi_rec_type;
4918  telex_rec       hz_contact_point_v2pub.telex_rec_type;
4919  web_rec         hz_contact_point_v2pub.web_rec_type;
4920  fax_rec         hz_contact_point_v2pub.phone_rec_type;
4921 
4922 
4923 begin
4924 
4925  x_gen_party_site_number := fnd_profile.value('HZ_GENERATE_PARTY_SITE_NUMBER');
4926  x_hz_dup_check          := fnd_profile.value('AMS_HZ_DEDUPE_RULE');
4927   if x_hz_dup_check <> 'Y' then
4928     x_hz_dup_check := 'N';
4929  end if;
4930  -- Checks if it's B2B or B2C party type.
4931         OPEN b2borb2c;
4932         FETCH b2borb2c into x_b2b,x_rented_list_flag,x_import_list_header_id;
4933         CLOSE b2borb2c;
4934 
4935     if x_rented_list_flag <> 'R' then
4936         p_return_status  := FND_API.G_RET_STS_UNEXP_ERROR;
4937         FND_MESSAGE.SET_NAME('AMS', 'API_DEBUG_MESSAGE');
4938         FND_MESSAGE.SET_TOKEN('ROW','Party was not created through rented list.');
4939         FND_MESSAGE.SET_TOKEN('ERROR' ,SQLERRM);
4940         FND_MSG_PUB.ADD;
4941        ROLLBACK;
4942        RETURN;
4943     end if;
4944 
4945 if x_b2b = 'B2B' then
4946      SELECT subject_id into x_org_party_id FROM hz_relationships WHERE subject_type = 'ORGANIZATION'
4947      AND party_id = p_party_id;
4948            OPEN b2b;
4949           FETCH b2b into
4950            org_rec.party_rec.orig_system_reference,
4951            org_rec.organization_name,
4952            org_rec.fiscal_yearend_month,
4953            org_rec.duns_number_c,
4954            org_rec.employees_total,
4955            org_rec.line_of_business,
4956            org_rec.year_established,
4957            org_rec.tax_reference,
4958            org_rec.ceo_name,
4959            person_rec.person_first_name,
4960            person_rec.person_middle_name,
4961            person_rec.person_last_name,
4962            person_rec.person_name_suffix,
4963            person_rec.person_pre_name_adjunct,
4964            -- person_rec.best_time_contact_begin,
4965            -- person_rec.best_time_contact_end,
4966            location_rec.country,
4967            location_rec.address1,
4968            location_rec.address2,
4969            location_rec.city,
4970            location_rec.county,
4971            location_rec.state,
4972            location_rec.province,
4973            location_rec.postal_code,
4974   --         location_rec.time_zone,
4975            x_email_address,
4976            x_phone_country_code,
4977            x_phone_area_code,
4978            x_phone_number,
4979            x_phone_extention,
4980            ocon_rec.department,
4981            ocon_rec.job_title,
4982            ocon_rec.decision_maker_flag,
4983            org_rec.sic_code,
4984            org_rec.sic_code_type,
4985         --   org_rec.party_rec.TOTAL_NUM_OF_ORDERS,
4986         --   org_rec.party_rec.TOTAL_ORDERED_AMOUNT,
4987         --   org_rec.party_rec.LAST_ORDERED_DATE,
4988            org_rec.analysis_fy,
4989            org_rec.CURR_FY_POTENTIAL_REVENUE,
4990            org_rec.NEXT_FY_POTENTIAL_REVENUE,
4991            org_rec.GSA_INDICATOR_FLAG,
4992            org_rec.MISSION_STATEMENT,
4993            org_rec.ORGANIZATION_NAME_PHONETIC,
4994            org_rec.party_rec.CATEGORY_CODE,
4995            org_rec.JGZZ_FISCAL_CODE,
4996          --  org_rec.TAX_NAME,
4997            location_rec.ADDRESS3,
4998            location_rec.ADDRESS4,
4999            location_rec.ADDRESS_LINES_PHONETIC,
5000            -- location_rec.APARTMENT_FLAG,
5001            -- bug 4641591: columns obsolete
5002            -- 	   location_rec.PO_BOX_NUMBER,
5003            --            location_rec.HOUSE_NUMBER,
5004            --            location_rec.STREET_SUFFIX,
5005            -- location_rec.SECONDARY_SUFFIX_ELEMENT,
5006            --            location_rec.STREET,
5007            -- location_rec.RURAL_ROUTE_TYPE,
5008            -- location_rec.RURAL_ROUTE_NUMBER,
5009            --            location_rec.STREET_NUMBER,
5010            --            location_rec.FLOOR,
5011            --            location_rec.SUITE,
5012            location_rec.POSTAL_PLUS4_CODE,
5013            -- location_rec.OVERSEAS_ADDRESS_FLAG,
5014            psite_rec.identifying_address_flag,
5015 
5016 	   location_rec.ADDRESS_EFFECTIVE_DATE,
5017            location_rec.ADDRESS_EXPIRATION_DATE,
5018            org_rec.BRANCH_FLAG,
5019            org_rec.line_of_business,
5020            org_rec.BUSINESS_SCOPE,
5021            org_rec.ceo_title,
5022            org_rec.cong_dist_code,
5023            org_rec.control_yr,
5024            org_rec.corporation_class,
5025            org_rec.credit_score,
5026            org_rec.credit_score_commentary,
5027            org_rec.DB_RATING,
5028            person_rec.DATE_OF_BIRTH,
5029            person_rec.DATE_OF_DEATH,
5030            org_rec.debarments_count,
5031            org_rec.debarments_date,
5032            person_rec.DECLARED_ETHNICITY,
5033            org_rec.debarment_ind,
5034            location_rec.description,
5035            org_rec.disadv_8a_ind,
5036            org_rec.ENQUIRY_DUNS,
5037            org_rec.export_ind,
5038            org_rec.failure_score,
5039            org_rec.FAILURE_SCORE_COMMENTARY,
5040            org_rec.failure_score_natnl_percentile,
5041            org_rec.FAILURE_SCORE_OVERRIDE_CODE,
5042            org_rec.GLOBAL_FAILURE_SCORE,
5043            org_rec.hq_branch_ind,
5044            person_rec.HEAD_OF_HOUSEHOLD_FLAG,
5045            person_rec.HOUSEHOLD_SIZE,
5046            org_rec.import_ind,
5047            org_rec.known_as,
5048            org_rec.known_as2,
5049            org_rec.known_as3,
5050            org_rec.known_as4,
5051            org_rec.known_as5,
5052            person_rec.KNOWN_AS,
5053            person_rec.KNOWN_AS2,
5054            PERSON_rec.KNOWN_AS3,
5055            PERSON_rec.KNOWN_AS4,
5056            PERSON_rec.KNOWN_AS5,
5057            org_rec.labor_surplus_ind,
5058            org_rec.LOCAL_ACTIVITY_CODE,
5059            org_rec.LOCAL_ACTIVITY_CODE_TYPE,
5060            location_rec.LOCATION_DIRECTIONS ,
5061            person_rec.MARITAL_STATUS,
5062            person_rec.MARITAL_STATUS_EFFECTIVE_DATE,
5063            org_rec.minority_owned_ind,
5064 	   org_rec.minority_owned_type,
5065 	   org_rec.organization_type,
5066            web_rec.url,
5067 	   org_rec.oob_ind,
5068            person_rec.personal_income,
5069 	   person_rec.person_academic_title,
5070            person_rec.person_first_name_phonetic,
5071 	   person_rec.person_last_name_phonetic,
5072            person_rec.middle_name_phonetic,
5073 	   person_rec.person_name_phonetic,
5074            person_rec.person_previous_last_name, --modify ak
5075 	   person_rec.place_of_birth,
5076 	   org_rec.principal_name,
5077            org_rec.principal_title,
5078 	   org_rec.public_private_ownership_flag,
5079            person_rec.rent_own_ind,
5080            person_rec.person_academic_title,
5081 	   location_rec.short_description,
5082            org_rec.small_bus_ind,
5083 	   person_rec.tax_reference,
5084            org_rec.woman_owned_ind,
5085            org_rec.ATTRIBUTE1,
5086            org_rec.ATTRIBUTE2,
5087            org_rec.ATTRIBUTE3,
5088            org_rec.ATTRIBUTE4,
5089            org_rec.ATTRIBUTE5,
5090            org_rec.ATTRIBUTE6,
5091            org_rec.ATTRIBUTE7,
5092            org_rec.ATTRIBUTE8,
5093            org_rec.ATTRIBUTE9,
5094            org_rec.ATTRIBUTE10,
5095            org_rec.ATTRIBUTE11,
5096            org_rec.ATTRIBUTE12,
5097            org_rec.ATTRIBUTE13,
5098            org_rec.ATTRIBUTE14,
5099            org_rec.ATTRIBUTE15,
5100            person_rec.ATTRIBUTE1,
5101            person_rec.ATTRIBUTE2,
5102            person_rec.ATTRIBUTE3,
5103            person_rec.ATTRIBUTE4,
5104            person_rec.ATTRIBUTE5,
5105            person_rec.ATTRIBUTE6,
5106            person_rec.ATTRIBUTE7,
5107            person_rec.ATTRIBUTE8,
5108            person_rec.ATTRIBUTE9,
5109            person_rec.ATTRIBUTE10,
5110            person_rec.ATTRIBUTE11,
5111            person_rec.ATTRIBUTE12,
5112            person_rec.ATTRIBUTE13,
5113            person_rec.ATTRIBUTE14,
5114            person_rec.ATTRIBUTE15,
5115            ocon_rec.ATTRIBUTE1,
5116            ocon_rec.ATTRIBUTE2,
5117            ocon_rec.ATTRIBUTE3,
5118            ocon_rec.ATTRIBUTE4,
5119            ocon_rec.ATTRIBUTE5,
5120            ocon_rec.ATTRIBUTE6,
5121            ocon_rec.ATTRIBUTE7,
5122            ocon_rec.ATTRIBUTE8,
5123            ocon_rec.ATTRIBUTE9,
5124            ocon_rec.ATTRIBUTE10,
5125            ocon_rec.ATTRIBUTE11,
5126            ocon_rec.ATTRIBUTE12,
5127            ocon_rec.ATTRIBUTE13,
5128            ocon_rec.ATTRIBUTE14,
5129            ocon_rec.ATTRIBUTE15,
5130            location_rec.ATTRIBUTE1,
5131            location_rec.ATTRIBUTE2,
5132            location_rec.ATTRIBUTE3,
5133            location_rec.ATTRIBUTE4,
5134            location_rec.ATTRIBUTE5,
5135            location_rec.ATTRIBUTE6,
5136            location_rec.ATTRIBUTE7,
5137            location_rec.ATTRIBUTE8,
5138            location_rec.ATTRIBUTE9,
5139            location_rec.ATTRIBUTE10,
5140            location_rec.ATTRIBUTE11,
5141            location_rec.ATTRIBUTE12,
5142            location_rec.ATTRIBUTE13,
5143            location_rec.ATTRIBUTE14,
5144            location_rec.ATTRIBUTE15,
5145 	   fax_rec.phone_country_code,
5146 	   fax_rec.phone_area_code,
5147            fax_rec.phone_number,
5148            org_rec.attribute_category,
5149            person_rec.attribute_category,
5150            ocon_rec.attribute_category,
5151            location_rec.attribute_category,
5152            psiteuse_rec.site_use_type;
5153 
5154 
5155            if b2b%notfound then
5156                  return;
5157            end if;
5158 
5159 -- Update Organization
5160 
5161            org_rec.party_rec.party_id     := x_org_party_id;
5162            org_rec.CREATED_BY_MODULE        := 'AMS_LIST_IMPORT';
5163            org_rec.application_id := 530;
5164            -- SELECT last_update_date INTO l_last_update_date
5165            SELECT OBJECT_VERSION_NUMBER INTO l_object_version
5166            FROM hz_parties
5167            WHERE party_id= x_org_party_id;
5168            x_date1 := l_last_update_date;
5169            org_rec.party_rec.status := 'A';
5170                 hz_party_v2pub.update_organization(
5171                 'F',
5172                 org_rec,
5173                 l_object_version,
5174                 x_profile_id,
5175                 x_return_status,
5176                 x_msg_count,
5177                 x_msg_data);
5178         if x_msg_count > 1 then
5179          FOR i IN 1..x_msg_count  LOOP
5180          x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
5181 	 x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
5182         END LOOP;
5183         x_msg_data := x_tmp_var1;
5184         END IF;
5185 
5186         if x_return_status <> 'S' then
5187           p_return_status  :=  x_return_status;
5188           p_msg_count      :=  x_msg_count;
5189           p_msg_data       :=  x_msg_data;
5190         ROLLBACK;
5191         RETURN;
5192        end if;
5193 
5194     -- Update Person
5195 
5196        SELECT subject_id into x_person_id FROM hz_relationships WHERE subject_type = 'PERSON'
5197        AND party_id = p_party_id;
5198       -- SELECT last_update_date INTO l_last_update_date1
5199        SELECT OBJECT_VERSION_NUMBER INTO l_object_version
5200        FROM HZ_PARTIES
5201        WHERE party_id = x_person_id;
5202        x_date1 := l_last_update_date1;
5203        person_rec.party_rec.party_id     := x_person_id;
5204        person_rec.party_rec.status := 'A';
5205        person_rec.CREATED_BY_MODULE        := 'AMS_LIST_IMPORT';
5206        person_rec.application_id  := 530;
5207           hz_party_v2pub.update_person(
5208                 'F',
5209                 person_rec,
5210                 l_object_version,
5211                 x_profile_id,
5212                 x_return_status,
5213                 x_msg_count,
5214                 x_msg_data);
5215        if x_msg_count > 1 then
5216          FOR i IN 1..x_msg_count  LOOP
5217          x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
5218          x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
5219         END LOOP;
5220         x_msg_data := x_tmp_var1;
5221         END IF;
5222 
5223        if x_return_status <> 'S' then
5224           p_return_status  :=  x_return_status;
5225           p_msg_count      :=  x_msg_count;
5226           p_msg_data       :=  x_msg_data;
5227         ROLLBACK;
5228         RETURN;
5229        end if;
5230 
5231      -- Update Org Contacts
5232        open c_relationship;
5233        fetch c_relationship into x_relationship_id,l_object_version2;
5234        close c_relationship;
5235 
5236        SELECT ORG_CONTACT_ID, OBJECT_VERSION_NUMBER into x_org_contact_id ,l_object_version3 FROM hz_org_contacts WHERE
5237        PARTY_RELATIONSHIP_ID = x_relationship_id;
5238 
5239        select last_update_date into x_date_three from hz_parties where party_id = p_party_id;
5240        -- ocon_rec.status     := 'A';
5241        ocon_rec.org_contact_id     := x_org_contact_id;
5242        ocon_rec.party_rel_rec.status     := 'A';
5243        ocon_rec.CREATED_BY_MODULE        := 'AMS_LIST_IMPORT';
5244        ocon_rec.application_id := 530;
5245        hz_party_contact_v2pub.update_org_contact(
5246                 'F',
5247                 ocon_rec,
5248                 l_object_version,
5249                 l_object_version2,
5250                 l_object_version3,
5251                 x_return_status,
5252                 x_msg_count,
5253                 x_msg_data);
5254       if x_msg_count > 1 then
5255          FOR i IN 1..x_msg_count  LOOP
5256          x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
5257           x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
5258         END LOOP;
5259         x_msg_data := x_tmp_var1;
5260         END IF;
5261 
5262       if x_return_status <> 'S' then
5263           p_return_status  :=  x_return_status;
5264           p_msg_count      :=  x_msg_count;
5265           p_msg_data       :=  x_msg_data;
5266         ROLLBACK;
5267         RETURN;
5268        end if;
5269 
5270 
5271  -- Create Location
5272 
5273  if x_hz_dup_check = 'Y' then
5274     address_echeck(
5275    p_party_id              => x_org_party_id,
5276    x_return_status       => x_return_status,
5277    x_msg_count           => x_msg_count,
5278    x_msg_data            => x_msg_data,
5279    p_location_id           => x_locatiON_Id,
5280    p_address1              => location_rec.address1,
5281    p_city                  => location_rec.city,
5282    p_pcode                 => location_rec.postal_code,
5283    p_country               => location_rec.country
5284                   );
5285       if x_return_status <> 'S' then
5286           p_return_status  :=  x_return_status;
5287           p_msg_count      :=  x_msg_count;
5288           p_msg_data       :=  x_msg_data;
5289         ROLLBACK;
5290         RETURN;
5291        end if;
5292 
5293  end if;
5294 
5295   if x_location_id is null and x_org_party_id is not null then
5296   if location_rec.address1 is not NULL then
5297       x_return_status  := null;
5298       x_msg_count      := null;
5299       x_msg_data       := null;
5300 
5301        create_location (
5302         location_rec  ,
5303         x_return_status ,
5304         x_msg_count     ,
5305         x_msg_data      ,
5306         x_location_id   );
5307       if x_return_status <> 'S' then
5308          rollback;
5309          return;
5310       end if;
5311   end if; -- if location_rec.address1 is not NULL
5312   end if; -- x_location_id is null;
5313 
5314 -- Create Party Site
5315    l_lp_psite_id := null;
5316    open LOCATION_EXISTS;
5317    fetch LOCATION_EXISTS into l_lp_psite_id;
5318    close LOCATION_EXISTS;
5319  if l_lp_psite_id is null and x_org_party_id is not null and x_location_id is not null then
5320   psite_rec.party_id                 := x_org_party_id;
5321   psite_rec.location_id              := x_location_id;
5322   psite_rec.status                   := 'A';
5323 
5324   create_party_site(
5325                 psite_rec,
5326                 x_return_status,
5327                 x_msg_count,
5328                 x_msg_data,
5329                 x_party_site_id,
5330                 x_party_site_number
5331                 );
5332      if x_return_status <> 'S' then
5333          rollback;
5334          return;
5335       end if;
5336  end if;
5337 
5338    -- Creating party_site for Contacts.
5339    x_party_rel_party_id := p_party_id;
5340    if person_rec.person_first_name is not null and x_party_rel_party_id is not null then
5341       if location_rec.address1 is not NULL and  x_location_id is not null then
5342          l_lp_psite_id := null;
5343          open CHECK_PSITE_EXISTS;
5344          fetch CHECK_PSITE_EXISTS into l_lp_psite_id;
5345          close CHECK_PSITE_EXISTS;
5346          if l_lp_psite_id is null then
5347             -- Create Party Site
5348             x_return_status  := null;
5349             x_msg_count      := null;
5350             x_msg_data       := null;
5351             x_party_site_number := null;
5352 
5353             psite_rec.party_id                 := x_party_rel_party_id;
5354             psite_rec.location_id              := x_location_id;
5355             psite_rec.status                   := 'A';
5356             create_party_site(
5357                 psite_rec,
5358                 x_return_status,
5359                 x_msg_count,
5360                 x_msg_data,
5361                 x_party_site_id,
5362                 x_party_site_number
5363                 );
5364               if x_return_status <> 'S' then
5365                   rollback;
5366                   return;
5367               end if;
5368           end if;
5369         end if;
5370     end if;
5371 
5372 -- Create contact points  Phone
5373 
5374    if x_phone_number is not NULL and x_party_rel_party_id is not null then
5375 
5376    x_return_status  := null;
5377    x_msg_count      := null;
5378    x_msg_data       := null;
5379   cpoint_rec.contact_point_type     := 'PHONE';
5380   cpoint_rec.status                 := 'A';
5381   cpoint_rec.owner_table_name       := 'HZ_PARTIES';
5382   cpoint_rec.owner_table_id         := x_party_rel_party_id;
5383   phone_rec.phone_line_type         := 'GEN';
5384   phone_rec.phone_number            := x_phone_number;
5385   phone_rec.phone_country_code      := x_phone_country_code;
5386   phone_rec.phone_area_code         := x_phone_area_code;
5387   phone_rec.phone_extension         := x_phone_extention;
5388 
5389   l_phone_exists := NULL;
5390   open phone_exists(x_party_rel_party_id);
5391   fetch phone_exists into l_phone_exists;
5392   close phone_exists;
5393    if l_phone_exists is NULL then
5394        create_contact_point(
5395                    cpoint_rec,
5396                    edi_rec,
5397                    email_rec,
5398                    phone_rec,
5399                    telex_rec,
5400                    web_rec,
5401                    x_return_status,
5402                    x_msg_count,
5403                    x_msg_data,
5404                    x_contact_point_id);
5405             if x_return_status <> 'S' then
5406                   rollback;
5407                   return;
5408               end if;
5409    end if;
5410   end if;
5411 
5412 -- Create contact points Email
5413 
5414 if x_email_address is not NULL  and x_party_rel_party_id is not null  then
5415 
5416    x_return_status  := null;
5417    x_msg_count      := null;
5418    x_msg_data       := null;
5419          cpoint_rec.contact_point_type     := 'EMAIL';
5420          cpoint_rec.status                 := 'A';
5421          cpoint_rec.owner_table_name       := 'HZ_PARTIES';
5422          cpoint_rec.owner_table_id         := x_party_rel_party_id;
5423          email_rec.email_address := x_email_address;
5424         l_email_exists := NULL;
5425         open email_exists(x_party_rel_party_id);
5426         fetch email_exists into l_email_exists;
5427         close email_exists;
5428         if l_email_exists is NULL then
5429            create_contact_point(
5430                    cpoint_rec,
5431                    edi_rec,
5432                    email_rec,
5433                    phone_rec,
5434                    telex_rec,
5435                    web_rec,
5436                    x_return_status,
5437                    x_msg_count,
5438                    x_msg_data,
5439                    x_contact_point_id);
5440             if x_return_status <> 'S' then
5441                   rollback;
5442                   return;
5443               end if;
5444        end if;
5445    end if;
5446 
5447  end if;  -- b2b = 'Y'
5448 
5449 if x_b2b = 'B2C' then
5450         OPEN b2c;
5451            FETCH b2c into
5452            person_rec.party_rec.orig_system_reference,
5453            person_rec.person_first_name,
5454            person_rec.person_middle_name,
5455            person_rec.person_last_name,
5456            person_rec.person_name_suffix,
5457            person_rec.person_pre_name_adjunct,
5458            -- person_rec.best_time_contact_begin,
5459            -- person_rec.best_time_contact_end,
5460            location_rec.country,
5461            location_rec.address1,
5462            location_rec.address2,
5463            location_rec.city,
5464            location_rec.county,
5465            location_rec.state,
5466            location_rec.province,
5467            location_rec.postal_code,
5468           -- location_rec.time_zone,
5469            x_email_address,
5470            x_phone_country_code,
5471            x_phone_area_code,
5472            x_phone_number,
5473            x_phone_extention,
5474            -- person_rec.person_pre_name_adjunct,
5475            person_rec.party_rec.SALUTATION,
5476            location_rec.ADDRESS3,
5477            location_rec.ADDRESS4,
5478            location_rec.ADDRESS_LINES_PHONETIC,
5479            -- location_rec.APARTMENT_FLAG,
5480            -- bug 4641591: columns obsolete
5481            -- location_rec.PO_BOX_NUMBER,
5482            -- location_rec.HOUSE_NUMBER,
5483            --            location_rec.STREET_SUFFIX,
5484            -- location_rec.SECONDARY_SUFFIX_ELEMENT,
5485            --            location_rec.STREET,
5486            -- location_rec.RURAL_ROUTE_TYPE,
5487            -- location_rec.RURAL_ROUTE_NUMBER,
5488            --            location_rec.STREET_NUMBER,
5489            --            location_rec.FLOOR,
5490            --            location_rec.SUITE,
5491            location_rec.POSTAL_PLUS4_CODE,
5492            -- location_rec.OVERSEAS_ADDRESS_FLAG,
5493            psite_rec.identifying_address_flag,
5494 
5495 	   person_rec.person_last_name_phonetic,
5496 	   person_rec.person_first_name_phonetic,
5497            --PREFERRED_NAME,
5498 	   web_rec.url, -- replace PREFERRED_NAME with URL
5499 	   person_rec.person_academic_title,
5500            person_rec.date_of_birth,
5501 	   person_rec.person_academic_title,
5502            person_rec.person_previous_last_name,
5503 	   person_rec.known_as,
5504            person_rec.known_as2,
5505 	   person_rec.known_as3,
5506            person_rec.known_as4,
5507 	   person_rec.known_as5,
5508            person_rec.person_name_phonetic,
5509 	   person_rec.middle_name_phonetic,
5510            person_rec.jgzz_fiscal_code,
5511 	   person_rec.place_of_birth,
5512            person_rec.date_of_death,
5513 	   person_rec.declared_ethnicity,
5514            person_rec.marital_status,
5515 	   person_rec.personal_income,
5516            person_rec.marital_status_effective_date,
5517 	   person_rec.head_of_household_flag,
5518            person_rec.household_size,
5519 	   location_rec.location_directions,
5520            location_rec.address_effective_date,
5521 	   location_rec.address_expiration_date,
5522            person_rec.attribute1,
5523            person_rec.attribute2,
5524            person_rec.attribute3,
5525            person_rec.attribute4,
5526            person_rec.attribute5,
5527            person_rec.attribute6,
5528            person_rec.attribute7,
5529            person_rec.attribute8,
5530            person_rec.attribute9,
5531            person_rec.attribute10,
5532            person_rec.attribute11,
5533            person_rec.attribute12,
5534            person_rec.attribute13,
5535            person_rec.attribute14,
5536            person_rec.attribute15,
5537            location_rec.attribute1,
5538            location_rec.attribute2,
5539            location_rec.attribute3,
5540            location_rec.attribute4,
5541            location_rec.attribute5,
5542            location_rec.attribute6,
5543            location_rec.attribute7,
5544            location_rec.attribute8,
5545            location_rec.attribute9,
5546            location_rec.attribute10,
5547            location_rec.attribute11,
5548            location_rec.attribute12,
5549            location_rec.attribute13,
5550            location_rec.attribute14,
5551            location_rec.attribute15,
5552            fax_rec.phone_country_code,
5553 	   fax_rec.phone_area_code,
5554            fax_rec.phone_number,
5555            person_rec.attribute_category,
5556            location_rec.attribute_category ,
5557 	   location_rec.short_description,
5558 	   location_rec.description,
5559            psiteuse_rec.site_use_type;
5560         CLOSE b2c;
5561 
5562     -- Update Person
5563 
5564        -- SELECT last_update_date INTO l_last_update_date1
5565        l_object_version := NULL;
5566        SELECT OBJECT_VERSION_NUMBER INTO l_object_version
5567        FROM HZ_PARTIES
5568        WHERE party_id = p_party_id;
5569        x_date1 := l_last_update_date1;
5570        person_rec.party_rec.party_id     := p_party_id;
5571        person_rec.party_rec.status := 'A';
5572        person_rec.CREATED_BY_MODULE        := 'AMS_LIST_IMPORT';
5573        person_rec.application_id := 530;
5574           hz_party_v2pub.update_person(
5575                 'F',
5576                 person_rec,
5577                 l_object_version,
5578                 x_profile_id,
5579                 x_return_status,
5580                 x_msg_count,
5581                 x_msg_data);
5582        if x_msg_count > 1 then
5583          FOR i IN 1..x_msg_count  LOOP
5584          x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
5585          x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
5586         END LOOP;
5587         x_msg_data := x_tmp_var1;
5588         END IF;
5589 
5590        if x_return_status <> 'S' then
5591           p_return_status  :=  x_return_status;
5592           p_msg_count      :=  x_msg_count;
5593           p_msg_data       :=  x_msg_data;
5594         ROLLBACK;
5595         RETURN;
5596        end if;
5597 
5598  -- Create Location
5599  x_per_party_id := p_party_id;
5600  if x_hz_dup_check = 'Y' then
5601    address_echeck(
5602    p_party_id              => x_per_party_id,
5603    x_return_status       => x_return_status,
5604    x_msg_count           => x_msg_count,
5605    x_msg_data            => x_msg_data,
5606    p_location_id           => x_locatiON_Id,
5607    p_address1              => location_rec.address1,
5608    p_city                  => location_rec.city,
5609    p_pcode                 => location_rec.postal_code,
5610    p_country               => location_rec.country
5611                   );
5612       if x_return_status <> 'S' then
5613           p_return_status  :=  x_return_status;
5614           p_msg_count      :=  x_msg_count;
5615           p_msg_data       :=  x_msg_data;
5616         ROLLBACK;
5617         RETURN;
5618        end if;
5619 
5620  end if;
5621 
5622   if x_location_id is null and x_per_party_id is not null then
5623   if location_rec.address1 is not NULL then
5624       x_return_status  := null;
5625       x_msg_count      := null;
5626       x_msg_data       := null;
5627 
5628        create_location (
5629         location_rec  ,
5630         x_return_status ,
5631         x_msg_count     ,
5632         x_msg_data      ,
5633         x_location_id   );
5634       if x_return_status <> 'S' then
5635          rollback;
5636          return;
5637       end if;
5638   end if; -- if location_rec.address1 is not NULL
5639   end if; -- x_location_id is null;
5640 
5641 
5642    l_lp_psite_id := null;
5643    open PER_LOCATION_EXISTS;
5644    fetch PER_LOCATION_EXISTS into l_lp_psite_id;
5645    close PER_LOCATION_EXISTS;
5646 if l_lp_psite_id is null and x_per_party_id is not null and x_location_id is not null then
5647 -- Create Party Site
5648    x_return_status  := null;
5649    x_msg_count      := null;
5650    x_msg_data       := null;
5651    x_party_site_number := null;
5652   psite_rec.party_id                 := x_per_party_id;
5653   psite_rec.location_id              := x_location_id;
5654   psite_rec.status                   := 'A';
5655 
5656   create_party_site(
5657                 psite_rec,
5658                 x_return_status,
5659                 x_msg_count,
5660                 x_msg_data,
5661                 x_party_site_id,
5662                 x_party_site_number
5663                 );
5664      if x_return_status <> 'S' then
5665          rollback;
5666          return;
5667       end if;
5668  end if;
5669 
5670 
5671 -- Create contact points  Phone
5672 
5673   if x_phone_number is not NULL and x_per_party_id is not null then
5674 
5675    x_return_status  := null;
5676    x_msg_count      := null;
5677    x_msg_data       := null;
5678   cpoint_rec.contact_point_type     := 'PHONE';
5679   cpoint_rec.status                 := 'A';
5680   cpoint_rec.owner_table_name       := 'HZ_PARTIES';
5681   cpoint_rec.owner_table_id         := x_per_party_id;
5682   phone_rec.phone_line_type         := 'GEN';
5683   phone_rec.phone_number            := x_phone_number;
5684   phone_rec.phone_country_code      := x_phone_country_code;
5685   phone_rec.phone_area_code         := x_phone_area_code;
5686   phone_rec.phone_extension         := x_phone_extention;
5687 
5688   l_phone_exists := NULL;
5689   open phone_exists(x_per_party_id);
5690   fetch phone_exists into l_phone_exists;
5691   close phone_exists;
5692    if l_phone_exists is NULL then
5693        create_contact_point(
5694                    cpoint_rec,
5695                    edi_rec,
5696                    email_rec,
5697                    phone_rec,
5698                    telex_rec,
5699                    web_rec,
5700                    x_return_status,
5701                    x_msg_count,
5702                    x_msg_data,
5703                    x_contact_point_id);
5704             if x_return_status <> 'S' then
5705                   rollback;
5706                   return;
5707               end if;
5708    end if;
5709   end if;
5710 
5711 
5712 -- Create contact points Email
5713 
5714 if x_email_address is not NULL  and x_per_party_id is not null  then
5715 
5716    x_return_status  := null;
5717    x_msg_count      := null;
5718    x_msg_data       := null;
5719          cpoint_rec.contact_point_type     := 'EMAIL';
5720          cpoint_rec.status                 := 'A';
5721          cpoint_rec.owner_table_name       := 'HZ_PARTIES';
5722          cpoint_rec.owner_table_id         := x_per_party_id;
5723          email_rec.email_address := x_email_address;
5724         l_email_exists := NULL;
5725         open email_exists(x_per_party_id);
5726         fetch email_exists into l_email_exists;
5727         close email_exists;
5728         if l_email_exists is NULL then
5729            create_contact_point(
5730                    cpoint_rec,
5731                    edi_rec,
5732                    email_rec,
5733                    phone_rec,
5734                    telex_rec,
5735                    web_rec,
5736                    x_return_status,
5737                    x_msg_count,
5738                    x_msg_data,
5739                    x_contact_point_id);
5740             if x_return_status <> 'S' then
5741                   rollback;
5742                   return;
5743               end if;
5744        end if;
5745    end if;
5746 
5747 end if; -- if x_b2b = 'N' then
5748 end update_rented_list_party;
5749 
5750 -- -------------------------------------------------------------
5751 
5752 -- This program performs error checks in ams_import_interface table.
5753 
5754 PROCEDURE execute_lead_data_validation (
5755                             p_import_list_header_id NUMBER,
5756                             p_return_status OUT NOCOPY     VARCHAR2
5757                             ) IS
5758 
5759 TYPE num_data_set_type_w IS
5760   TABLE OF NUMBER INDEX BY BINARY_INTEGER;
5761 
5762 TYPE varchar2_250_set_type IS
5763         TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
5764 
5765 L_MAX_ROW_COUNT                                 CONSTANT NUMBER := 1000;
5766 l_batch_id						 NUMBER;
5767 l_assign_date					varchar2(150);
5768 l_lead_date					varchar2(150);
5769 l_address_effective_date			varchar2(150);
5770 l_last_ordered_date				varchar2(150);
5771 l_program_update_date				varchar2(150);
5772 x_import_list_header_id				number;
5773 x_import_source_line_id 			number;
5774 l_message					varchar2(100);
5775 l_invalid_number varchar2(4000) ;
5776 l_invalid_size   varchar2(4000) ;
5777 l_null_value     varchar2(4000) ;
5778 l_invalid_src_system     varchar2(4000) ;
5779 l_return_status           			varchar2(1);
5780 l_total_rec	number;
5781 l_source_system	varchar2(60);
5782 l_error_exists  varchar2(1);
5783 
5784 
5785 
5786        l_import_source_line_id                 num_data_set_type_w;
5787        l_import_list_header_id                 num_data_set_type_w;
5788 
5789        l_col1	                               varchar2_250_set_type;
5790        l_col2 	                               varchar2_250_set_type;
5791        l_col3 	                               varchar2_250_set_type;
5792        l_col4 	                               varchar2_250_set_type;
5793        l_col5 	                               varchar2_250_set_type;
5794        l_col6 	                               varchar2_250_set_type;
5795        l_col7 	                               varchar2_250_set_type;
5796        l_col8 	                               varchar2_250_set_type;
5797        l_col9 	                               varchar2_250_set_type;
5798        l_col10 	                               varchar2_250_set_type;
5799        l_col11 	                               varchar2_250_set_type;
5800        l_col12 	                               varchar2_250_set_type;
5801        l_col13 	                               varchar2_250_set_type;
5802        l_col14 	                               varchar2_250_set_type;
5803        l_col15 	                               varchar2_250_set_type;
5804        l_col16 	                               varchar2_250_set_type;
5805        l_col17 	                               varchar2_250_set_type;
5806        l_col18 	                               varchar2_250_set_type;
5807        l_col19 	                               varchar2_250_set_type;
5808        l_col20 	                               varchar2_250_set_type;
5809        l_col21 	                               varchar2_250_set_type;
5810        l_col22 	                               varchar2_250_set_type;
5811        l_col23 	                               varchar2_250_set_type;
5812        l_col24 	                               varchar2_250_set_type;
5813        l_col25 	                               varchar2_250_set_type;
5814        l_col26 	                               varchar2_250_set_type;
5815        l_col27 	                               varchar2_250_set_type;
5816        l_col28 	                               varchar2_250_set_type;
5817        l_col29 	                               varchar2_250_set_type;
5818        l_col30 	                               varchar2_250_set_type;
5819        l_col31 	                               varchar2_250_set_type;
5820        l_col32 	                               varchar2_250_set_type;
5821        l_col33 	                               varchar2_250_set_type;
5822        l_col34 	                               varchar2_250_set_type;
5823        l_col35 	                               varchar2_250_set_type;
5824        l_col36 	                               varchar2_250_set_type;
5825        l_col37 	                               varchar2_250_set_type;
5826        l_col38 	                               varchar2_250_set_type;
5827        l_col39 	                               varchar2_250_set_type;
5828        l_col40 	                               varchar2_250_set_type;
5829        l_col41 	                               varchar2_250_set_type;
5830        l_col42 	                               varchar2_250_set_type;
5831        l_col43 	                               varchar2_250_set_type;
5832        l_col44 	                               varchar2_250_set_type;
5833        l_col45 	                               varchar2_250_set_type;
5834        l_col46 	                               varchar2_250_set_type;
5835        l_col47 	                               varchar2_250_set_type;
5836        l_col48 	                               varchar2_250_set_type;
5837        l_col49 	                               varchar2_250_set_type;
5838        l_col50 	                               varchar2_250_set_type;
5839        l_col51 	                               varchar2_250_set_type;
5840        l_col52 	                               varchar2_250_set_type;
5841        l_col53 	                               varchar2_250_set_type;
5842        l_col54 	                               varchar2_250_set_type;
5843        l_col55 	                               varchar2_250_set_type;
5844        l_col56 	                               varchar2_250_set_type;
5845        l_col57 	                               varchar2_250_set_type;
5846        l_col58 	                               varchar2_250_set_type;
5847        l_col59 	                               varchar2_250_set_type;
5848        l_col60 	                               varchar2_250_set_type;
5849        l_col61 	                               varchar2_250_set_type;
5850        l_col62 	                               varchar2_250_set_type;
5851        l_col63 	                               varchar2_250_set_type;
5852        l_col64 	                               varchar2_250_set_type;
5853        l_col65 	                               varchar2_250_set_type;
5854        l_col66 	                               varchar2_250_set_type;
5855        l_col67 	                               varchar2_250_set_type;
5856        l_col68 	                               varchar2_250_set_type;
5857        l_col69 	                               varchar2_250_set_type;
5858        l_col70 	                               varchar2_250_set_type;
5859        l_col71 	                               varchar2_250_set_type;
5860        l_col72 	                               varchar2_250_set_type;
5861        l_col73 	                               varchar2_250_set_type;
5862        l_col74 	                               varchar2_250_set_type;
5863        l_col75 	                               varchar2_250_set_type;
5864        l_col76 	                               varchar2_250_set_type;
5865        l_col77 	                               varchar2_250_set_type;
5866        l_col78 	                               varchar2_250_set_type;
5867        l_col79 	                               varchar2_250_set_type;
5868        l_col80 	                               varchar2_250_set_type;
5869        l_col81 	                               varchar2_250_set_type;
5870        l_col82 	                               varchar2_250_set_type;
5871        l_col83 	                               varchar2_250_set_type;
5872        l_col84 	                               varchar2_250_set_type;
5873        l_col85 	                               varchar2_250_set_type;
5874        l_col86 	                               varchar2_250_set_type;
5875        l_col87 	                               varchar2_250_set_type;
5876        l_col88 	                               varchar2_250_set_type;
5877        l_col89 	                               varchar2_250_set_type;
5878        l_col90 	                               varchar2_250_set_type;
5879        l_col91 	                               varchar2_250_set_type;
5880        l_col92 	                               varchar2_250_set_type;
5881        l_col93 	                               varchar2_250_set_type;
5882        l_col94 	                               varchar2_250_set_type;
5883        l_col95 	                               varchar2_250_set_type;
5884        l_col96 	                               varchar2_250_set_type;
5885        l_col97 	                               varchar2_250_set_type;
5886        l_col98 	                               varchar2_250_set_type;
5887        l_col99 	                               varchar2_250_set_type;
5888        l_col100                                varchar2_250_set_type;
5889        l_col101                                  varchar2_250_set_type;
5890        l_col102                                  varchar2_250_set_type;
5891        l_col103                                  varchar2_250_set_type;
5892        l_col104                                  varchar2_250_set_type;
5893        l_col105                                  varchar2_250_set_type;
5894        l_col106                                  varchar2_250_set_type;
5895        l_col107                                  varchar2_250_set_type;
5896        l_col108                                  varchar2_250_set_type;
5897        l_col109                                  varchar2_250_set_type;
5898        l_col110                                 varchar2_250_set_type;
5899        l_col111                                 varchar2_250_set_type;
5900        l_col112                                 varchar2_250_set_type;
5901        l_col113                                 varchar2_250_set_type;
5902        l_col114                                 varchar2_250_set_type;
5903        l_col115                                 varchar2_250_set_type;
5904        l_col116                                 varchar2_250_set_type;
5905        l_col117                                 varchar2_250_set_type;
5906        l_col118                                 varchar2_250_set_type;
5907        l_col119                                 varchar2_250_set_type;
5908        l_col120                                 varchar2_250_set_type;
5909        l_col121                                 varchar2_250_set_type;
5910        l_col122                                 varchar2_250_set_type;
5911        l_col123                                 varchar2_250_set_type;
5912        l_col124                                 varchar2_250_set_type;
5913        l_col125                                 varchar2_250_set_type;
5914        l_col126                                 varchar2_250_set_type;
5915        l_col127                                 varchar2_250_set_type;
5916        l_col128                                 varchar2_250_set_type;
5917        l_col129                                 varchar2_250_set_type;
5918        l_col130                                 varchar2_250_set_type;
5919        l_col131                                 varchar2_250_set_type;
5920        l_col132                                 varchar2_250_set_type;
5921        l_col133                                 varchar2_250_set_type;
5922        l_col134                                 varchar2_250_set_type;
5923        l_col135                                 varchar2_250_set_type;
5924        l_col136                                 varchar2_250_set_type;
5925        l_col137                                 varchar2_250_set_type;
5926        l_col138                                 varchar2_250_set_type;
5927        l_col139                                 varchar2_250_set_type;
5928        l_col140                                 varchar2_250_set_type;
5929        l_col141                                 varchar2_250_set_type;
5930        l_col142                                 varchar2_250_set_type;
5931        l_col143                                 varchar2_250_set_type;
5932        l_col144                                 varchar2_250_set_type;
5933        l_col145                                 varchar2_250_set_type;
5934        l_col146                                 varchar2_250_set_type;
5935        l_col147                                 varchar2_250_set_type;
5936        l_col148                                 varchar2_250_set_type;
5937        l_col149                                 varchar2_250_set_type;
5938        l_col150                                 varchar2_250_set_type;
5939        l_col151                                 varchar2_250_set_type;
5940        l_col152                                 varchar2_250_set_type;
5941        l_col153                                 varchar2_250_set_type;
5942        l_col154                                 varchar2_250_set_type;
5943        l_col155                                 varchar2_250_set_type;
5944        l_col156                                 varchar2_250_set_type;
5945        l_col157                                 varchar2_250_set_type;
5946        l_col158                                 varchar2_250_set_type;
5947        l_col159                                 varchar2_250_set_type;
5948        l_col160                                 varchar2_250_set_type;
5949        l_col161                                 varchar2_250_set_type;
5950        l_col162                                 varchar2_250_set_type;
5951        l_col163                                 varchar2_250_set_type;
5952        l_col164                                 varchar2_250_set_type;
5953        l_col165                                 varchar2_250_set_type;
5954        l_col166                                 varchar2_250_set_type;
5955        l_col167                                 varchar2_250_set_type;
5956        l_col168                                 varchar2_250_set_type;
5957        l_col169                                 varchar2_250_set_type;
5958        l_col170                                 varchar2_250_set_type;
5959        l_col171                                 varchar2_250_set_type;
5960        l_col172                                 varchar2_250_set_type;
5961        l_col173                                 varchar2_250_set_type;
5962        l_col174                                 varchar2_250_set_type;
5963        l_col175                                 varchar2_250_set_type;
5964        l_col176                                 varchar2_250_set_type;
5965        l_col177                                 varchar2_250_set_type;
5966        l_col178                                 varchar2_250_set_type;
5967        l_col179                                 varchar2_250_set_type;
5968        l_col180                                 varchar2_250_set_type;
5969        l_col181                                 varchar2_250_set_type;
5970        l_col182                                 varchar2_250_set_type;
5971        l_col183                                 varchar2_250_set_type;
5972        l_col184                                 varchar2_250_set_type;
5973        l_col185                                 varchar2_250_set_type;
5974        l_col186                                 varchar2_250_set_type;
5975        l_col187                                 varchar2_250_set_type;
5976        l_col188                                 varchar2_250_set_type;
5977        l_col189                                 varchar2_250_set_type;
5978        l_col190                                 varchar2_250_set_type;
5979        l_col191                                 varchar2_250_set_type;
5980        l_col192                                 varchar2_250_set_type;
5981        l_col193                                 varchar2_250_set_type;
5982        l_col194                                 varchar2_250_set_type;
5983        l_col195                                 varchar2_250_set_type;
5984        l_col196                                 varchar2_250_set_type;
5985        l_col197                                 varchar2_250_set_type;
5986        l_col198                                 varchar2_250_set_type;
5987        l_col199                                 varchar2_250_set_type;
5988        l_col200                                varchar2_250_set_type;
5989        l_col201                                  varchar2_250_set_type;
5990        l_col202                                  varchar2_250_set_type;
5991        l_col203                                  varchar2_250_set_type;
5992        l_col204                                  varchar2_250_set_type;
5993        l_col205                                  varchar2_250_set_type;
5994        l_col206                                  varchar2_250_set_type;
5995        l_col207                                  varchar2_250_set_type;
5996        l_col208                                  varchar2_250_set_type;
5997        l_col209                                  varchar2_250_set_type;
5998        l_col210                                 varchar2_250_set_type;
5999        l_col211                                 varchar2_250_set_type;
6000        l_col212                                 varchar2_250_set_type;
6001        l_col213                                 varchar2_250_set_type;
6002        l_col214                                 varchar2_250_set_type;
6003        l_col215                                 varchar2_250_set_type;
6004        l_col216                                 varchar2_250_set_type;
6005        l_col217                                 varchar2_250_set_type;
6006        l_col218                                 varchar2_250_set_type;
6007        l_col219                                 varchar2_250_set_type;
6008        l_col220                                 varchar2_250_set_type;
6009        l_col221                                 varchar2_250_set_type;
6010        l_col222                                 varchar2_250_set_type;
6011        l_col223                                 varchar2_250_set_type;
6012        l_col224                                 varchar2_250_set_type;
6013        l_col225                                 varchar2_250_set_type;
6014        l_col226                                 varchar2_250_set_type;
6015        l_col227                                 varchar2_250_set_type;
6016        l_col228                                 varchar2_250_set_type;
6017 
6018 
6019        l_col229                                 varchar2_250_set_type;
6020        l_col230                                 varchar2_250_set_type;
6021        l_col231                                 varchar2_250_set_type;
6022        l_col232                                 varchar2_250_set_type;
6023        l_col233                                 varchar2_250_set_type;
6024        l_col234                                 varchar2_250_set_type;
6025        l_col235                                 varchar2_250_set_type;
6026        l_col236                                 varchar2_250_set_type;
6027        l_col237                                 varchar2_250_set_type;
6028        l_col238                                 varchar2_250_set_type;
6029 
6030 
6031 
6032 CURSOR c_lead_fields is
6033 SELECT
6034 import_source_line_id,
6035 import_list_header_id,
6036 DECODE(GREATEST(lengthb(LTRIM(RTRIM(source_system))),30) - 30,0,' ','SOURCE_SYSTEM :'||decode(nvl(source_system,'x'),'x',l_null_value,l_invalid_size)||'(30)') source_system,
6037 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LEAD_NOTE)),'x')),2000) - 2000,0,' ','LEAD_NOTE :'||l_invalid_size||'(2000)') LEAD_NOTE,
6038 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROMOTION_CODE)),'x')),50) - 50,0,' ','PROMOTION_CODE :'||l_invalid_size||'(50)') PROMOTION_CODE,
6039 DECODE(GREATEST(lengthb(LTRIM(RTRIM(CUSTOMER_NAME))),255) - 255,0,' ','CUSTOMER_NAME :'||l_invalid_size||'(255)') CUSTOMER_NAME,
6040 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE)),'x')),30) - 30,0,' ','SIC_CODE :'||l_invalid_size||'(30)') SIC_CODE,
6041 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ANALYSIS_FY)),'x')),5) - 5,0,' ','ANALYSIS_FY :'||l_invalid_size||'(5)') ANALYSIS_FY,
6042 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CUSTOMER_CATEGORY_CODE)),'x')),30) -30,0,' ','CUSTOMER_CATEGORY_CODE:'||l_invalid_size||'(30)') CUSTOMER_CATEGORY_CODE,
6043 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FISCAL_YEAREND_MONTH)),'x')),30) - 30,0,' ','FISCAL_YEAREND_MONTH :'||l_invalid_size||'(30)') FISCAL_YEAREND_MONTH,
6044 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(num_of_employees,' ','x'))),'0123456789.','           x'))),0),0,' ','NUM_OF_EMPLOYEES :'||l_invalid_number) NUM_OF_EMPLOYE,
6045 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(POTENTIAL_REVENUE_CURR_FY,' ','x'))),'0123456789.','           x'))),0),0,' ','POTENTIAL_REVENUE_CURR_FY :'||l_invalid_number) POTENTIAL_REVENUE_CURR_FY,
6046 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(POTENTIAL_REVENUE_NEXT_FY,' ','x'))),'0123456789.','           x'))),0),0,' ','POTENTIAL_REVENUE_NEXT_FY :'||l_invalid_number) POTENTIAL_REVENUE_CURR_FY,
6047 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CUSTOMER_RANK)),'x')),30) - 30,0,' ','CUSTOMER_RANK :'||l_invalid_size||'(30)') CUSTOMER_RANK,
6048 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),50) - 50,0,' ','TAX_REFERENCE :'||l_invalid_size||'(50)') TAX_REFERENCE,
6049 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(YEAR_ESTABLISHED,' ','x'))),'0123456789.','           x'))),0),0,' ','YEAR_ESTABLISHED :'||l_invalid_number) YEAR_ESTABLISHED,
6050 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDR_DO_NOT_MAIL_FLAG)),'x')),1) - 1,0,' ','ADDR_DO_NOT_MAIL_FLAG :'||l_invalid_size||'(1)') ADDR_DO_NOT_MAIL_FLAG,
6051 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URL)),'x')),2000) - 2000,0,' ','URL :'||l_invalid_size) URL,
6052 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONT_DO_NOT_MAIL_FLAG)),'x')),1) - 1,0,' ','CONT_DO_NOT_MAIL_FLAG :'||l_invalid_size||'(1)') CONT_DO_NOT_MAIL_FLAG,
6053 DECODE(GREATEST(lengthb(LTRIM(RTRIM(COUNTRY))),60) - 60,0,' ','COUNTRY :'||decode(nvl(COUNTRY,'x'),'x',l_null_value,l_invalid_size)||'(60)') COUNTRY,
6054 DECODE(GREATEST(lengthb(LTRIM(RTRIM(ADDRESS1))),240) - 240,0,' ','ADDRESS1 :'||decode(nvl(ADDRESS1,'x'),'x',l_null_value,l_invalid_size)||'(240)') ADDRESS1,
6055 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,' ','ADDRESS2 :'||l_invalid_size||'(240)') ADDRESS2,
6056 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,' ','ADDRESS3 :'||l_invalid_size||'(240)') ADDRESS3,
6057 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,' ','ADDRESS4 :'||l_invalid_size||'(240)') ADDRESS4,
6058 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,' ','CITY :'||l_invalid_size||'(60)') CITY ,
6059 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,' ','POSTAL_CODE :'||l_invalid_size||'(60)') POSTAL_CODE,
6060 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,' ','STATE :'||l_invalid_size||'(60)') STATE,
6061 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,' ','PROVINCE :'||l_invalid_size||'(60)') PROVINCE,
6062 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,' ','COUNTY :'||l_invalid_size||'(60)') COUNTY,
6063 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,' ','EMAIL_ADDRESS :'||l_invalid_size||'(240)') EMAIL_ADDRESS,
6064 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SEX_CODE)),'x')),30) - 30,0,' ','SEX_CODE :'||l_invalid_size||'(30)') SEX_CODE,
6065 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALUTATION)),'x')),60) - 60,0,' ','SALUTATION :'||l_invalid_size||'(60)') SALUTATION,
6066 DECODE(GREATEST(lengthb(LTRIM(RTRIM(LAST_NAME))),50) - 50,0,' ','LAST_NAME :'||decode(nvl(LAST_NAME,'x'),'x',l_null_value,l_invalid_size)||'(50)') LAST_NAME,
6067 DECODE(GREATEST(lengthb(LTRIM(RTRIM(FIRST_NAME))),40) - 40,0,' ','FIRST_NAME :'||decode(nvl(FIRST_NAME,'x'),'x',l_null_value,l_invalid_size)||'(40)') FIRST_NAME,
6068 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TITLE)),'x')),40) - 40,0,' ','TITLE :'||l_invalid_size||'(40)') TITLE,
6069 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE)),'x')),100) - 100,0,' ','JOB_TITLE :'||l_invalid_size||'(100)') JOB_TITLE,
6070 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,' ','PHONE_NUMBER :'||l_invalid_size||'(25)') PHONE_NUMBER,
6071 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_STATUS)),'x')),1) - 1,0,' ','PHONE_STATUS :'||l_invalid_size||'(1)') PHONE_STATUS,
6072 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_TYPE)),'x')),30) - 30,0,' ','PHONE_TYPE :'||l_invalid_size||'(30)') PHONE_TYPE,
6073 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(AREA_CODE)),'x')),10) - 10,0,' ','AREA_CODE :'||l_invalid_size||'(10)') AREA_CODE,
6074 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EXTENSION)),'x')),20) - 20,0,' ','EXTENSION :'||l_invalid_size||'(20)') EXTENSION,
6075 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_INITIAL)),'x')),10) - 10,0,' ','MIDDLE_INITIAL :'||l_invalid_size||'(10)') MIDDLE_INITIAL,
6076 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE_CODE)),'x')),30) - 30,0,' ','JOB_TITLE_CODE :'||l_invalid_size||'(30)') JOB_TITLE_CODE,
6077 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MAIL_STOP)),'x')),60) - 60,0,' ','MAIL_STOP :'||l_invalid_size||'(60)') MAIL_STOP,
6078 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),25) - 25,0,' ','FAX_NUMBER:'||l_invalid_size||'(25)') FAX_NUMBER,
6079 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,' ','FAX_AREA_CODE :'||l_invalid_size||'(1)') FAX_AREA_CODE,
6080 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DO_NOT_PHONE_FLAG)),'x')),1) - 1,0,' ','DO_NOT_PHONE_FLAG :'||l_invalid_size||'(1)') DO_NOT_PHONE_FLAG,
6081 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DO_NOT_FAX_FLAG)),'x')),1) - 1,0,' ','DO_NOT_FAX_FLAG :'||l_invalid_size||'(1)') DO_NOT_FAX_FLAG,
6082 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DO_NOT_EMAIL_FLAG)),'x')),1) - 1,0,' ','DO_NOT_EMAIL_FLAG :'||l_invalid_size||'(1)') DO_NOT_EMAIL_FLAG,
6083 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URGENT_FLAG)),'x')),1) - 1,0,' ','URGENT_FLAG :'||l_invalid_size||'(1)') URGENT_FLAG,
6084 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ACCEPT_FLAG)),'x')),1) - 1,0,' ','ACCEPT_FLAG :'||l_invalid_size||'(1)') ACCEPT_FLAG,
6085 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DELETED_FLAG)),'x')),1) - 1,0,' ','DELETED_FLAG :'||l_invalid_size||'(1)') DELETED_FLAG,
6086 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(IMPORT_FLAG)),'x')),1) - 1,0,' ','IMPORT_FLAG :'||l_invalid_size||'(1)') IMPORT_FLAG,
6087 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KEEP_FLAG)),'x')),1) - 1,0,' ','KEEP_FLAG :'||l_invalid_size||'(1)') KEEP_FLAG,
6088 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(QUALIFIED_FLAG)),'x')),1) - 1,0,' ','QUALIFIED_FLAG :'||l_invalid_size||'(1)') QUALIFIED_FLAG,
6089 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRIMARY_CONTACT_FLAG)),'x')),1) - 1,0,' ','PRIMARY_CONTACT_FLAG :'||l_invalid_size||'(1)') PRIMARY_CONTACT_FLAG,
6090 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOC_VALIDATED_FLAG)),'x')),1) - 1,0,' ','LOC_VALIDATED_FLAG :'||l_invalid_size||'(1)') LOC_VALIDATED_FLAG,
6091 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GSA_INDICATOR_FLAG)),'x')),1) - 1,0,' ','GSA_INDICATOR_FLAG :'||l_invalid_size||'(1)') GSA_INDICATOR_FLAG,
6092 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_REFERENCE_USE_FLAG)),'x')),1) - 1,0,' ','PARTY_REFERENCE_USE_FLAG :'||l_invalid_size||'(1)') PARTY_REFERENCE_USE_FLAG,
6093 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTIES_VALIDATED_FLAG)),'x')),1) - 1,0,' ','PARTIES_VALIDATED_FLAG:'||l_invalid_size||'(1)') PARTIES_VALIDATED_FLAG,
6094 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,' ','DECISION_MAKER_FLAG :'||l_invalid_size||'(1)') DECISION_MAKER_FLAG,
6095 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_EXEC_SPONSOR_FLAG)),'x')),1) - 1,0,' ','PRM_EXEC_SPONSOR_FLAG :'||l_invalid_size||'(1)') PRM_EXEC_SPONSOR_FLAG,
6096 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_PRJ_LEAD_IN_PLACE_FLAG)),'x')),1) - 1,0,' ','PRM_PRJ_LEAD_IN_PLACE_FLAG :'||l_invalid_size||'(1)') PRM_PRJ_LEAD_IN_PLACE_FLAG,
6097 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_PARTY_FLAG)),'x')),1) - 1,0,' ','NEW_PARTY_FLAG :'||l_invalid_size||'(1)') NEW_PARTY_FLAG,
6098 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,' ','DECISION_MAKER_FLAG :'||l_invalid_size||'(1)') NEW_LOC_FLAG,
6099 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_PS_FLAG)),'x')),1) - 1,0,' ','NEW_PS_FLAG :'||l_invalid_size||'(1)') NEW_PS_FLAG,
6100 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_REL_FLAG)),'x')),1) - 1,0,' ','NEW_REL_FLAG :'||l_invalid_size||'(1)') NEW_REL_FLAG,
6101 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_CON_FLAG)),'x')),1) - 1,0,' ','NEW_CON_FLAG :'||l_invalid_size||'(1)') NEW_CON_FLAG,
6102 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTACT_ROLE_CODE)),'x')),30) - 30,0,' ','CONTACT_ROLE_CODE :'||l_invalid_size||'(30)') CONTACT_ROLE_CODE,
6103 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CHANNEL_CODE)),'x')),30) - 30,0,' ','CHANNEL_CODE :'||l_invalid_size||'(30)') CHANNEL_CODE,
6104 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUDGET_STATUS_CODE)),'x')),30) - 30,0,' ','BUDGET_STATUS_CODE :'||l_invalid_size||'(30)') BUDGET_STATUS_CODE,
6105 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_TIMEFRAME_CODE)),'x')),30) - 30,0,' ','DECISION_TIMEFRAME_CODE :'||l_invalid_size||'(30)') DECISION_TIMEFRAME_CODE,
6106 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CURRENCY_CODE)),'x')),15) - 15,0,' ','CURRENCY_CODE :'||l_invalid_size||'(15)') CURRENCY_CODE,
6107 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,' ','VEHICLE_RESPONSE_CODE :'||l_invalid_size||'(30)') VEHICLE_RESPONSE_CODE,
6108 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_1)),'x')),3) - 3,0,' ','UOM_CODE_1 :'||l_invalid_size||'(3)') UOM_CODE_1,
6109 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_2)),'x')),3) - 3,0,' ','UOM_CODE_2 :'||l_invalid_size||'(3)') UOM_CODE_2,
6110 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_3)),'x')),3) - 3,0,' ','UOM_CODE_3 :'||l_invalid_size||'(3)') UOM_CODE_3,
6111 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_4)),'x')),3) - 3,0,' ','UOM_CODE_4 :'||l_invalid_size||'(3)') UOM_CODE_4,
6112 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_5)),'x')),3) - 3,0,' ','UOM_CODE_5 :'||l_invalid_size||'(3)') UOM_CODE_5,
6113 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS)),'x')),240) - 240,0,' ','KNOWN_AS :'||l_invalid_size||'(3)') KNOWN_AS,
6114 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS2)),'x')),240) - 240,0,' ','KNOWN_AS2 :'||l_invalid_size||'(240)') KNOWN_AS2,
6115 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS3)),'x')),240) - 240,0,' ','KNOWN_AS3 :'||l_invalid_size||'(240)') KNOWN_AS3,
6116 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS4)),'x')),240) - 240,0,' ','KNOWN_AS4 :'||l_invalid_size||'(240)') KNOWN_AS4,
6117 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS5)),'x')),240) - 240,0,' ','KNOWN_AS5 :'||l_invalid_size||'(240)') KNOWN_AS5,
6118 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','INTEREST_TYPE_ID_1 :'||l_invalid_number) INTEREST_TYPE_ID_1,
6119 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','INTEREST_TYPE_ID_2 :'||l_invalid_number) INTEREST_TYPE_ID_2,
6120 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','INTEREST_TYPE_ID_3 :'||l_invalid_number) INTEREST_TYPE_ID_3,
6121 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','INTEREST_TYPE_ID_4 :'||l_invalid_number) INTEREST_TYPE_ID_4,
6122 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','INTEREST_TYPE_ID_5 :'||l_invalid_number) INTEREST_TYPE_ID_5,
6123 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','PRIMARY_INTEREST_CODE_ID_1 :'||l_invalid_number) PRIMARY_INTEREST_CODE_ID_1,
6124 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','PRIMARY_INTEREST_CODE_ID_2 :'||l_invalid_number) PRIMARY_INTEREST_CODE_ID_2,
6125 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','PRIMARY_INTEREST_CODE_ID_3 :'||l_invalid_number) PRIMARY_INTEREST_CODE_ID_3,
6126 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','PRIMARY_INTEREST_CODE_ID_4 :'||l_invalid_number) PRIMARY_INTEREST_CODE_ID_4,
6127 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','PRIMARY_INTEREST_CODE_ID_5 :'||l_invalid_number) PRIMARY_INTEREST_CODE_ID_5,
6128 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','SECONDARY_INTEREST_CODE_ID_1 :'||l_invalid_number) SECONDARY_INTEREST_CODE_ID_1,
6129 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','SECONDARY_INTEREST_CODE_ID_2 :'||l_invalid_number) SECONDARY_INTEREST_CODE_ID_2,
6130 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','SECONDARY_INTEREST_CODE_ID_3 :'||l_invalid_number) SECONDARY_INTEREST_CODE_ID_3,
6131 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','SECONDARY_INTEREST_CODE_ID_4 :'||l_invalid_number) SECONDARY_INTEREST_CODE_ID_4,
6132 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','SECONDARY_INTEREST_CODE_ID_5 :'||l_invalid_number) SECONDARY_INTEREST_CODE_ID_5,
6133 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','INVENTORY_ITEM_ID_1 :'||l_invalid_number) INVENTORY_ITEM_ID_1,
6134 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','INVENTORY_ITEM_ID_2 :'||l_invalid_number) INVENTORY_ITEM_ID_2,
6135 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','INVENTORY_ITEM_ID_3 :'||l_invalid_number) INVENTORY_ITEM_ID_3,
6136 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','INVENTORY_ITEM_ID_4 :'||l_invalid_number) INVENTORY_ITEM_ID_4,
6137 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','INVENTORY_ITEM_ID_5 :'||l_invalid_number) INVENTORY_ITEM_ID_5,
6138 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','ORGANIZATION_ID_1 :'||l_invalid_number) ORGANIZATION_ID_1,
6139 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','ORGANIZATION_ID_2 :'||l_invalid_number) ORGANIZATION_ID_2,
6140 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','ORGANIZATION_ID_3 :'||l_invalid_number) ORGANIZATION_ID_3,
6141 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','ORGANIZATION_ID_4 :'||l_invalid_number) ORGANIZATION_ID_4,
6142 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','ORGANIZATION_ID_5 :'||l_invalid_number) ORGANIZATION_ID_5,
6143 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_1,' ','x'))),'0123456789.','           x'))),0),0,' ','BUDGET_AMOUNT_1 :'||l_invalid_number) BUDGET_AMOUNT_1,
6144 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_2,' ','x'))),'0123456789.','           x'))),0),0,' ','BUDGET_AMOUNT_2 :'||l_invalid_number) BUDGET_AMOUNT_2,
6145 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_3,' ','x'))),'0123456789.','           x'))),0),0,' ','BUDGET_AMOUNT_3 :'||l_invalid_number) BUDGET_AMOUNT_3,
6146 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_4,' ','x'))),'0123456789.','           x'))),0),0,' ','BUDGET_AMOUNT_4 :'||l_invalid_number) BUDGET_AMOUNT_4,
6147 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_5,' ','x'))),'0123456789.','           x'))),0),0,' ','BUDGET_AMOUNT_5 :'||l_invalid_number) BUDGET_AMOUNT_5,
6148 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT,' ','x'))),'0123456789.','           x'))),0),0,' ','BUDGET_AMOUNT :'||l_invalid_number) BUDGET_AMOUNT,
6149 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_1,' ','x'))),'0123456789.','           x'))),0),0,' ','QUANTITY_1:'||l_invalid_number) QUANTITY_1,
6150 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_2,' ','x'))),'0123456789.','           x'))),0),0,' ','QUANTITY_2:'||l_invalid_number) QUANTITY_2,
6151 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_3,' ','x'))),'0123456789.','           x'))),0),0,' ','QUANTITY_3:'||l_invalid_number) QUANTITY_3,
6152 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_4,' ','x'))),'0123456789.','           x'))),0),0,' ','QUANTITY_4:'||l_invalid_number) QUANTITY_4,
6153 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_5,' ','x'))),'0123456789.','           x'))),0),0,' ','QUANTITY_5:'||l_invalid_number) QUANTITY_5,
6154 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','SOURCE_PROMOTION_ID_1 :'||l_invalid_number) SOURCE_PROMOTION_ID_1,
6155 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','SOURCE_PROMOTION_ID_2 :'||l_invalid_number) SOURCE_PROMOTION_ID_2,
6156 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','SOURCE_PROMOTION_ID_3 :'||l_invalid_number) SOURCE_PROMOTION_ID_3,
6157 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','SOURCE_PROMOTION_ID_4 :'||l_invalid_number) SOURCE_PROMOTION_ID_4,
6158 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','SOURCE_PROMOTION_ID_5 :'||l_invalid_number) SOURCE_PROMOTION_ID_5,
6159 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','OFFER_ID_1 :'||l_invalid_number) OFFER_ID_1,
6160 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','OFFER_ID_2 :'||l_invalid_number) OFFER_ID_2,
6161 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','OFFER_ID_3 :'||l_invalid_number) OFFER_ID_3,
6162 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','OFFER_ID_4 :'||l_invalid_number) OFFER_ID_4,
6163 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','OFFER_ID_5 :'||l_invalid_number) OFFER_ID_5,
6164 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ASSIGN_SALES_GROUP_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','ASSIGN_SALES_GROUP_ID :'||l_invalid_number) ASSIGN_SALES_GROUP_ID,
6165 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ASSIGN_TO_PERSON_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','ASSIGN_TO_PERSON_ID :'||l_invalid_number) ASSIGN_TO_PERSON_ID,
6166 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ASSIGN_TO_SALESFORCE_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','ASSIGN_TO_SALESFORCE_ID :'||l_invalid_number) ASSIGN_TO_SALESFORCE_ID,
6167 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SCORECARD_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','SCORECARD_ID :'||l_invalid_number) SCORECARD_ID,
6168 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(LOC_HIERARCHY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','LOC_HIERARCHY_ID :'||l_invalid_number) LOC_HIERARCHY_ID,
6169 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(FA_LOCATION_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','FA_LOCATION_ID :'||l_invalid_number) FA_LOCATION_ID,
6170 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PROMOTION_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','PROMOTION_ID :'||l_invalid_number) PROMOTION_ID,
6171 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','OFFER_ID :'||l_invalid_number) OFFER_ID,
6172 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REQUEST_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','REQUEST_ID :'||l_invalid_number) REQUEST_ID,
6173 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PROGRAM_APPLICATION_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','PROGRAM_APPLICATION_ID :'||l_invalid_number) PROGRAM_APPLICATION_ID,
6174 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PROGRAM_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','PROGRAM_ID :'||l_invalid_number) PROGRAM_ID,
6175 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PHONE_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','PHONE_ID :'||l_invalid_number) PHONE_ID,
6176 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CONTACT_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','CONTACT_PARTY_ID :'||l_invalid_number) CONTACT_PARTY_ID,
6177 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECURITY_GROUP_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','SECURITY_GROUP_ID :'||l_invalid_number) SECURITY_GROUP_ID,
6178 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INCUMBENT_PARTNER_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','INCUMBENT_PARTNER_PARTY_ID :'||l_invalid_number) INCUMBENT_PARTNER_PARTY_ID,
6179 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INCUMBENT_PARTNER_RESOURCE_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','INCUMBENT_PARTNER_RESOURCE_ID :'||l_invalid_number) INCUMBENT_PARTNER_RESOURCE_ID,
6180 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','PARTY_ID :'||l_invalid_number) PARTY_ID,
6181 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PARTY_SITE_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','PARTY_SITE_ID :'||l_invalid_number) PARTY_SITE_ID,
6182 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(LOCATION_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','LOCATION_ID :'||l_invalid_number) LOCATION_ID,
6183 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REL_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','REL_PARTY_ID :'||l_invalid_number) REL_PARTY_ID,
6184 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SALES_LEAD_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','SALES_LEAD_ID :'||l_invalid_number) SALES_LEAD_ID,
6185 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(LEAD_RANK_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','LEAD_RANK_ID :'||l_invalid_number) LEAD_RANK_ID,
6186 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_ORDERED_AMOUNT,' ','x'))),'0123456789.','           x'))),0),0,' ','TOTAL_ORDERED_AMOUNT :'||l_invalid_number) TOTAL_ORDERED_AMOUNT,
6187 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_NUM_OF_ORDERS,' ','x'))),'0123456789.','           x'))),0),0,' ','TOTAL_NUM_OF_ORDERS :'||l_invalid_number) TOTAL_NUM_OF_ORDERS,
6188 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(NET_WORTH,' ','x'))),'0123456789.','           x'))),0),0,' ','NET_WORTH :'||l_invalid_number) NET_WORTH,
6189 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CUSTOMER_KEY)),'x')),500) - 500,0,' ','CUSTOMER_KEY :'||l_invalid_size||'(500)') CUSTOMER_KEY,
6190 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_KEY)),'x')),500) - 500,0,' ','ADDRESS_KEY :'||l_invalid_size||'(500)') ADDRESS_KEY,
6191 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTACT_KEY)),'x')),80) - 80,0,' ','CONTACT_KEY :'||l_invalid_size||'(80)') CONTACT_KEY,
6192 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CLOSE_REASON)),'x')),30) - 30,0,' ','CLOSE_REASON :'||l_invalid_size||'(30)') CLOSE_REASON,
6193 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARENT_PROJECT)),'x')),80) - 80,0,' ','PARENT_PROJECT :'||l_invalid_size||'(80)') PARENT_PROJECT,
6194 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION :'||l_invalid_size||'(2000)') DESCRIPTION,
6195 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) -240,0,' ','ORIG_SYSTEM_REFERENCE :'||l_invalid_size||'(240)') ORIG_SYSTEM_REFERENCE,
6196 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIG_SYSTEM_CODE)),'x')),30) - 30,0,' ','ORIG_SYSTEM_CODE :'||l_invalid_size||'(30)') ORIG_SYSTEM_CODE,
6197 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(AUTO_ASSIGNMENT_TYPE)),'x')),30) - 30,0,' ','AUTO_ASSIGNMENT_TYPE :'||l_invalid_size||'(30)') AUTO_ASSIGNMENT_TYPE,
6198 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_ASSIGNMENT_TYPE)),'x')),30) - 30,0,' ','PRM_ASSIGNMENT_TYPE :'||l_invalid_size||'(30)') PRM_ASSIGNMENT_TYPE,
6199 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REJECT_REASON_CODE)),'x')),30) - 30,0,' ','REJECT_REASON_CODE :'||l_invalid_size||'(30)') REJECT_REASON_CODE,
6200 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_STYLE)),'x')),30) - 30,0,' ','ADDRESS_STYLE :'||l_invalid_size||'(30)') ADDRESS_STYLE,
6201 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,' ','ADDRESS_LINES_PHONETIC :'||l_invalid_size||'(560)') ADDRESS_LINES_PHONETIC,
6202 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTENT_SOURCE_TYPE)),'x')),30) - 30,0,' ','CONTENT_SOURCE_TYPE :'||l_invalid_size||'(30)') CONTENT_SOURCE_TYPE,
6203 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOC_DESCRIPTION)),'x')),2000) - 2000,0,' ','LOC_DESCRIPTION :'||l_invalid_size||'(2000)') LOC_DESCRIPTION,
6204 -- bug 4641591: columns obsolete
6205 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,' ','FLOOR :'||l_invalid_size||'(50)') FLOOR,
6206 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,' ','HOUSE_NUMBER :'||l_invalid_size||'(50)') HOUSE_NUMBER,
6207 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,' ','PO_BOX_NUMBER :'||l_invalid_size||'(50)') PO_BOX_NUMBER,
6208 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_POSITION)),'x')),50) - 50,0,' ','LOCATION_POSITION :'||l_invalid_size||'(50)') LOCATION_POSITION,
6209 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LANGUAGE)),'x')),4) - 4,0,' ','LANGUAGE :'||l_invalid_size||'(4)') LANGUAGE,
6210 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,' ','LOCATION_DIRECTIONS :'||l_invalid_size||'(640)') LOCATION_DIRECTIONS,
6211 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),10) - 10,0,' ','POSTAL_PLUS4_CODE :'||l_invalid_size||'(10)') POSTAL_PLUS4_CODE,
6212 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALES_TAX_GEOCODE)),'x')),30) - 30,0,' ','SALES_TAX_GEOCODE :'||l_invalid_size||'(30)') SALES_TAX_GEOCODE,
6213 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALES_TAX_INSIDE_CITY_LIMITS)),'x')),30) - 30,0,' ','SALES_TAX_INSIDE_CITY_LIMITS :'||l_invalid_size||'(30)') SALES_TAX_INSIDE_CITY_LIMITS,
6214 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,' ','STREET :'||l_invalid_size||'(50)') STREET,
6215 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,' ','STREET_NUMBER :'||l_invalid_size||'(50)') STREET_NUMBER,
6216 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,' ','STREET_SUFFIX :'||l_invalid_size||'(50)') STREET_SUFFIX,
6217 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SUITE)),'x')),50) - 50,0,' ','SUITE :'||l_invalid_size||'(50)') SUITE,
6218 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,' ','TIME_ZONE :'||l_invalid_size||'(50)') TIME_ZONE,
6219 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) -240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,/*
6220 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DUNS_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,' ','DUNS_NUMBER :'||l_invalid_number) DUNS_NUMBER, */
6221 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DUNS_NUMBER)),'x')),30) - 30,0,' ','DUNS_NUMBER:'||l_invalid_size||'(30)') DUNS_NUMBER,
6222 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GROUP_TYPE)),'x')),30) - 30,0,' ','GROUP_TYPE :'||l_invalid_size||'(30)') GROUP_TYPE,
6223 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HQ_BRANCH_IND)),'x')),30) - 30,0,' ','HQ_BRANCH_IND :'||l_invalid_size||'(30)') HQ_BRANCH_IND,
6224 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JGZZ_FISCAL_CODE)),'x')),20) - 20,0,' ','JGZZ_FISCAL_CODE :'||l_invalid_size||'(20)') JGZZ_FISCAL_CODE,
6225 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LANGUAGE_NAME)),'x')),30) - 30,0,' ','LANGUAGE_NAME :'||l_invalid_size||'(30)') LANGUAGE_NAME,
6226 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_NUMBER)),'x')),30) - 30,0,' ','PARTY_NUMBER :'||l_invalid_size||'(30)') PARTY_NUMBER,
6227 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MISSION_STATEMENT)),'x')),2000) - 2000,0,' ','MISSION_STATEMENT :'||l_invalid_size||'(2000)') MISSION_STATEMENT,
6228 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_NAME_PHONETIC)),'x')),320) - 320,0,' ','ORGANIZATION_NAME_PHONETIC :'||l_invalid_size||'(320)') ORGANIZATION_NAME_PHONETIC,
6229 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_FIRST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_FIRST_NAME_PHONETIC,
6230 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_IDENTIFIER)),'x')),60) - 60,0,' ','PERSON_IDENTIFIER :'||l_invalid_size||'(60)') PERSON_IDENTIFIER,
6231 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_LAST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_LAST_NAME_PHONETIC,
6232 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_NAME)),'x')),60) - 60,0,' ','TAX_NAME :'||l_invalid_size||'(60)') TAX_NAME,
6233 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_IDEN_TYPE)),'x')),30) - 30,0,' ','PERSON_IDEN_TYPE :'||l_invalid_size||'(30)') PERSON_IDEN_TYPE,
6234 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,' ','PERSON_NAME_SUFFIX :'||l_invalid_size||'(30)') PERSON_NAME_SUFFIX,
6235 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE_TYPE)),'x')),30) - 30,0,' ','SIC_CODE_TYPE :'||l_invalid_size||'(30)') SIC_CODE_TYPE,
6236 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_LAST_NAME)),'x')),150) - 150,0,' ','PERSON_PREVIOUS_LAST_NAME :'||l_invalid_size||'(150)') PERSON_PREVIOUS_LAST_NAME,
6237 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_IND_CLASSIFICATION_CODE)),'x')),30) - 30,0,' ','PRM_IND_CLASSIFICATION_CODE :'||l_invalid_size||'(30)') PRM_IND_CLASSIFICATION_CODE,
6238 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_TYPE)),'x')),30) - 30,0,' ','PARTY_TYPE :'||l_invalid_size||'(30)') PARTY_TYPE,
6239 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LEAD_NUMBER)),'x')),30) - 30,0,' ','LEAD_NUMBER :'||l_invalid_size||'(30)') LEAD_NUMBER,
6240 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_SALES_LEAD_TYPE)),'x')),30) - 30,0,' ','PRM_SALES_LEAD_TYPE :'||l_invalid_size||'(30)') PRM_SALES_LEAD_TYPE,
6241 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT_CODE)),'x')),30) - 30,0,' ','DEPARTMENT_CODE :'||l_invalid_size||'(30)') DEPARTMENT_CODE,
6242 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RANK)),'x')),30) - 30,0,' ','RANK :'||l_invalid_size||'(30)') RANK,
6243 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ROLE_LEVEL)),'x')),30) - 30,0,' ','ROLE_LEVEL :'||l_invalid_size||'(30)') ROLE_LEVEL,
6244 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CNT_PNT_CONTENT_SOURCE_TYPE)),'x')),30) - 30,0,' ','CNT_PNT_CONTENT_SOURCE_TYPE :'||l_invalid_size||'(30)') CNT_PNT_CONTENT_SOURCE_TYPE,
6245 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,' ','PHONE_COUNTRY_CODE :'||l_invalid_size||'(30)') PHONE_COUNTRY_CODE,
6246 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),30) - 30,0,' ','FAX_COUNTRY_CODE :'||l_invalid_size||'(30)') FAX_COUNTRY_CODE,
6247 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_CALLING_CALENDAR)),'x')),30) - 30,0,' ','PHONE_CALLING_CALENDAR :'||l_invalid_size||'(30)') PHONE_CALLING_CALENDAR,
6248 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_FORMAT)),'x')),30) - 30,0,' ','EMAIL_FORMAT :'||l_invalid_size||'(30)') EMAIL_FORMAT,
6249 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CNT_TITLE)),'x')),30) - 30,0,' ','ORG_CNT_TITLE :'||l_invalid_size||'(30)') ORG_CNT_TITLE,
6250 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CNT_PNT_TIME_ZONE,' ','x'))),'0123456789.','           x'))),0),0,' ','CNT_PNT_TIME_ZONE :'||l_invalid_number) CNT_PNT_TIME_ZONE,
6251 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RAW_PHONE_NUMBER)),'x')),60) - 60,0,' ','RAW_PHONE_NUMBER :'||l_invalid_size||'(60)') RAW_PHONE_NUMBER,
6252 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_EXTENSION)),'x')),20) - 20,0,' ','FAX_EXTENSION :'||l_invalid_size||'(20)') FAX_EXTENSION,
6253 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT)),'x')),60) - 60,0,' ','DEPARTMENT :'||l_invalid_size||'(60)') DEPARTMENT,
6254 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRIMARY_CONTACT_PER_ROLE_TYPE)),'x')),1) - 1,0,' ','PRIMARY_CONTACT_PER_ROLE_TYPE :'||l_invalid_size||'(1)') PRIMARY_CONTACT_PER_ROLE_TYPE,
6255 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRIMARY_PER_TYPE)),'x')),1) - 1,0,' ','PRIMARY_PER_TYPE :'||l_invalid_size||'(1)') PRIMARY_PER_TYPE,
6256 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_USES_COMMENTS)),'x')),240) - 240,0,' ','PS_USES_COMMENTS :'||l_invalid_size||'(240)') PS_USES_COMMENTS,
6257 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_SITE_NAME)),'x')),240) - 240,0,' ','PARTY_SITE_NAME :'||l_invalid_size||'(240)') PARTY_SITE_NAME,
6258 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CNT_COMMENTS)),'x')),240) - 240,0,' ','ORG_CNT_COMMENTS :'||l_invalid_size||'(240)') ORG_CNT_COMMENTS,
6259 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SITE_USE_TYPE)),'x')),30) - 30,0,' ','SITE_USE_TYPE :'||l_invalid_size||'(30)') SITE_USE_TYPE,
6260 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_SITE_NUMBER)),'x')),30) - 30,0,' ','PARTY_SITE_NUMBER :'||l_invalid_size||'(30)') PARTY_SITE_NUMBER,
6261 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTACT_NUMBER)),'x')),30) - 30,0,' ','CONTACT_NUMBER :'||l_invalid_size||'(30)') CONTACT_NUMBER,
6262 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESSEE)),'x')),360) - 360,0,' ','ADDRESSEE :'||l_invalid_size||'(360)') ADDRESSEE,
6263 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MAILSTOP)),'x')),60) - 60,0,' ','MAILSTOP :'||l_invalid_size||'(60)') MAILSTOP,
6264 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(MARKETING_SCORE,' ','x'))),'0123456789.','           x'))),0),0,' ','MARKETING_SCORE :'||l_invalid_number) MARKETING_SCORE,
6265 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_INITIALS)),'x')),6) - 6,0,' ','PERSON_INITIALS :'||l_invalid_size||'(6)') PERSON_INITIALS,
6266 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_1,' ','x'))),'0123456789.','           x'))),0),0,' ','CATEGORY_ID_1 :'||l_invalid_number) CATEGORY_ID_1,
6267 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_2,' ','x'))),'0123456789.','           x'))),0),0,' ','CATEGORY_ID_2 :'||l_invalid_number) CATEGORY_ID_2,
6268 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_3,' ','x'))),'0123456789.','           x'))),0),0,' ','CATEGORY_ID_3 :'||l_invalid_number) CATEGORY_ID_3,
6269 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_4,' ','x'))),'0123456789.','           x'))),0),0,' ','CATEGORY_ID_4 :'||l_invalid_number) CATEGORY_ID_4,
6270 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_5,' ','x'))),'0123456789.','           x'))),0),0,' ','CATEGORY_ID_5 :'||l_invalid_number) CATEGORY_ID_5,
6271 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SALES_METHODOLOGY_ID,' ','x'))),'0123456789.','
6272 x'))),0),0,' ','SALES_METHODOLOGY_ID :'||l_invalid_number) SALES_METHODOLOGY_ID,
6273 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DUNS_NUMBER_C)),'x')),30) - 30,0,' ','DUNS_NUMBER_C :'||l_invalid_size||'(30)') DUNS_NUMBER_C,
6274 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SOURCE_PRIMARY_REFERENCE)),'x')),30) - 30,0,' ','SOURCE_PRIMARY_REFERENCE :'||l_invalid_size||'(30)') SOURCE_PRIMARY_REFERENCE,
6275 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SOURCE_SECONDARY_REFERENCE)),'x')),30) - 30,0,' ','SOURCE_SECONDARY_REFERENCE :'||l_invalid_size||'(30)') SOURCE_SECONDARY_REFERENCE,
6276 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NOTE_TYPE)),'x')),30) - 30,0,' ','NOTE_TYPE :'||l_invalid_size||'(30)')
6277 NOTE_TYPE
6278 FROM ams_lead_mapping_v
6279 WHERE import_list_header_id = p_import_list_header_id
6280   and load_status in ('ACTIVE','RELOAD')
6281   and
6282 (
6283   DECODE(GREATEST(lengthb(LTRIM(RTRIM(source_system))),30) - 30,0,'OK','NO') = 'NO'
6284 or
6285   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LEAD_NOTE)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
6286 or
6287   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROMOTION_CODE)),'x')),50) - 50,0,'OK','NO') = 'NO'
6288 or
6289   DECODE(GREATEST(lengthb(LTRIM(RTRIM(CUSTOMER_NAME))),255) - 255,0,'OK','NO') = 'NO'
6290 or
6291   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6292 or
6293   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ANALYSIS_FY)),'x')),5) - 5,0,'OK','NO') = 'NO'
6294 or
6295   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CUSTOMER_CATEGORY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6296 or
6297   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DUNS_NUMBER_C)),'x')),30) - 30,0,'OK','NO') = 'NO'
6298 or
6299   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SOURCE_PRIMARY_REFERENCE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6300 or
6301   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SOURCE_SECONDARY_REFERENCE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6302 or
6303   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NOTE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6304 or
6305 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6306  or
6307 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6308 or
6309 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6310 or
6311 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6312 or
6313 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CATEGORY_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6314 or
6315 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SALES_METHODOLOGY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6316 or
6317 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FISCAL_YEAREND_MONTH)),'x')),30) - 30,0,'OK','NO') = 'NO'
6318 or
6319 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(num_of_employees,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6320 or
6321 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(POTENTIAL_REVENUE_CURR_FY,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6322 or
6323 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(POTENTIAL_REVENUE_NEXT_FY,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6324 or
6325   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CUSTOMER_RANK)),'x')),30) - 30,0,'OK','NO') = 'NO'
6326 or
6327   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),50) - 50,0,'OK','NO') = 'NO'
6328 or
6329 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(YEAR_ESTABLISHED,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6330 or
6331   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDR_DO_NOT_MAIL_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6332 or
6333   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
6334 or
6335   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONT_DO_NOT_MAIL_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6336 or
6337   DECODE(GREATEST(lengthb(LTRIM(RTRIM(COUNTRY))),60) - 60,0,'OK','NO') = 'NO'
6338 or
6339   DECODE(GREATEST(lengthb(LTRIM(RTRIM(ADDRESS1))),240) - 240,0,'OK','NO') = 'NO'
6340 or
6341   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
6342 or
6343   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
6344 or
6345   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
6346 or
6347   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
6348 or
6349   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
6350 or
6351   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
6352 or
6353   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
6354 or
6355   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
6356 or
6357   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
6358 or
6359   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SEX_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6360 or
6361   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALUTATION)),'x')),60) - 60,0,'OK','NO') = 'NO'
6362 or
6363   DECODE(GREATEST(lengthb(LTRIM(RTRIM(LAST_NAME))),50) - 50,0,'OK','NO') = 'NO'
6364 or
6365   DECODE(GREATEST(lengthb(LTRIM(RTRIM(FIRST_NAME))),40) - 40,0,'OK','NO') = 'NO'
6366 or
6367   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TITLE)),'x')),40) - 40,0,'OK','NO') = 'NO'
6368 or
6369   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE)),'x')),100) - 100,0,'OK','NO') = 'NO'
6370 or
6371   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
6372 or
6373   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_STATUS)),'x')),1) - 1,0,'OK','NO') = 'NO'
6374 or
6375   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6376 or
6377   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
6378 or
6379   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EXTENSION)),'x')),20) - 20,0,'OK','NO') = 'NO'
6380 or
6381   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_INITIAL)),'x')),10) - 10,0,'OK','NO') = 'NO'
6382 or
6383   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6384 or
6385   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MAIL_STOP)),'x')),60) - 60,0,'OK','NO') = 'NO'
6386 or
6387   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
6388 or
6389   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
6390 or
6391   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DO_NOT_PHONE_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6392 or
6393   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DO_NOT_FAX_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6394 or
6395   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DO_NOT_EMAIL_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6396 or
6397   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URGENT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6398 or
6399   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ACCEPT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6400 or
6401   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DELETED_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6402 or
6403   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(IMPORT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6404 or
6405   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KEEP_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6406 or
6407   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(QUALIFIED_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6408 or
6409   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRIMARY_CONTACT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6410 or
6411   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOC_VALIDATED_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6412 or
6413   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GSA_INDICATOR_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6414 or
6415   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_REFERENCE_USE_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6416 or
6417   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTIES_VALIDATED_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6418 or
6419   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6420 or
6421   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_EXEC_SPONSOR_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6422 or
6423   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_PRJ_LEAD_IN_PLACE_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6424 or
6425   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_PARTY_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6426 or
6427   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_LOC_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6428 or
6429   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_PS_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6430 or
6431   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_REL_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6432 or
6433   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NEW_CON_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
6434 or
6435   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTACT_ROLE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6436 or
6437   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CHANNEL_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6438 or
6439   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUDGET_STATUS_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6440 or
6441   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_TIMEFRAME_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6442 or
6443   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CURRENCY_CODE)),'x')),15) - 15,0,'OK','NO') = 'NO'
6444 or
6445   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6446 or
6447   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_1)),'x')),3) - 3,0,'OK','NO') = 'NO'
6448 or
6449   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_2)),'x')),3) - 3,0,'OK','NO') = 'NO'
6450 or
6451   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_3)),'x')),3) - 3,0,'OK','NO') = 'NO'
6452 or
6453   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_4)),'x')),3) - 3,0,'OK','NO') = 'NO'
6454 or
6455   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(UOM_CODE_5)),'x')),3) - 3,0,'OK','NO') = 'NO'
6456 or
6457   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
6458 or
6459   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
6460 or
6461   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
6462 or
6463   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
6464 or
6465   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
6466 or
6467 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6468 or
6469 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6470 or
6471 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6472 or
6473 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6474 or
6475 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INTEREST_TYPE_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6476 or
6477 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6478 or
6479 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6480 or
6481 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6482 or
6483 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6484 or
6485 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PRIMARY_INTEREST_CODE_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6486 or
6487 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6488 or
6489 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6490 or
6491 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6492 or
6493 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6494 or
6495 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECONDARY_INTEREST_CODE_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6496 or
6497 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6498 or
6499 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6500 or
6501 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6502 or
6503 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6504 or
6505 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INVENTORY_ITEM_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6506 or
6507 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6508 or
6509 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6510 or
6511 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6512 or
6513 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6514 or
6515 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ORGANIZATION_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6516 or
6517 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6518 or
6519 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6520 or
6521 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6522 or
6523 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6524 or
6525 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6526 or
6527 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(BUDGET_AMOUNT,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6528 or
6529 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6530 or
6531 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6532 or
6533 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6534 or
6535 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6536 or
6537 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(QUANTITY_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6538 or
6539 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6540 or
6541 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6542 or
6543 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6544 or
6545 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6546 or
6547 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SOURCE_PROMOTION_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6548 or
6549 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_1,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6550 or
6551 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_2,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6552 or
6553 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_3,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6554 or
6555 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_4,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6556 or
6557 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID_5,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6558 or
6559 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ASSIGN_SALES_GROUP_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6560 or
6561 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ASSIGN_TO_PERSON_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6562 or
6563 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SCORECARD_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6564 or
6565 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(LOC_HIERARCHY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6566 or
6567 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(FA_LOCATION_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6568 or
6569 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PROMOTION_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6570 or
6571 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(OFFER_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6572 or
6573 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REQUEST_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6574 or
6575 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PROGRAM_APPLICATION_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6576 or
6577 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PROGRAM_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6578 or
6579 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PHONE_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6580 or
6581 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CONTACT_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6582 or
6583 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SECURITY_GROUP_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6584 or
6585 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INCUMBENT_PARTNER_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6586 or
6587 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(INCUMBENT_PARTNER_RESOURCE_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6588 or
6589 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6590 or
6591 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PARTY_SITE_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6592 or
6593 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(LOCATION_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6594 or
6595 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REL_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6596 or
6597 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(SALES_LEAD_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6598 or
6599 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(LEAD_RANK_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6600 or
6601 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_ORDERED_AMOUNT,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6602 or
6603 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_NUM_OF_ORDERS,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6604 or
6605 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(NET_WORTH,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6606 or
6607   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CUSTOMER_KEY)),'x')),500) - 500,0,'OK','NO') = 'NO'
6608 or
6609   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_KEY)),'x')),500) - 500,0,'OK','NO') = 'NO'
6610 or
6611   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTACT_KEY)),'x')),80) - 80,0,'OK','NO') = 'NO'
6612 or
6613   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CLOSE_REASON)),'x')),30) - 30,0,'OK','NO') = 'NO'
6614 or
6615   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARENT_PROJECT)),'x')),80) - 80,0,'OK','NO') = 'NO'
6616 or
6617   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
6618 or
6619   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,'OK','NO') = 'NO'
6620 or
6621   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIG_SYSTEM_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6622 or
6623   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(AUTO_ASSIGNMENT_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6624 or
6625   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_ASSIGNMENT_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6626 or
6627   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REJECT_REASON_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6628 or
6629   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_STYLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6630 or
6631   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,'OK','NO') = 'NO'
6632 or
6633   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTENT_SOURCE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6634 or
6635   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOC_DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
6636 or
6637 /*
6638   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,'OK','NO') = 'NO'
6639 or
6640   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
6641 or
6642   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
6643 or
6644 */
6645   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_POSITION)),'x')),50) - 50,0,'OK','NO') = 'NO'
6646 or
6647   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LANGUAGE)),'x')),4) - 4,0,'OK','NO') = 'NO'
6648 or
6649   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,'OK','NO') = 'NO'
6650 or
6651   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
6652 or
6653   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALES_TAX_GEOCODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6654 or
6655   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALES_TAX_INSIDE_CITY_LIMITS)),'x')),30) - 30,0,'OK','NO') = 'NO'
6656 or
6657 /*
6658   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,'OK','NO') = 'NO'
6659 or
6660   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
6661 or
6662   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,'OK','NO') = 'NO'
6663 or
6664   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SUITE)),'x')),50) - 50,0,'OK','NO') = 'NO'
6665 or
6666 */
6667   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,'OK','NO') = 'NO'
6668 or
6669   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,'OK','NO') = 'NO'
6670 /* or
6671 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DUNS_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6672 */
6673 or
6674   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DUNS_NUMBER)),'x')),30) - 30,0,'OK','NO') = 'NO'
6675 or
6676   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GROUP_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6677 or
6678   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HQ_BRANCH_IND)),'x')),30) - 30,0,'OK','NO') = 'NO'
6679 or
6680   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JGZZ_FISCAL_CODE)),'x')),20) - 20,0,'OK','NO') = 'NO'
6681 or
6682   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LANGUAGE_NAME)),'x')),30) - 30,0,'OK','NO') = 'NO'
6683 or
6684   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HQ_BRANCH_IND)),'x')),30) - 30,0,'OK','NO') = 'NO'
6685 or
6686   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MISSION_STATEMENT)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
6687 or
6688   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_NAME_PHONETIC)),'x')),320) - 320,0,'OK','NO') = 'NO'
6689 or
6690   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
6691 or
6692   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_IDENTIFIER)),'x')),60) - 60,0,'OK','NO') = 'NO'
6693 or
6694   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
6695 or
6696   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
6697 or
6698   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_IDEN_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6699 or
6700   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
6701 or
6702   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6703 or
6704   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_LAST_NAME)),'x')),150) - 150,0,'OK','NO') = 'NO'
6705 or
6706   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_IND_CLASSIFICATION_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6707 or
6708   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6709 or
6710   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LEAD_NUMBER)),'x')),30) - 30,0,'OK','NO') = 'NO'
6711 or
6712   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRM_SALES_LEAD_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6713 or
6714   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6715 or
6716   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RANK)),'x')),30) - 30,0,'OK','NO') = 'NO'
6717 or
6718   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ROLE_LEVEL)),'x')),30) - 30,0,'OK','NO') = 'NO'
6719 or
6720   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CNT_PNT_CONTENT_SOURCE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6721 or
6722   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6723 or
6724   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6725 or
6726   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_CALLING_CALENDAR)),'x')),30) - 30,0,'OK','NO') = 'NO'
6727 or
6728   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_FORMAT)),'x')),30) - 30,0,'OK','NO') = 'NO'
6729 or
6730   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CNT_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6731 or
6732 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CNT_PNT_TIME_ZONE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6733 or
6734   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RAW_PHONE_NUMBER)),'x')),60) - 60,0,'OK','NO') = 'NO'
6735 or
6736   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_EXTENSION)),'x')),20) - 20,0,'OK','NO') = 'NO'
6737 or
6738   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT)),'x')),60) - 60,0,'OK','NO') = 'NO'
6739 or
6740   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRIMARY_CONTACT_PER_ROLE_TYPE)),'x')),1) - 1,0,'OK','NO') = 'NO'
6741 or
6742   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRIMARY_PER_TYPE)),'x')),1) - 1,0,'OK','NO') = 'NO'
6743 or
6744   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_USES_COMMENTS)),'x')),240) - 240,0,'OK','NO') = 'NO'
6745 or
6746   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_SITE_NAME)),'x')),240) - 240,0,'OK','NO') = 'NO'
6747 or
6748   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CNT_COMMENTS)),'x')),240) - 240,0,'OK','NO') = 'NO'
6749 or
6750   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SITE_USE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
6751 or
6752   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PARTY_SITE_NUMBER)),'x')),30) - 30,0,'OK','NO') = 'NO'
6753 or
6754   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONTACT_NUMBER)),'x')),30) - 30,0,'OK','NO') = 'NO'
6755 or
6756   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESSEE)),'x')),360) - 360,0,'OK','NO') = 'NO'
6757 or
6758   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MAILSTOP)),'x')),60) - 60,0,'OK','NO') = 'NO'
6759 or
6760 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(MARKETING_SCORE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
6761 or
6762   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_INITIALS)),'x')),6) - 6,0,'OK','NO') = 'NO'
6763 )
6764 ;
6765 
6766 CURSOR c_lead_batch_id is
6767 SELECT
6768 batch_id
6769 FROM ams_imp_list_headers_all
6770 WHERE import_list_header_id = p_import_list_header_id;
6771 
6772 CURSOR c_lead_date_fields is
6773 SELECT
6774 import_list_header_id,
6775 import_source_line_id,
6776 assign_date,
6777 address_effective_date,
6778 last_ordered_date,
6779 program_update_date,
6780 lead_date
6781 FROM ams_lead_mapping_v
6782 WHERE import_list_header_id = p_import_list_header_id
6783   and load_status in ('ACTIVE','RELOAD')
6784   AND (assign_date is not null or address_effective_date is not null or
6785        last_ordered_date is not null or program_update_date is not null
6786        or lead_date is not null);
6787 
6788 CURSOR c_source_system is
6789 SELECT COUNT(*) total_rec, source_system FROM ams_lead_mapping_v
6790 WHERE import_list_header_id = p_import_list_header_id
6791 GROUP BY source_system ORDER BY COUNT(*) DESC;
6792 
6793 
6794 CURSOR c_invalid_src_sys is
6795 SELECT
6796 import_list_header_id,
6797 import_source_line_id
6798 FROM ams_lead_mapping_v
6799 WHERE import_list_header_id = p_import_list_header_id
6800   AND source_system <> l_source_system;
6801 
6802 cursor c_error_exists is
6803 select 'Y'
6804 from ams_list_import_errors
6805 where import_list_header_id = x_import_source_line_id
6806   and import_source_line_id = x_import_source_line_id
6807   and batch_id		    = l_batch_id;
6808 
6809 begin
6810 
6811         IF p_import_list_header_id IS NULL THEN
6812                 RAISE FND_API.G_EXC_ERROR;
6813         END IF;
6814     p_return_status := FND_API.G_RET_STS_SUCCESS;
6815 
6816     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_DATATYPE_ERROR_CHK');
6817     l_invalid_number := FND_MESSAGE.get;
6818     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_SIZE_ERROR_CHK');
6819     l_invalid_size := FND_MESSAGE.get;
6820     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_NULL_ERROR_CHK');
6821     l_null_value := FND_MESSAGE.get;
6822     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_SOUR_SYS_ERROR_CHK');
6823     l_invalid_src_system := FND_MESSAGE.get;
6824 
6825     OPEN c_lead_batch_id;
6826     FETCH c_lead_batch_id into l_batch_id;
6827     CLOSE c_lead_batch_id;
6828 
6829     OPEN c_lead_fields;
6830      LOOP
6831       FETCH c_lead_fields BULK COLLECT INTO
6832        l_import_source_line_id,
6833        l_import_list_header_id,
6834        l_col1                                  ,
6835        l_col2                                  ,
6836        l_col3                                  ,
6837        l_col4                                  ,
6838        l_col5                                  ,
6839        l_col6                                  ,
6840        l_col7                                  ,
6841        l_col8                                  ,
6842        l_col9                                  ,
6843        l_col10                                 ,
6844        l_col11                                 ,
6845        l_col12                                 ,
6846        l_col13                                 ,
6847        l_col14                                 ,
6848        l_col15                                 ,
6849        l_col16                                 ,
6850        l_col17                                 ,
6851        l_col18                                 ,
6852        l_col19                                 ,
6853        l_col20                                 ,
6854        l_col21                                 ,
6855        l_col22                                 ,
6856        l_col23                                 ,
6857        l_col24                                 ,
6858        l_col25                                 ,
6859        l_col26                                 ,
6860        l_col27                                 ,
6861        l_col28                                 ,
6862        l_col29                                 ,
6863        l_col30                                 ,
6864        l_col31                                 ,
6865        l_col32                                 ,
6866        l_col33                                 ,
6867        l_col34                                 ,
6868        l_col35                                 ,
6869        l_col36                                 ,
6870        l_col37                                 ,
6871        l_col38                                 ,
6872        l_col39                                 ,
6873        l_col40                                 ,
6874        l_col41                                 ,
6875        l_col42                                 ,
6876        l_col43                                 ,
6877        l_col44                                 ,
6878        l_col45                                 ,
6879        l_col46                                 ,
6880        l_col47                                 ,
6881        l_col48                                 ,
6882        l_col49                                 ,
6883        l_col50                                 ,
6884        l_col51                                 ,
6885        l_col52                                 ,
6886        l_col53                                 ,
6887        l_col54                                 ,
6888        l_col55                                 ,
6889        l_col56                                 ,
6890        l_col57                                 ,
6891        l_col58                                 ,
6892        l_col59                                 ,
6893        l_col60                                 ,
6894        l_col61                                 ,
6895        l_col62                                 ,
6896        l_col63                                 ,
6897        l_col64                                 ,
6898        l_col65                                 ,
6899        l_col66                                 ,
6900        l_col67                                 ,
6901        l_col68                                 ,
6902        l_col69                                 ,
6903        l_col70                                 ,
6904        l_col71                                 ,
6905        l_col72                                 ,
6906        l_col73                                 ,
6907        l_col74                                 ,
6908        l_col75                                 ,
6909        l_col76                                 ,
6910        l_col77                                 ,
6911        l_col78                                 ,
6912        l_col79                                 ,
6913        l_col80                                 ,
6914        l_col81                                 ,
6915        l_col82                                 ,
6916        l_col83                                 ,
6917        l_col84                                 ,
6918        l_col85                                 ,
6919        l_col86                                 ,
6920        l_col87                                 ,
6921        l_col88                                 ,
6922        l_col89                                 ,
6923        l_col90                                 ,
6924        l_col91                                 ,
6925        l_col92                                 ,
6926        l_col93                                 ,
6927        l_col94                                 ,
6928        l_col95                                 ,
6929        l_col96                                 ,
6930        l_col97                                 ,
6931        l_col98                                 ,
6932        l_col99                                 ,
6933        l_col100                                ,
6934        l_col101                                  ,
6935        l_col102                                  ,
6936        l_col103                                  ,
6937        l_col104                                  ,
6938        l_col105                                  ,
6939        l_col106                                  ,
6940        l_col107                                  ,
6941        l_col108                                  ,
6942        l_col109                                  ,
6943        l_col110                                 ,
6944        l_col111                                 ,
6945        l_col112                                 ,
6946        l_col113                                 ,
6947        l_col114                                 ,
6948        l_col115                                 ,
6949        l_col116                                 ,
6950        l_col117                                 ,
6951        l_col118                                 ,
6952        l_col119                                 ,
6953        l_col120                                 ,
6954        l_col121                                 ,
6955        l_col122                                 ,
6956        l_col123                                 ,
6957        l_col124                                 ,
6958        l_col125                                 ,
6959        l_col126                                 ,
6960        l_col127                                 ,
6961        l_col128                                 ,
6962        l_col129                                 ,
6963        l_col130                                 ,
6964        l_col131                                 ,
6965        l_col132                                 ,
6966        l_col133                                 ,
6967        l_col134                                 ,
6968        l_col135                                 ,
6969        l_col136                                 ,
6970        l_col137                                 ,
6971        l_col138                                 ,
6972        l_col139                                 ,
6973        l_col140                                 ,
6974        l_col141                                 ,
6975        l_col142                                 ,
6976        l_col143                                 ,
6977        l_col144                                 ,
6978        l_col145                                 ,
6979        l_col146                                 ,
6980        l_col147                                 ,
6981        l_col148                                 ,
6982        l_col149                                 ,
6983        l_col150                                 ,
6984        l_col151                                 ,
6985        l_col152                                 ,
6986        l_col153                                 ,
6987        l_col154                                 ,
6988        l_col155                                 ,
6989        l_col156                                 ,
6990        l_col157                                 ,
6991        l_col158                                 ,
6992        l_col159                                 ,
6993        l_col160                                 ,
6994        l_col161                                 ,
6995        l_col162                                 ,
6996        l_col163                                 ,
6997        l_col164                                 ,
6998        l_col165                                 ,
6999        l_col166                                 ,
7000        l_col167                                 ,
7001        l_col168                                 ,
7002 --       l_col169                                 ,
7003 --       l_col170                                 ,
7004 --       l_col171                                 ,
7005        l_col172                                 ,
7006        l_col173                                 ,
7007        l_col174                                 ,
7008        l_col175                                 ,
7009        l_col176                                 ,
7010        l_col177                                 ,
7011 --       l_col178                                 ,
7012 --       l_col179                                 ,
7013 --       l_col180                                 ,
7014 --       l_col181                                 ,
7015        l_col182                                 ,
7016        l_col183                                 ,
7017        l_col184                                 ,
7018        l_col185                                 ,
7019        l_col186                                 ,
7020        l_col187                                 ,
7021        l_col188                                 ,
7022        l_col189                                 ,
7023        l_col190                                 ,
7024        l_col191                                 ,
7025        l_col192                                 ,
7026        l_col193                                 ,
7027        l_col194                                 ,
7028        l_col195                                 ,
7029        l_col196                                 ,
7030        l_col197                                 ,
7031        l_col198                                 ,
7032        l_col199                                 ,
7033        l_col200                                ,
7034        l_col201                                  ,
7035        l_col202                                  ,
7036        l_col203                                  ,
7037        l_col204                                  ,
7038        l_col205                                  ,
7039        l_col206                                  ,
7040        l_col207                                  ,
7041        l_col208                                  ,
7042        l_col209                                  ,
7043        l_col210                                 ,
7044        l_col211                                 ,
7045        l_col212                                 ,
7046        l_col213                                 ,
7047        l_col214                                 ,
7048        l_col215                                 ,
7049        l_col216                                 ,
7050        l_col217                                 ,
7051        l_col218                                 ,
7052        l_col219                                 ,
7053        l_col220                                 ,
7054        l_col221                                 ,
7055        l_col222                                 ,
7056        l_col223                                 ,
7057        l_col224                                 ,
7058        l_col225                                 ,
7059        l_col226                                 ,
7060        l_col227                                 ,
7061        l_col228                             ,
7062        l_col229,
7063        l_col230,
7064        l_col231,
7065        l_col232,
7066        l_col233,
7067        l_col234,
7068        l_col235,
7069        l_col236,
7070        l_col237,
7071        l_col238
7072       LIMIT L_MAX_ROW_COUNT;
7073 
7074 
7075       FORALL i IN 1 .. l_import_source_line_id.count
7076        INSERT INTO ams_list_import_errors
7077        (
7078 	LIST_IMPORT_ERROR_ID,
7079 	LAST_UPDATED_BY,
7080 	LAST_UPDATE_DATE,
7081 	CREATION_DATE,
7082 	CREATED_BY,
7083 	LAST_UPDATE_LOGIN,
7084 	IMPORT_SOURCE_LINE_ID,
7085 	IMPORT_LIST_HEADER_ID,
7086 	IMPORT_TYPE,
7087 	ERROR_TYPE,
7088         BATCH_ID,
7089         ERROR_FLAG,
7090         col1                                  ,
7091         col2                                  ,
7092         col3                                  ,
7093         col4                                  ,
7094         col5                                  ,
7095         col6                                  ,
7096         col7                                  ,
7097         col8                                  ,
7098         col9                                  ,
7099         col10                                 ,
7100         col11                                 ,
7101         col12                                 ,
7102         col13                                 ,
7103         col14                                 ,
7104         col15                                 ,
7105         col16                                 ,
7106         col17                                 ,
7107         col18                                 ,
7108         col19                                 ,
7109         col20                                 ,
7110         col21                                 ,
7111         col22                                 ,
7112         col23                                 ,
7113         col24                                 ,
7114         col25                                 ,
7115         col26                                 ,
7116         col27                                 ,
7117         col28                                 ,
7118         col29                                 ,
7119         col30                                 ,
7120         col31                                 ,
7121         col32                                 ,
7122         col33                                 ,
7123         col34                                 ,
7124         col35                                 ,
7125         col36                                 ,
7126         col37                                 ,
7127         col38                                 ,
7128         col39                                 ,
7129         col40                                 ,
7130         col41                                 ,
7131         col42                                 ,
7132         col43                                 ,
7133         col44                                 ,
7134         col45                                 ,
7135         col46                                 ,
7136         col47                                 ,
7137         col48                                 ,
7138         col49                                 ,
7139         col50                                 ,
7140         col51                                 ,
7141         col52                                 ,
7142         col53                                 ,
7143         col54                                 ,
7144         col55                                 ,
7145         col56                                 ,
7146         col57                                 ,
7147         col58                                 ,
7148         col59                                 ,
7149         col60                                 ,
7150         col61                                 ,
7151         col62                                 ,
7152         col63                                 ,
7153         col64                                 ,
7154         col65                                 ,
7155         col66                                 ,
7156         col67                                 ,
7157         col68                                 ,
7158         col69                                 ,
7159         col70                                 ,
7160         col71                                 ,
7161         col72                                 ,
7162         col73                                 ,
7163         col74                                 ,
7164         col75                                 ,
7165         col76                                 ,
7166         col77                                 ,
7167         col78                                 ,
7168         col79                                 ,
7169         col80                                 ,
7170         col81                                 ,
7171         col82                                 ,
7172         col83                                 ,
7173         col84                                 ,
7174         col85                                 ,
7175         col86                                 ,
7176         col87                                 ,
7177         col88                                 ,
7178         col89                                 ,
7179         col90                                 ,
7180         col91                                 ,
7181         col92                                 ,
7182         col93                                 ,
7183         col94                                 ,
7184         col95                                 ,
7185         col96                                 ,
7186         col97                                 ,
7187         col98                                 ,
7188         col99                                 ,
7189         col100                                ,
7190         col101                                  ,
7191         col102                                  ,
7192         col103                                  ,
7193         col104                                  ,
7194         col105                                  ,
7195         col106                                  ,
7196         col107                                  ,
7197         col108                                  ,
7198         col109                                  ,
7199         col110                                 ,
7200         col111                                 ,
7201         col112                                 ,
7202         col113                                 ,
7203         col114                                 ,
7204         col115                                 ,
7205         col116                                 ,
7206         col117                                 ,
7207         col118                                 ,
7208         col119                                 ,
7209         col120                                 ,
7210         col121                                 ,
7211         col122                                 ,
7212         col123                                 ,
7213         col124                                 ,
7214         col125                                 ,
7215         col126                                 ,
7216         col127                                 ,
7217         col128                                 ,
7218         col129                                 ,
7219         col130                                 ,
7220         col131                                 ,
7221         col132                                 ,
7222         col133                                 ,
7223         col134                                 ,
7224         col135                                 ,
7225         col136                                 ,
7226         col137                                 ,
7227         col138                                 ,
7228         col139                                 ,
7229         col140                                 ,
7230         col141                                 ,
7231         col142                                 ,
7232         col143                                 ,
7233         col144                                 ,
7234         col145                                 ,
7235         col146                                 ,
7236         col147                                 ,
7237         col148                                 ,
7238         col149                                 ,
7239         col150                                 ,
7240         col151                                 ,
7241         col152                                 ,
7242         col153                                 ,
7243         col154                                 ,
7244         col155                                 ,
7245         col156                                 ,
7246         col157                                 ,
7247         col158                                 ,
7248         col159                                 ,
7249         col160                                 ,
7250         col161                                 ,
7251         col162                                 ,
7252         col163                                 ,
7253         col164                                 ,
7254         col165                                 ,
7255         col166                                 ,
7256         col167                                 ,
7257         col168                                 ,
7258 --        col169                                 ,
7259 --        col170                                 ,
7260 --        col171                                 ,
7261         col172                                 ,
7262         col173                                 ,
7263         col174                                 ,
7264         col175                                 ,
7265         col176                                 ,
7266         col177                                 ,
7267 --        col178                                 ,
7268 --        col179                                 ,
7269 --        col180                                 ,
7270 --        col181                                 ,
7271         col182                                 ,
7272         col183                                 ,
7273         col184                                 ,
7274         col185                                 ,
7275         col186                                 ,
7276         col187                                 ,
7277         col188                                 ,
7278         col189                                 ,
7279         col190                                 ,
7280         col191                                 ,
7281         col192                                 ,
7282         col193                                 ,
7283         col194                                 ,
7284         col195                                 ,
7285         col196                                 ,
7286         col197                                 ,
7287         col198                                 ,
7288         col199                                 ,
7289         col200                                ,
7290         col201                                  ,
7291         col202                                  ,
7292         col203                                  ,
7293         col204                                  ,
7294         col205                                  ,
7295         col206                                  ,
7296         col207                                  ,
7297         col208                                  ,
7298         col209                                  ,
7299         col210                                 ,
7300         col211                                 ,
7301         col212                                 ,
7302         col213                                 ,
7303         col214                                 ,
7304         col215                                 ,
7305         col216                                 ,
7306         col217                                 ,
7307         col218                                 ,
7308         col219                                 ,
7309         col220                                 ,
7310         col221                                 ,
7311         col222                                 ,
7312         col223                                 ,
7313         col224                                 ,
7314         col225                                 ,
7315         col226                                 ,
7316 	col227                                 ,
7317 	col228,
7318        col229,
7319        col230,
7320        col231,
7321        col232,
7322        col233,
7323        col234,
7324        col235,
7325        col236,
7326        col237,
7327        col238
7328         )
7329        VALUES
7330        (
7331 	ams_list_import_errors_s.nextval,      -- LIST_IMPORT_ERROR_ID,
7332 	FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
7333 	SYSDATE,                              -- LAST_UPDATE_DATE,
7334 	SYSDATE,                              -- CREATION_DATE,
7335 	FND_GLOBAL.User_ID,                   -- CREATED_BY,
7336 	FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
7337         l_import_source_line_id(i),
7338         l_import_list_header_id(i),
7339 	'LEAD',                                -- IMPORT_TYPE,
7340 	'E',                                  -- ERROR_TYPE,
7341         l_batch_id,
7342        'Y',
7343        l_col1(i),
7344        l_col2(i),
7345        l_col3(i),
7346        l_col4(i),
7347        l_col5(i),
7348        l_col6(i),
7349        l_col7(i),
7350        l_col8(i),
7351        l_col9(i),
7352        l_col10(i),
7353        l_col11(i),
7354        l_col12(i),
7355        l_col13(i),
7356        l_col14(i),
7357        l_col15(i),
7358        l_col16(i),
7359        l_col17(i),
7360        l_col18(i),
7361        l_col19(i),
7362        l_col20(i),
7363        l_col21(i),
7364        l_col22(i),
7365        l_col23(i),
7366        l_col24(i),
7367        l_col25(i),
7368        l_col26(i),
7369        l_col27(i),
7370        l_col28(i),
7371        l_col29(i),
7372        l_col30(i),
7373        l_col31(i),
7374        l_col32(i),
7375        l_col33(i),
7376        l_col34(i),
7377        l_col35(i),
7378        l_col36(i),
7379        l_col37(i),
7380        l_col38(i),
7381        l_col39(i),
7382        l_col40(i),
7383        l_col41(i),
7384        l_col42(i),
7385        l_col43(i),
7386        l_col44(i),
7387        l_col45(i),
7388        l_col46(i),
7389        l_col47(i),
7390        l_col48(i),
7391        l_col49(i),
7392        l_col50(i),
7393        l_col51(i),
7394        l_col52(i),
7395        l_col53(i),
7396        l_col54(i),
7397        l_col55(i),
7398        l_col56(i),
7399        l_col57(i),
7400        l_col58(i),
7401        l_col59(i),
7402        l_col60(i),
7403        l_col61(i),
7404        l_col62(i),
7405        l_col63(i),
7406        l_col64(i),
7407        l_col65(i),
7408        l_col66(i),
7409        l_col67(i),
7410        l_col68(i),
7411 --       l_col69(i),
7412 --       l_col70(i),
7413 --       l_col71(i),
7414        l_col72(i),
7415        l_col73(i),
7416        l_col74(i),
7417        l_col75(i),
7418        l_col76(i),
7419        l_col77(i),
7420 --       l_col78(i),
7421 --       l_col79(i),
7422 --       l_col80(i),
7423 --       l_col81(i),
7424        l_col82(i),
7425        l_col83(i),
7426        l_col84(i),
7427        l_col85(i),
7428        l_col86(i),
7429        l_col87(i),
7430        l_col88(i),
7431        l_col89(i),
7432        l_col90(i),
7433        l_col91(i),
7434        l_col92(i),
7435        l_col93(i),
7436        l_col94(i),
7437        l_col95(i),
7438        l_col96(i),
7439        l_col97(i),
7440        l_col98(i),
7441        l_col99(i),
7442        l_col100(i),
7443        l_col101(i),
7444        l_col102(i),
7445        l_col103(i),
7446        l_col104(i),
7447        l_col105(i),
7448        l_col106(i),
7449        l_col107(i),
7450        l_col108(i),
7451        l_col109(i),
7452        l_col110(i),
7453        l_col111(i),
7454        l_col112(i),
7455        l_col113(i),
7456        l_col114(i),
7457        l_col115(i),
7458        l_col116(i),
7459        l_col117(i),
7460        l_col118(i),
7461        l_col119(i),
7462        l_col120(i),
7463        l_col121(i),
7464        l_col122(i),
7465        l_col123(i),
7466        l_col124(i),
7467        l_col125(i),
7468        l_col126(i),
7469        l_col127(i),
7470        l_col128(i),
7471        l_col129(i),
7472        l_col130(i),
7473        l_col131(i),
7474        l_col132(i),
7475        l_col133(i),
7476        l_col134(i),
7477        l_col135(i),
7478        l_col136(i),
7479        l_col137(i),
7480        l_col138(i),
7481        l_col139(i),
7482        l_col140(i),
7483        l_col141(i),
7484        l_col142(i),
7485        l_col143(i),
7486        l_col144(i),
7487        l_col145(i),
7488        l_col146(i),
7489        l_col147(i),
7490        l_col148(i),
7491        l_col149(i),
7492        l_col150(i),
7493        l_col151(i),
7494        l_col152(i),
7495        l_col153(i),
7496        l_col154(i),
7497        l_col155(i),
7498        l_col156(i),
7499        l_col157(i),
7500        l_col158(i),
7501        l_col159(i),
7502        l_col160(i),
7503        l_col161(i),
7504        l_col162(i),
7505        l_col163(i),
7506        l_col164(i),
7507        l_col165(i),
7508        l_col166(i),
7509        l_col167(i),
7510        l_col168(i),
7511        l_col169(i),
7512        l_col170(i),
7513        l_col171(i),
7514        l_col172(i),
7515        l_col173(i),
7516        l_col174(i),
7517        l_col175(i),
7518        l_col176(i),
7519        l_col177(i),
7520        l_col178(i),
7521        l_col179(i),
7522        l_col180(i),
7523        l_col181(i),
7524        l_col182(i),
7525        l_col183(i),
7526        l_col184(i),
7527        l_col185(i),
7528        l_col186(i),
7529        l_col187(i),
7530        l_col188(i),
7531        l_col189(i),
7532        l_col190(i),
7533        l_col191(i),
7534        l_col192(i),
7535        l_col193(i),
7536        l_col194(i),
7537        l_col195(i),
7538        l_col196(i),
7539        l_col197(i),
7540        l_col198(i),
7541        l_col199(i),
7542        l_col200(i),
7543        l_col201(i),
7544        l_col202(i),
7545        l_col203(i),
7546        l_col204(i),
7547        l_col205(i),
7548        l_col206(i),
7549        l_col207(i),
7550        l_col208(i),
7551        l_col209(i),
7552        l_col210(i),
7553        l_col211(i),
7554        l_col212(i),
7555        l_col213(i),
7556        l_col214(i),
7557        l_col215(i),
7558        l_col216(i),
7559        l_col217(i),
7560        l_col218(i),
7561        l_col219(i),
7562        l_col220(i),
7563        l_col221(i),
7564        l_col222(i),
7565        l_col223(i),
7566        l_col224(i),
7567        l_col225(i),
7568        l_col226(i),
7569        l_col227(i),
7570        l_col228(i),
7571        l_col229(i),
7572        l_col230(i),
7573        l_col231(i),
7574        l_col232(i),
7575        l_col233(i),
7576        l_col234(i),
7577        l_col235(i),
7578        l_col236(i),
7579        l_col237(i),
7580        l_col238(i)
7581        );
7582       EXIT WHEN c_lead_fields%NOTFOUND;
7583     END LOOP;
7584       CLOSE c_lead_fields;
7585 
7586        OPEN c_lead_date_fields;
7587        LOOP
7588        FETCH c_lead_date_fields into x_import_list_header_id,x_import_source_line_id,l_assign_date,
7589              l_address_effective_date, l_last_ordered_date,l_program_update_date,l_lead_date;
7590        EXIT WHEN c_lead_date_fields%NOTFOUND;
7591        date_validate( x_import_list_header_id,x_import_source_line_id,l_batch_id,l_assign_date,
7592              l_address_effective_date, l_last_ordered_date,l_program_update_date,l_lead_date,null);
7593        End Loop;
7594        CLOSE c_lead_date_fields;
7595 
7596        open c_source_system;
7597        fetch c_source_system into l_total_rec, l_source_system;
7598        close c_source_system;
7599       if l_source_system is not NULL then
7600        open c_invalid_src_sys;
7601        loop
7602         fetch c_invalid_src_sys into x_import_list_header_id,x_import_source_line_id;
7603         exit when c_invalid_src_sys%notfound;
7604         l_error_exists := null;
7605         open c_error_exists;
7606         fetch c_error_exists into l_error_exists;
7607         close c_error_exists;
7608         if l_error_exists = 'Y' then
7609           update ams_list_import_errors
7610           set col1 =  'SOURCE_SYSTEM:'||l_invalid_src_system
7611           where import_list_header_id = x_import_list_header_id
7612           and import_source_line_id = x_import_source_line_id
7613           and batch_id                = l_batch_id;
7614         end if;
7615         if l_error_exists is null then
7616           INSERT INTO ams_list_import_errors
7617           (
7618            LIST_IMPORT_ERROR_ID,
7619            LAST_UPDATED_BY,
7620            LAST_UPDATE_DATE,
7621            CREATION_DATE,
7622            CREATED_BY,
7623            LAST_UPDATE_LOGIN,
7624            IMPORT_SOURCE_LINE_ID,
7625            IMPORT_LIST_HEADER_ID,
7626            IMPORT_TYPE,
7627            ERROR_TYPE,
7628            BATCH_ID,
7629            col1
7630            )
7631           VALUES
7632           (
7633           ams_list_import_errors_s.nextval,      -- LIST_IMPORT_ERROR_ID,
7634           FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
7635           SYSDATE,                              -- LAST_UPDATE_DATE,
7636           SYSDATE,                              -- CREATION_DATE,
7637           FND_GLOBAL.User_ID,                   -- CREATED_BY,
7638           FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
7639           x_import_source_line_id,
7640           x_import_list_header_id,
7641           'LEAD',                                -- IMPORT_TYPE,
7642           'E',                                  -- ERROR_TYPE,
7643           l_batch_id,
7644            'SOURCE_SYSTEM:'||l_invalid_src_system);
7645         end if;
7646        end loop;
7647        close c_invalid_src_sys;
7648       end if;
7649 
7650        UPDATE ams_imp_source_lines
7651          SET load_status = decode(load_status,'DUPLICATE','DUPLICATE','ERROR')
7652        WHERE import_list_header_id = p_import_list_header_id
7653          and import_source_line_id in
7654        (select import_source_line_id from ams_list_import_errors
7655         where import_list_header_id = p_import_list_header_id
7656           and error_type = 'E');
7657 
7658 
7659 EXCEPTION
7660  WHEN OTHERS THEN
7661     p_return_status := FND_API.G_RET_STS_ERROR;
7662     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
7663     FND_MESSAGE.Set_Token('ROW','Error in execute_lead_data_validation:' || SQLERRM||' '||SQLCODE);
7664     AMS_Utility_PVT.Create_Log (
7665       x_return_status   => l_return_status,
7666       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7667       p_log_used_by_id  => p_import_list_header_id,
7668       p_msg_data        => FND_MESSAGE.get,
7669       p_msg_type        => 'DEBUG'
7670    );
7671 
7672 end execute_lead_data_validation;
7673 
7674 -- ---------------------------------------
7675 procedure date_validate (
7676    p_import_list_header_id    IN    NUMBER,
7677    p_import_source_line_id    IN    NUMBER,
7678    p_batch_id                   IN    NUMBER,
7679    p_column1                  IN    VARCHAR2,
7680    p_column2                  IN    VARCHAR2,
7681    p_column3                  IN    VARCHAR2,
7682    p_column4                  IN    VARCHAR2,
7683    p_column5                  IN    VARCHAR2,
7684    p_column6                  IN    VARCHAR2
7685                         ) IS
7686 
7687 l_col1          varchar2(1);
7688 l_col2          varchar2(1);
7689 l_col3          varchar2(1);
7690 l_col4          varchar2(1);
7691 l_col5          varchar2(1);
7692 l_col6          varchar2(1);
7693 l_date1         date;
7694 l_date2         date;
7695 l_date3         date;
7696 l_date4         date;
7697 l_date5         date;
7698 l_date6         date;
7699 l_error_exist   varchar2(1);
7700 l_imp_type      varchar2(60);
7701 l_col11         varchar2(60);
7702 l_col22         varchar2(60);
7703 l_col33         varchar2(60);
7704 l_col44         varchar2(60);
7705 l_col55         varchar2(60);
7706 l_col66         varchar2(60);
7707 l_return_status varchar2(1);
7708 l_invalid_date varchar2(4000) ;
7709 
7710 l_org_imp_xml_element_id        number;
7711 l_add_imp_xml_element_id        number;
7712 l_ocont_imp_xml_element_id      number;
7713 l_cp_imp_xml_element_id         number;
7714 l_em_imp_xml_element_id         number;
7715 l_per_imp_xml_element_id        number;
7716 l_file_type                     varchar2(60);
7717 x_date_format    VARCHAR2(50);
7718 
7719 cursor c_error_exists is
7720 select 'Y'
7721 from ams_list_import_errors
7722 where import_list_header_id = p_import_list_header_id
7723   and import_source_line_id = p_import_source_line_id
7724   and batch_id              = p_batch_id;
7725 
7726 cursor c_imp_type is
7727 select import_type
7728 from ams_imp_list_headers_all
7729 where import_list_header_id = p_import_list_header_id;
7730 
7731 cursor c_b2bxmlrec is
7732 select org_imp_xml_element_id, add_imp_xml_element_id, ocont_imp_xml_element_id,
7733 cp_imp_xml_element_id, em_imp_xml_element_id
7734 from ams_hz_b2b_mapping_v where import_source_line_id = p_import_source_line_id;
7735 
7736 cursor c_b2cxmlrec is
7737 select per_imp_xml_element_id, add_imp_xml_element_id,cp_imp_xml_element_id, em_imp_xml_element_id
7738 from ams_hz_b2c_mapping_v where import_source_line_id = p_import_source_line_id;
7739 
7740 cursor c_file_type is
7741 select file_type from AMS_IMP_DOCUMENTS where import_list_header_id = p_import_list_header_id;
7742 
7743 begin
7744  FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_DATE_VAL_ERROR_CHK');
7745  l_invalid_date := FND_MESSAGE.get;
7746  x_date_format             := fnd_profile.value('ICX_DATE_FORMAT_MASK');
7747  open c_file_type;
7748  fetch c_file_type into l_file_type;
7749  close c_file_type;
7750 
7751  open c_b2bxmlrec;
7752  fetch c_b2bxmlrec into l_org_imp_xml_element_id, l_add_imp_xml_element_id, l_ocont_imp_xml_element_id,
7753                      l_cp_imp_xml_element_id, l_em_imp_xml_element_id;
7754  close c_b2bxmlrec;
7755  open c_imp_type;
7756  fetch c_imp_type into l_imp_type;
7757  close c_imp_type;
7758  open c_error_exists;
7759  fetch c_error_exists into l_error_exist;
7760  close c_error_exists;
7761 
7762  if l_imp_type = 'B2B' then
7763  open c_b2bxmlrec;
7764  fetch c_b2bxmlrec into l_org_imp_xml_element_id, l_add_imp_xml_element_id, l_ocont_imp_xml_element_id,
7765                      l_cp_imp_xml_element_id, l_em_imp_xml_element_id;
7766  close c_b2bxmlrec;
7767  end if;
7768  if l_imp_type = 'B2C' then
7769  open c_b2cxmlrec;
7770  fetch c_b2cxmlrec into l_per_imp_xml_element_id, l_add_imp_xml_element_id,
7771                      l_cp_imp_xml_element_id, l_em_imp_xml_element_id;
7772  close c_b2cxmlrec;
7773  end if;
7774 l_col1 := null;
7775 l_col2 := null;
7776 l_col3 := null;
7777 l_col4 := null;
7778 l_col5 := null;
7779 l_col6 := null;
7780 /*
7781     AMS_Utility_PVT.Create_Log (
7782       x_return_status   => l_return_status,
7783       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7784       p_log_used_by_id  => p_import_list_header_id,
7785       p_msg_data        => 'p_column1 = '||p_column1,
7786       p_msg_type        => 'DEBUG'
7787    );
7788     AMS_Utility_PVT.Create_Log (
7789       x_return_status   => l_return_status,
7790       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7791       p_log_used_by_id  => p_import_list_header_id,
7792       p_msg_data        => 'p_column2 = '||p_column2,
7793       p_msg_type        => 'DEBUG'
7794    );
7795     AMS_Utility_PVT.Create_Log (
7796       x_return_status   => l_return_status,
7797       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7798       p_log_used_by_id  => p_import_list_header_id,
7799       p_msg_data        => 'p_column3 = '||p_column3,
7800       p_msg_type        => 'DEBUG'
7801    );
7802     AMS_Utility_PVT.Create_Log (
7803       x_return_status   => l_return_status,
7804       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7805       p_log_used_by_id  => p_import_list_header_id,
7806       p_msg_data        => 'p_column4 = '||p_column4,
7807       p_msg_type        => 'DEBUG'
7808    );
7809     AMS_Utility_PVT.Create_Log (
7810       x_return_status   => l_return_status,
7811       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7812       p_log_used_by_id  => p_import_list_header_id,
7813       p_msg_data        => 'p_column5 = '||p_column5,
7814       p_msg_type        => 'DEBUG'
7815    );
7816     AMS_Utility_PVT.Create_Log (
7817       x_return_status   => l_return_status,
7818       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7819       p_log_used_by_id  => p_import_list_header_id,
7820       p_msg_data        => 'p_column6 = '||p_column6,
7821       p_msg_type        => 'DEBUG'
7822    );
7823 */
7824  if p_column1 is not null then
7825   begin
7826  --   l_date1 := to_date(p_column1,'MM/DD/YYYY');
7827 select to_date(p_column1, x_date_format) into l_date1 from dual;
7828     AMS_Utility_PVT.Create_Log (
7829       x_return_status   => l_return_status,
7830       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7831       p_log_used_by_id  => p_import_list_header_id,
7832       p_msg_data        => 'l_date1 = '||to_char(l_date1),
7833       p_msg_type        => 'DEBUG'
7834    );
7835 
7836   exception
7837   when others then
7838                 l_col1 := 'Y';
7839   end;
7840  end if;
7841  if p_column2 is not null then
7842   begin
7843    -- l_date2 :=  to_date(p_column2,'MM/DD/YYYY');
7844 select to_date(p_column2, x_date_format) into l_date2 from dual;
7845     AMS_Utility_PVT.Create_Log (
7846       x_return_status   => l_return_status,
7847       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7848       p_log_used_by_id  => p_import_list_header_id,
7849       p_msg_data        => 'l_date2 = '||to_char(l_date2),
7850       p_msg_type        => 'DEBUG'
7851    );
7852 
7853   exception
7854   when others then
7855                 l_col2 := 'Y';
7856   end;
7857  end if;
7858  if p_column3 is not null then
7859   begin
7860 --     l_date3 :=  to_date(p_column3,'MM/DD/YYYY');
7861 select to_date(p_column3, x_date_format) into l_date3 from dual;
7862     AMS_Utility_PVT.Create_Log (
7863       x_return_status   => l_return_status,
7864       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7865       p_log_used_by_id  => p_import_list_header_id,
7866       p_msg_data        => 'l_date3 = '||to_char(l_date3),
7867       p_msg_type        => 'DEBUG'
7868    );
7869 
7870   exception
7871   when others then
7872                 l_col3 := 'Y';
7873   end;
7874  end if;
7875 
7876  if p_column4 is not null then
7877   begin
7878     -- l_date4 :=  to_date(p_column4,'MM/DD/YYYY');
7879 select to_date(p_column4, x_date_format) into l_date4 from dual;
7880     AMS_Utility_PVT.Create_Log (
7881       x_return_status   => l_return_status,
7882       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7883       p_log_used_by_id  => p_import_list_header_id,
7884       p_msg_data        => 'l_date4 = '||to_char(l_date4),
7885       p_msg_type        => 'DEBUG'
7886    );
7887 
7888   exception
7889   when others then
7890                 l_col4 := 'Y';
7891   end;
7892  end if;
7893 
7894 
7895  if p_column5 is not null then
7896   begin
7897     -- l_date5 :=  to_date(p_column5,'MM/DD/YYYY');
7898 select to_date(p_column5, x_date_format) into l_date5 from dual;
7899     AMS_Utility_PVT.Create_Log (
7900       x_return_status   => l_return_status,
7901       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7902       p_log_used_by_id  => p_import_list_header_id,
7903       p_msg_data        => 'l_date5 = '||to_char(l_date5),
7904       p_msg_type        => 'DEBUG'
7905    );
7906   exception
7907   when others then
7908                 l_col5 := 'Y';
7909   end;
7910  end if;
7911 
7912  if p_column6 is not null then
7913   begin
7914     -- l_date6 :=  to_date(p_column6,'MM/DD/YYYY');
7915 select to_date(p_column6, x_date_format) into l_date6 from dual;
7916     AMS_Utility_PVT.Create_Log (
7917       x_return_status   => l_return_status,
7918       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
7919       p_log_used_by_id  => p_import_list_header_id,
7920       p_msg_data        => 'l_date6 = '||to_char(l_date6),
7921       p_msg_type        => 'DEBUG'
7922    );
7923   exception
7924   when others then
7925                 l_col6 := 'Y';
7926   end;
7927  end if;
7928 
7929  if  l_imp_type = 'LEAD' then
7930     l_col11 := 'ASSIGN_DATE: ';
7931     l_col22 := 'ADDRESS_EFFECTIVE_DATE: ';
7932     l_col55 := 'LEAD_DATE: ';
7933  end if;
7934 
7935  if  (l_imp_type = 'B2B' or l_imp_type = 'B2C') then
7936     l_col11 := 'ADDRESS_EFFECTIVE_DATE : ';
7937     l_col22 := 'ADDRESS_EXPIRATION_DATE : ';
7938     l_col33 := 'DATE_OF_BIRTH : ';
7939     l_col44 := 'DATE_OF_DEATH : ';
7940     l_col55 := 'DEBARTMENTS_DATE : ';
7941     l_col66 := 'MARITAL_STATUS_EFFECTIVE_DATE : ';
7942  end if;
7943 
7944  if (l_col1 = 'Y' or l_col2 = 'Y' or l_col3 = 'Y' or l_col4 = 'Y' or l_col5 = 'Y' or l_col6 = 'Y') then
7945     if l_error_exist = 'Y' then
7946         update ams_list_import_errors
7947         set col227 =  decode(l_col1,'Y',l_col11||l_invalid_date),
7948          col228 =  decode(l_col2,'Y',l_col22||l_invalid_date),
7949         -- col229 =  decode(l_col3,'Y','LAST_ORDERED_DATE:'||l_invalid_date),
7950         -- col230 =  decode(l_col4,'Y','PROGRAM_UPDATE_DATE:'||l_invalid_date),
7951          col233 =  decode(l_col3,'Y',l_col33||l_invalid_date),
7952          col234 =  decode(l_col4,'Y',l_col44||l_invalid_date),
7953          col235 =  decode(l_col5,'Y',l_col55||l_invalid_date),
7954          col236 =  decode(l_col6,'Y',l_col66||l_invalid_date)
7955         where import_list_header_id = p_import_list_header_id
7956         and import_source_line_id = p_import_source_line_id
7957         and batch_id                = p_batch_id;
7958     end if;
7959     if l_file_type = 'XML' then
7960        if (l_imp_type in ('B2B','B2C') and (l_col1 = 'Y' or l_col2 = 'Y'))then
7961             update AMS_IMP_XML_ELEMENTS
7962             set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col1,'Y',l_col11||l_invalid_date)||','||
7963                              decode(l_col2,'Y',l_col22||l_invalid_date),
7964                 LOAD_STATUS = 'ERROR'
7965             where  imp_xml_element_id = l_add_imp_xml_element_id;
7966        end if;
7967        if (l_imp_type in ('B2B') and (l_col3 = 'Y' or l_col4 = 'Y' or l_col5 = 'Y' or l_col6 = 'Y'))then
7968            if l_col3 = 'Y' then
7969               update AMS_IMP_XML_ELEMENTS
7970               set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col3,'Y',l_col33||l_invalid_date),
7971                 LOAD_STATUS = 'ERROR'
7972               where  imp_xml_element_id = l_ocont_imp_xml_element_id;
7973            end if;
7974            if l_col4 = 'Y' then
7975               update AMS_IMP_XML_ELEMENTS
7976               set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col4,'Y',l_col44||l_invalid_date),
7977                 LOAD_STATUS = 'ERROR'
7978               where  imp_xml_element_id = l_ocont_imp_xml_element_id;
7979            end if;
7980            if l_col6 = 'Y' then
7981               update AMS_IMP_XML_ELEMENTS
7982               set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col6,'Y',l_col66||l_invalid_date),
7983                 LOAD_STATUS = 'ERROR'
7984               where  imp_xml_element_id = l_ocont_imp_xml_element_id;
7985            end if;
7986            if l_col5 = 'Y' then
7987             update AMS_IMP_XML_ELEMENTS
7988             set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col5,'Y',l_col55||l_invalid_date),
7989                 LOAD_STATUS = 'ERROR'
7990             where  imp_xml_element_id = l_org_imp_xml_element_id;
7991            end if;
7992        end if;
7993        if (l_imp_type in ('B2C') and (l_col3 = 'Y' or l_col4 = 'Y' or l_col6 = 'Y'))then
7994            if l_col3 = 'Y' then
7995             update AMS_IMP_XML_ELEMENTS
7996             set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col3,'Y',l_col33||l_invalid_date),
7997                 LOAD_STATUS = 'ERROR'
7998             where  imp_xml_element_id = l_per_imp_xml_element_id;
7999            end if;
8000            if l_col4 = 'Y' then
8001             update AMS_IMP_XML_ELEMENTS
8002             set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col4,'Y',l_col44||l_invalid_date),
8003                 LOAD_STATUS = 'ERROR'
8004             where  imp_xml_element_id = l_per_imp_xml_element_id;
8005            end if;
8006            if l_col6 = 'Y' then
8007             update AMS_IMP_XML_ELEMENTS
8008             set ERROR_TEXT = ERROR_TEXT ||','||decode(l_col6,'Y',l_col66||l_invalid_date),
8009                 LOAD_STATUS = 'ERROR'
8010             where  imp_xml_element_id = l_per_imp_xml_element_id;
8011            end if;
8012        end if;
8013 
8014     end if;
8015  end if;
8016  if l_error_exist is null then
8017     if (l_col1 = 'Y' or l_col2 = 'Y' or l_col3 = 'Y' or l_col4 = 'Y' or l_col5 = 'Y' or l_col6 = 'Y') then
8018        INSERT INTO ams_list_import_errors
8019        (
8020         LIST_IMPORT_ERROR_ID,
8021         LAST_UPDATED_BY,
8022         LAST_UPDATE_DATE,
8023         CREATION_DATE,
8024         CREATED_BY,
8025         LAST_UPDATE_LOGIN,
8026         IMPORT_SOURCE_LINE_ID,
8027         IMPORT_LIST_HEADER_ID,
8028         IMPORT_TYPE,
8029         ERROR_TYPE,
8030         BATCH_ID,
8031         col227,
8032         col228,
8033         -- col229,
8034         -- col230,
8035         col233,
8036         col234,
8037         col235,
8038         col236
8039         )
8040        VALUES
8041        (
8042         ams_list_import_errors_s.nextval,      -- LIST_IMPORT_ERROR_ID,
8043         FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
8044         SYSDATE,                              -- LAST_UPDATE_DATE,
8045         SYSDATE,                              -- CREATION_DATE,
8046         FND_GLOBAL.User_ID,                   -- CREATED_BY,
8047         FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
8048         p_import_source_line_id,
8049         p_import_list_header_id,
8050         'LEAD',                                -- IMPORT_TYPE,
8051         'E',                                  -- ERROR_TYPE,
8052         p_batch_id,
8053         decode(l_col1,'Y',l_col11||l_invalid_date),
8054         decode(l_col2,'Y',l_col22||l_invalid_date),
8055         -- decode(l_col3,'Y','LAST_ORDERED_DATE:'||l_invalid_date),
8056         -- decode(l_col4,'Y','PROGRAM_UPDATE_DATE:'||l_invalid_date),
8057         -- decode(l_col5,'Y','LEAD_DATE:'||l_invalid_date)
8058         decode(l_col3,'Y',l_col33||l_invalid_date),
8059         decode(l_col4,'Y',l_col44||l_invalid_date),
8060         decode(l_col5,'Y',l_col55||l_invalid_date),
8061         decode(l_col6,'Y',l_col66||l_invalid_date)
8062         );
8063      end if;
8064  end if;
8065 EXCEPTION
8066  WHEN OTHERS THEN
8067     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
8068     FND_MESSAGE.Set_Token('ROW','Error in date_validate:' || SQLERRM||' '||SQLCODE);
8069     AMS_Utility_PVT.Create_Log (
8070       x_return_status   => l_return_status,
8071       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
8072       p_log_used_by_id  => p_import_list_header_id,
8073       p_msg_data        => FND_MESSAGE.get,
8074       p_msg_type        => 'DEBUG'
8075    );
8076 
8077 end date_validate;
8078 
8079 
8080 -- ---------------------------------------
8081 --  sranka 3/6/2003
8082 --  Using for support of "EMPLOYEE_OF"
8083 PROCEDURE execute_reltnship_validation (
8084   			    p_import_list_header_id NUMBER,
8085                             p_return_status OUT NOCOPY     VARCHAR2
8086                             ) IS
8087 
8088 --TYPE l_batch_id     IS TABLE OF AMS_IMP_SOURCE_LINES.BATCH_ID%TYPE;
8089 TYPE l_imp_list_header_id                 IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_LIST_HEADER_ID%TYPE;
8090 TYPE l_imp_source_line_id                 IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
8091 TYPE l_relationship_type         IS TABLE OF AMS_IMP_SOURCE_LINES.COL69%TYPE;
8092 TYPE l_relationship_code         IS TABLE OF AMS_IMP_SOURCE_LINES.COL70%TYPE;
8093 TYPE l_import_failure_reason     IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_FAILURE_REASON%TYPE;
8094 
8095 l_last_fetch            BOOLEAN := FALSE;
8096 l_limit_rows            number := 1000;
8097 
8098 
8099 L_MAX_ROW_COUNT                                 CONSTANT NUMBER := 1000;
8100 l_batch_id                                      NUMBER;
8101 l_BEST_TIME_CONTACT_END                         varchar2(150);
8102 l_BEST_TIME_CONTACT_BEGIN                       varchar2(150);
8103 l_last_ordered_date                             varchar2(150);
8104 x_import_list_header_id                         number;
8105 x_import_source_line_id                         number;
8106 l_invalid_number                                varchar2(4000) ;
8107 l_invalid_value                                 varchar2(4000) ;
8108 l_null_value                                    varchar2(4000) ;
8109 x_b2b                                           varchar(1);
8110 l_return_status                                 varchar(1);
8111 
8112 
8113 CURSOR c_lead_batch_id is
8114 SELECT
8115 batch_id
8116 FROM ams_imp_list_headers_all
8117 WHERE import_list_header_id = p_import_list_header_id;
8118 
8119 CURSOR  c_as_list_headers is
8120 SELECT
8121 --  BATCH_ID,
8122   IMPORT_SOURCE_LINE_ID,
8123   IMPORT_LIST_HEADER_ID,
8124   RELATIONSHIP_CODE,
8125   RELATIONSHIP_TYPE,
8126   l_invalid_value
8127 FROM
8128   AMS_HZ_B2B_MAPPING_V B2B
8129 WHERE
8130   IMPORT_LIST_HEADER_ID=p_import_list_header_id  and
8131   ( PERSON_FIRST_NAME IS NOT NULL OR PERSON_LAST_NAME IS NOT NULL )
8132   AND ((        RELATIONSHIP_CODE is not null
8133             AND RELATIONSHIP_TYPE is not null )
8134                 OR(RELATIONSHIP_CODE is  null
8135             AND RELATIONSHIP_TYPE is not null
8136                 )
8137                 OR(RELATIONSHIP_CODE is not null
8138             AND RELATIONSHIP_TYPE is  null
8139                 )
8140           )
8141   AND (nvl(RELATIONSHIP_CODE,'DUMMY')
8142   not IN (  SELECT
8143               b.FORWARD_REL_CODE
8144             FROM
8145               HZ_CODE_ASSIGNMENTS a,
8146               HZ_RELATIONSHIP_TYPES b
8147             WHERE
8148               a.owner_table_name = 'HZ_RELATIONSHIP_TYPES'  and
8149               a.owner_table_id = b.RELATIONSHIP_TYPE_ID  and
8150               a.class_code= 'PARTY_REL_GRP_CONTACTS'  and
8151               b.subject_type = 'PERSON'  and
8152               b.object_type = 'ORGANIZATION'  and
8153               b.DIRECTION_CODE = 'P'and
8154 --              B2B.RELATIONSHIP_CODE = b.FORWARD_REL_CODE
8155               B2B.RELATIONSHIP_TYPE = b.RELATIONSHIP_TYPE
8156   )
8157 --OR RELATIONSHIP_TYPE
8158 --  not IN (  SELECT
8159 --              b.RELATIONSHIP_TYPE
8160 --            FROM
8161 --              HZ_CODE_ASSIGNMENTS a,
8162 --              HZ_RELATIONSHIP_TYPES b
8163 --            WHERE
8164 --              a.owner_table_name = 'HZ_RELATIONSHIP_TYPES'  and
8165 --              a.owner_table_id = b.RELATIONSHIP_TYPE_ID  and
8166 --              a.class_code= 'PARTY_REL_GRP_CONTACTS'  and
8167 --              b.subject_type = 'PERSON'  and
8168 --              b.object_type = 'ORGANIZATION'  and
8169 --              b.DIRECTION_CODE = 'P'and
8170 --              B2B.RELATIONSHIP_TYPE = b.RELATIONSHIP_TYPE
8171 --  )
8172 
8173 );
8174 
8175 --I_batch_id l_batch_id;
8176 I_imp_source_line_id l_imp_source_line_id;
8177 I_imp_list_header_id l_imp_list_header_id;
8178 I_relationship_type l_relationship_type;
8179 I_relationship_code l_relationship_code;
8180 I_import_failure_reason l_import_failure_reason;
8181 
8182 
8183 
8184 BEGIN
8185 
8186 
8187     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_INVALID_VAL');
8188     l_invalid_value := 'RELATIONSHIP_TYPE :: RELATIONSHIP_CODE :: ' || FND_MESSAGE.get;
8189 
8190 
8191 
8192 OPEN c_lead_batch_id;
8193     FETCH c_lead_batch_id into l_batch_id;
8194 CLOSE c_lead_batch_id;
8195 
8196 
8197 open c_as_list_headers;
8198 LOOP
8199     fetch c_as_list_headers BULK COLLECT into
8200 --    I_batch_id,
8201     I_imp_source_line_id,
8202     I_imp_list_header_id,
8203     I_relationship_type,
8204     I_relationship_code,
8205     I_import_failure_reason LIMIT l_limit_rows;
8206 
8207 
8208 
8209   IF c_as_list_headers%NOTFOUND THEN
8210 
8211         l_last_fetch := TRUE;
8212   END IF;
8213 
8214   IF I_imp_source_line_id.COUNT = 0 AND l_last_fetch THEN
8215         EXIT;
8216   END IF;
8217 
8218 
8219 FORALL i IN I_imp_source_line_id.FIRST..I_imp_source_line_id.LAST
8220     INSERT INTO ams_list_import_errors
8221     (
8222         LIST_IMPORT_ERROR_ID,
8223         LAST_UPDATED_BY,
8224         LAST_UPDATE_DATE,
8225         CREATION_DATE,
8226         CREATED_BY,
8227         LAST_UPDATE_LOGIN,
8228         ERROR_TYPE,
8229         BATCH_ID,
8230         IMPORT_LIST_HEADER_ID,
8231         IMPORT_SOURCE_LINE_ID,
8232         COL1
8233     )
8234     values
8235     (
8236         ams_list_import_errors_s.nextval,      -- LIST_IMPORT_ERROR_ID,
8237         FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
8238         SYSDATE,                              -- LAST_UPDATE_DATE,
8239         SYSDATE,                              -- CREATION_DATE,
8240         FND_GLOBAL.User_ID,                   -- CREATED_BY,
8241         FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
8242         'E',
8243         l_batch_id,
8244         I_imp_list_header_id(i),
8245         I_imp_source_line_id(i),
8246         I_import_failure_reason(i)
8247     );
8248   COMMIT;
8249 --
8250   IF  l_last_fetch = TRUE THEN
8251      EXIT;
8252   END IF;
8253 
8254 END LOOP;
8255 CLOSE c_as_list_headers;
8256 
8257 
8258 
8259        UPDATE ams_imp_source_lines
8260          SET load_status = 'ERROR'
8261        WHERE import_list_header_id = p_import_list_header_id
8262          and import_source_line_id in
8263        (select import_source_line_id from ams_list_import_errors
8264         where import_list_header_id = p_import_list_header_id
8265           and error_type = 'E');
8266 
8267 
8268 EXCEPTION
8269  WHEN OTHERS THEN
8270     p_return_status := FND_API.G_RET_STS_ERROR;
8271     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
8272     FND_MESSAGE.Set_Token('ROW','Error in execute_relationship_validation:' || SQLERRM||' '||SQLCODE);
8273     AMS_Utility_PVT.Create_Log (
8274       x_return_status   => l_return_status,
8275       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
8276       p_log_used_by_id  => p_import_list_header_id,
8277       p_msg_data        => FND_MESSAGE.get,
8278       p_msg_type        => 'DEBUG'
8279    );
8280 
8281 end execute_reltnship_validation;
8282 
8283 
8284 
8285 
8286 
8287 
8288 PROCEDURE execute_cust_data_validation (
8289   			    p_import_list_header_id NUMBER,
8290                             p_return_status OUT NOCOPY     VARCHAR2
8291                             ) IS
8292 
8293 TYPE num_data_set_type_w IS
8294   TABLE OF NUMBER INDEX BY BINARY_INTEGER;
8295 
8296 TYPE varchar2_250_set_type IS
8297         TABLE OF VARCHAR2(250) INDEX BY BINARY_INTEGER;
8298 
8299 L_MAX_ROW_COUNT                                 CONSTANT NUMBER := 1000;
8300 l_batch_id                                      NUMBER;
8301 l_ADDRESS_EFFECTIVE_DATE			varchar2(150);
8302 l_ADDRESS_EXPIRATION_DATE			varchar2(150);
8303 l_DATE_OF_BIRTH					varchar2(150);
8304 l_DATE_OF_DEATH					varchar2(150);
8305 l_DEBARTMENTS_DATE				varchar2(150);
8306 l_MARITAL_STATUS_EFF_DATE			varchar2(150);
8307 l_last_ordered_date                             varchar2(150);
8308 x_import_list_header_id                         number;
8309 x_import_source_line_id                         number;
8310 l_invalid_number varchar2(4000) ;
8311 l_invalid_size   varchar2(4000) ;
8312 l_null_value     varchar2(4000) ;
8313 x_b2b                           varchar(30);
8314 l_return_status                 varchar(1);
8315 l_imp_type         varchar2(60);
8316 
8317 
8318        l_import_source_line_id                 num_data_set_type_w;
8319        l_import_list_header_id                 num_data_set_type_w;
8320 
8321        l_col1                                  varchar2_250_set_type;
8322        l_col2                                  varchar2_250_set_type;
8323        l_col3                                  varchar2_250_set_type;
8324        l_col4                                  varchar2_250_set_type;
8325        l_col5                                  varchar2_250_set_type;
8326        l_col6                                  varchar2_250_set_type;
8327        l_col7                                  varchar2_250_set_type;
8328        l_col8                                  varchar2_250_set_type;
8329        l_col9                                  varchar2_250_set_type;
8330        l_col10                                 varchar2_250_set_type;
8331        l_col11                                 varchar2_250_set_type;
8332        l_col12                                 varchar2_250_set_type;
8333        l_col13                                 varchar2_250_set_type;
8334        l_col14                                 varchar2_250_set_type;
8335        l_col15                                 varchar2_250_set_type;
8336        l_col16                                 varchar2_250_set_type;
8337        l_col17                                 varchar2_250_set_type;
8338        l_col18                                 varchar2_250_set_type;
8339        l_col19                                 varchar2_250_set_type;
8340        l_col20                                 varchar2_250_set_type;
8341        l_col21                                 varchar2_250_set_type;
8342        l_col22                                 varchar2_250_set_type;
8343        l_col23                                 varchar2_250_set_type;
8344        l_col24                                 varchar2_250_set_type;
8345        l_col25                                 varchar2_250_set_type;
8346        l_col26                                 varchar2_250_set_type;
8347        l_col27                                 varchar2_250_set_type;
8348        l_col28                                 varchar2_250_set_type;
8349        l_col29                                 varchar2_250_set_type;
8350        l_col30                                 varchar2_250_set_type;
8351        l_col31                                 varchar2_250_set_type;
8352        l_col32                                 varchar2_250_set_type;
8353        l_col33                                 varchar2_250_set_type;
8354        l_col34                                 varchar2_250_set_type;
8355        l_col35                                 varchar2_250_set_type;
8356        l_col36                                 varchar2_250_set_type;
8357        l_col37                                 varchar2_250_set_type;
8358        l_col38                                 varchar2_250_set_type;
8359        l_col39                                 varchar2_250_set_type;
8360        l_col40                                 varchar2_250_set_type;
8361        l_col41                                 varchar2_250_set_type;
8362        l_col42                                 varchar2_250_set_type;
8363        l_col43                                 varchar2_250_set_type;
8364        l_col44                                 varchar2_250_set_type;
8365        l_col45                                 varchar2_250_set_type;
8366        l_col46                                 varchar2_250_set_type;
8367        l_col47                                 varchar2_250_set_type;
8368        l_col48                                 varchar2_250_set_type;
8369        l_col49                                 varchar2_250_set_type;
8370        l_col50                                 varchar2_250_set_type;
8371        l_col51                                 varchar2_250_set_type;
8372        l_col52                                 varchar2_250_set_type;
8373        l_col53                                 varchar2_250_set_type;
8374        l_col54                                 varchar2_250_set_type;
8375        l_col55                                 varchar2_250_set_type;
8376        l_col56                                 varchar2_250_set_type;
8377        l_col57                                 varchar2_250_set_type;
8378        l_col58                                 varchar2_250_set_type;
8379        l_col59                                 varchar2_250_set_type;
8380        l_col60                                 varchar2_250_set_type;
8381        l_col61                                 varchar2_250_set_type;
8382        l_col62                                 varchar2_250_set_type;
8383        l_col63                                 varchar2_250_set_type;
8384        l_col64                                 varchar2_250_set_type;
8385        l_col65                                 varchar2_250_set_type;
8386        l_col66                                 varchar2_250_set_type;
8387        l_col67                                 varchar2_250_set_type;
8388        l_col68                                 varchar2_250_set_type;
8389        l_col69                                 varchar2_250_set_type;
8390        l_col70                                 varchar2_250_set_type;
8391        l_col71                                 varchar2_250_set_type;
8392        l_col72                                 varchar2_250_set_type;
8393        l_col73                                 varchar2_250_set_type;
8394        l_col74                                 varchar2_250_set_type;
8395        l_col75                                 varchar2_250_set_type;
8396        l_col76                                 varchar2_250_set_type;
8397        l_col77                                 varchar2_250_set_type;
8398        l_col78                                 varchar2_250_set_type;
8399        l_col79                                 varchar2_250_set_type;
8400        l_col80                                 varchar2_250_set_type;
8401        l_col81                                 varchar2_250_set_type;
8402        l_col82                                 varchar2_250_set_type;
8403        l_col83                                 varchar2_250_set_type;
8404        l_col84                                 varchar2_250_set_type;
8405        l_col85                                 varchar2_250_set_type;
8406        l_col86                                 varchar2_250_set_type;
8407        l_col87                                 varchar2_250_set_type;
8408        l_col88                                 varchar2_250_set_type;
8409        l_col89                                 varchar2_250_set_type;
8410        l_col90                                 varchar2_250_set_type;
8411        l_col91                                 varchar2_250_set_type;
8412        l_col92                                 varchar2_250_set_type;
8413        l_col93                                 varchar2_250_set_type;
8414        l_col94                                 varchar2_250_set_type;
8415        l_col95                                 varchar2_250_set_type;
8416        l_col96                                 varchar2_250_set_type;
8417        l_col97                                 varchar2_250_set_type;
8418        l_col98                                 varchar2_250_set_type;
8419        l_col99                                 varchar2_250_set_type;
8420        l_col100                                varchar2_250_set_type;
8421        l_col101                                varchar2_250_set_type;
8422        l_col102                                varchar2_250_set_type;
8423        l_col103                                varchar2_250_set_type;
8424        l_col104                                varchar2_250_set_type;
8425        l_col105                                varchar2_250_set_type;
8426        l_col106                                varchar2_250_set_type;
8427        l_col107                                varchar2_250_set_type;
8428        l_col108                                varchar2_250_set_type;
8429        l_col109                                varchar2_250_set_type;
8430        l_col110                                varchar2_250_set_type;
8431        l_col111                                varchar2_250_set_type;
8432        l_col112                                varchar2_250_set_type;
8433        l_col113                                varchar2_250_set_type;
8434        l_col114                                varchar2_250_set_type;
8435        l_col115                                varchar2_250_set_type;
8436        l_col116                                varchar2_250_set_type;
8437        l_col117                                varchar2_250_set_type;
8438        l_col118                                varchar2_250_set_type;
8439        l_col119                                varchar2_250_set_type;
8440        l_col120                                varchar2_250_set_type;
8441        l_col121                                varchar2_250_set_type;
8442        l_col122                                varchar2_250_set_type;
8443        l_col123                                varchar2_250_set_type;
8444        l_col124                                varchar2_250_set_type;
8445        l_col125                                varchar2_250_set_type;
8446        l_col126                                varchar2_250_set_type;
8447        l_col127                                varchar2_250_set_type;
8448        l_col128                                varchar2_250_set_type;
8449        l_col129                                varchar2_250_set_type;
8450        l_col130                                varchar2_250_set_type;
8451        l_col131                                varchar2_250_set_type;
8452        l_col132                                varchar2_250_set_type;
8453        l_col133                                varchar2_250_set_type;
8454        l_col134                                varchar2_250_set_type;
8455        l_col135                                varchar2_250_set_type;
8456        l_col136                                varchar2_250_set_type;
8457        l_col137                                varchar2_250_set_type;
8458        l_col138                                varchar2_250_set_type;
8459        l_col139                                varchar2_250_set_type;
8460        l_col140                                varchar2_250_set_type;
8461        l_col141                                varchar2_250_set_type;
8462        l_col142                                varchar2_250_set_type;
8463        l_col143                                varchar2_250_set_type;
8464        l_col144                                varchar2_250_set_type;
8465        l_col145                                varchar2_250_set_type;
8466        l_col146                                varchar2_250_set_type;
8467        l_col147                                varchar2_250_set_type;
8468        l_col148                                varchar2_250_set_type;
8469        l_col149                                varchar2_250_set_type;
8470        l_col150                                varchar2_250_set_type;
8471        l_col151                                varchar2_250_set_type;
8472        l_col152                                varchar2_250_set_type;
8473        l_col153                                varchar2_250_set_type;
8474        l_col154                                varchar2_250_set_type;
8475        l_col155                                varchar2_250_set_type;
8476        l_col156                                varchar2_250_set_type;
8477        l_col157                                varchar2_250_set_type;
8478        l_col158                                varchar2_250_set_type;
8479        l_col159                                varchar2_250_set_type;
8480        l_col160                                varchar2_250_set_type;
8481        l_col161                                varchar2_250_set_type;
8482        l_col162                                varchar2_250_set_type;
8483        l_col163                                varchar2_250_set_type;
8484        l_col164                                varchar2_250_set_type;
8485        l_col165                                varchar2_250_set_type;
8486        l_col166                                varchar2_250_set_type;
8487        l_col167                                varchar2_250_set_type;
8488        l_col168                                varchar2_250_set_type;
8489        l_col169                                varchar2_250_set_type;
8490        l_col170                                varchar2_250_set_type;
8491        l_col171                                varchar2_250_set_type;
8492        l_col172                                varchar2_250_set_type;
8493        l_col173                                varchar2_250_set_type;
8494        l_col174                                varchar2_250_set_type;
8495        l_col175                                varchar2_250_set_type;
8496        l_col176                                varchar2_250_set_type;
8497        l_col177                                varchar2_250_set_type;
8498        l_col178                                varchar2_250_set_type;
8499        l_col179                                varchar2_250_set_type;
8500        l_col180                                varchar2_250_set_type;
8501        l_col181                                varchar2_250_set_type;
8502        l_col182                                varchar2_250_set_type;
8503        l_col183                                varchar2_250_set_type;
8504        l_col184                                varchar2_250_set_type;
8505        l_col185                                varchar2_250_set_type;
8506        l_col186                                varchar2_250_set_type;
8507        l_col187                                varchar2_250_set_type;
8508        l_col188                                varchar2_250_set_type;
8509        l_col189                                varchar2_250_set_type;
8510        l_col190                                varchar2_250_set_type;
8511        l_col191                                varchar2_250_set_type;
8512        l_col192                                varchar2_250_set_type;
8513        l_col193                                varchar2_250_set_type;
8514        l_col194                                varchar2_250_set_type;
8515        l_col195                                varchar2_250_set_type;
8516        l_col196                                varchar2_250_set_type;
8517        l_col197                                varchar2_250_set_type;
8518        l_col198                                varchar2_250_set_type;
8519        l_col199                                varchar2_250_set_type;
8520        l_col200                                varchar2_250_set_type;
8521        l_col201                                varchar2_250_set_type;
8522 -- sranka modiefied for COLT Enhacement 7/15/2003
8523         l_col221   varchar2_250_set_type;
8524         l_col222   varchar2_250_set_type;
8525         l_col223   varchar2_250_set_type;
8526         l_col224   varchar2_250_set_type;
8527         l_col225   varchar2_250_set_type;
8528         l_col226   varchar2_250_set_type;
8529         l_col227   varchar2_250_set_type;
8530         l_col228   varchar2_250_set_type;
8531         l_col229   varchar2_250_set_type;
8532         l_col230   varchar2_250_set_type;
8533         l_col231   varchar2_250_set_type;
8534         l_col232   varchar2_250_set_type;
8535         l_col233   varchar2_250_set_type;
8536         l_col234   varchar2_250_set_type;
8537         l_col235   varchar2_250_set_type;
8538         l_col236   varchar2_250_set_type;
8539         l_col237   varchar2_250_set_type;
8540         l_col238   varchar2_250_set_type;
8541         l_col239   varchar2_250_set_type;
8542         l_col240   varchar2_250_set_type;
8543         l_col241   varchar2_250_set_type;
8544         l_col242   varchar2_250_set_type;
8545         l_col243   varchar2_250_set_type;
8546         l_col244   varchar2_250_set_type;
8547         l_col245   varchar2_250_set_type;
8548         l_col246   varchar2_250_set_type;
8549         l_col247   varchar2_250_set_type;
8550         l_col248   varchar2_250_set_type;
8551         l_col249   varchar2_250_set_type;
8552         l_col251   varchar2_250_set_type;
8553         l_col252   varchar2_250_set_type;
8554         l_col253   varchar2_250_set_type;
8555         l_col254   varchar2_250_set_type;
8556         l_col255   varchar2_250_set_type;
8557         l_col256   varchar2_250_set_type;
8558         l_col257   varchar2_250_set_type;
8559         l_col258   varchar2_250_set_type;
8560         l_col259   varchar2_250_set_type;
8561         l_col260   varchar2_250_set_type;
8562         l_col261   varchar2_250_set_type;
8563         l_col262   varchar2_250_set_type;
8564         l_col263   varchar2_250_set_type;
8565         l_col264   varchar2_250_set_type;
8566         l_col265   varchar2_250_set_type;
8567         l_col266   varchar2_250_set_type;
8568         l_col267   varchar2_250_set_type;
8569         l_col268   varchar2_250_set_type;
8570         l_col269   varchar2_250_set_type;
8571         l_col270   varchar2_250_set_type;
8572         l_col271   varchar2_250_set_type;
8573         l_col272   varchar2_250_set_type;
8574         l_col273   varchar2_250_set_type;
8575         l_col274   varchar2_250_set_type;
8576         l_col275   varchar2_250_set_type;
8577         l_col276   varchar2_250_set_type;
8578         l_col277   varchar2_250_set_type;
8579         l_col278   varchar2_250_set_type;
8580         l_col279   varchar2_250_set_type;
8581         l_col280   varchar2_250_set_type;
8582         l_col281   varchar2_250_set_type;
8583         l_col282   varchar2_250_set_type;
8584         l_col283   varchar2_250_set_type;
8585         l_col284   varchar2_250_set_type;
8586         l_col285   varchar2_250_set_type;
8587         l_col286   varchar2_250_set_type;
8588         l_col287   varchar2_250_set_type;
8589         l_col288   varchar2_250_set_type;
8590         l_col289   varchar2_250_set_type;
8591         l_col290   varchar2_250_set_type;
8592         l_col291   varchar2_250_set_type;
8593         l_col292   varchar2_250_set_type;
8594         l_col293   varchar2_250_set_type;
8595         l_col294   varchar2_250_set_type;
8596         l_col295   varchar2_250_set_type;
8597         l_col296   varchar2_250_set_type;
8598         l_col297   varchar2_250_set_type;
8599         l_col298   varchar2_250_set_type;
8600         l_col299   varchar2_250_set_type;
8601         l_col300   varchar2_250_set_type;
8602         l_col301   varchar2_250_set_type;
8603         l_col302   varchar2_250_set_type;
8604 
8605 CURSOR c_lead_batch_id is
8606 SELECT
8607 batch_id
8608 FROM ams_imp_list_headers_all
8609 WHERE import_list_header_id = p_import_list_header_id;
8610 
8611 -- Cursor for B2B party type
8612 
8613 cursor b2b is
8614  SELECT
8615  IMPORT_SOURCE_LINE_ID,
8616  import_list_header_id,
8617 DECODE(GREATEST(lengthb(LTRIM(RTRIM(PARTY_NAME))),255) - 255,0,' ','PARTY_NAME :'||decode(nvl(PARTY_NAME,'x'),'x',l_null_value,l_invalid_size)||'(255)') PARTY_NAME,
8618 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FISCAL_YEAREND_MONTH)),'x')),30) - 30,0,' ','FISCAL_YEAREND_MONTH :'||l_invalid_size||'(30)') FISCAL_YEAREND_MONTH,
8619 /*
8620 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DUNS_NUMBER,' ','x'))),'0123456789.',           'x'))),0),0,' ','DUNS_NUMBER :'||l_invalid_number) DUNS_NUMBER,
8621 */
8622 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DUNS_NUMBER)),'x')),30) - 30,0,' ','DUNS_NUMBER:'||l_invalid_size||'(30)') DUNS_NUMBER,
8623 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(EMPLOYEES_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,' ','EMPLOYEES_TOTAL :'||l_invalid_number) EMPLOYEES_TOTAL,
8624 DECODE(GREATEST(lengthb(nvl(LINE_OF_BUSINESS,'x')),240) - 240,0,' ','LINE_OF_BUSINESS :'||l_invalid_size) LINE_OF_BUSINESS,
8625 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,' ','ADDRESS1 :'||l_invalid_size||'(240)') ADDRESS1,
8626 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,' ','ADDRESS2 :'||l_invalid_size||'(240)') ADDRESS2,
8627 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,' ','ADDRESS3 :'||l_invalid_size||'(240)') ADDRESS3,
8628 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,' ','ADDRESS4 :'||l_invalid_size||'(240)') ADDRESS4,
8629 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(YEAR_ESTABLISHED,' ','x'))),'0123456789.','           x'))),0),0,' ','YEAR_ESTABLISHED :'||l_invalid_number) YEAR_ESTABLISHED,
8630 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),50) - 50,0,' ','TAX_REFERENCE :'||l_invalid_size||'(50)') TAX_REFERENCE,
8631 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CEO_NAME)),'x')),240) - 240,0,' ','CEO_NAME :'||l_invalid_size||'(240)') CEO_NAME,
8632 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME)),'x')),50) - 50,0,' ','PERSON_LAST_NAME :'||l_invalid_size||'(50)') PERSON_LAST_NAME,
8633 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME)),'x')),40) - 40,0,' ','PERSON_FIRST_NAME :'||l_invalid_size||'(40)') PERSON_FIRST_NAME,
8634 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,' ','PERSON_NAME_PREFIX :'||l_invalid_size||'(30)') PERSON_NAME_PREFIX,
8635 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE)),'x')),100) - 100,0,' ','JOB_TITLE :'||l_invalid_size||'(100)') JOB_TITLE,
8636 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,' ','PERSON_MIDDLE_NAME :'||l_invalid_size||'(60)') PERSON_MIDDLE_NAME,
8637 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,' ','PERSON_NAME_SUFFIX :'||l_invalid_size||'(30)') PERSON_NAME_SUFFIX,
8638 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,' ','CITY :'||l_invalid_size||'(60)') CITY ,
8639 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,' ','POSTAL_CODE :'||l_invalid_size||'(60)') POSTAL_CODE,
8640 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,' ','STATE :'||l_invalid_size||'(60)') STATE,
8641 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,' ','PROVINCE :'||l_invalid_size||'(60)') PROVINCE,
8642 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,' ','COUNTY :'||l_invalid_size||'(60)') COUNTY,
8643 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,' ','COUNTRY :'||l_invalid_size||'(60)') COUNTRY,
8644 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,' ','TIME_ZONE :'||l_invalid_size||'(50)') TIME_ZONE,
8645 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,' ','EMAIL_ADDRESS :'||l_invalid_size||'(240)') EMAIL_ADDRESS,
8646 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,' ','PHONE_COUNTRY_CODE :'||l_invalid_size||'(30)') PHONE_COUNTRY_CODE,
8647 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,' ','PHONE_AREA_CODE :'||l_invalid_size||'(10)') PHONE_AREA_CODE,
8648 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,' ','PHONE_NUMBER :'||l_invalid_size||'(25)') PHONE_NUMBER,
8649 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,' ','PHONE_EXTENTION :'||l_invalid_size||'(20)') PHONE_EXTENTION,
8650 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT)),'x')),60) - 60,0,' ','DEPARTMENT :'||l_invalid_size||'(60)') DEPARTMENT,
8651 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,' ','DECISION_MAKER_FLAG :'||l_invalid_size||'(1)') DECISION_MAKER_FLAG,
8652 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE)),'x')),30) - 30,0,' ','SIC_CODE :'||l_invalid_size||'(30)') SIC_CODE,
8653 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE_TYPE)),'x')),30) - 30,0,' ','SIC_CODE_TYPE :'||l_invalid_size||'(30)') SIC_CODE_TYPE,
8654 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_NUM_OF_ORDERS,' ','x'))),'0123456789.','           x'))),0),0,' ','TOTAL_NUM_OF_ORDERS :'||l_invalid_number) TOTAL_NUM_OF_ORDERS,
8655 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_ORDERED_AMOUNT,' ','x'))),'0123456789.','           x'))),0),0,' ','TOTAL_ORDERED_AMOUNT :'||l_invalid_number) TOTAL_ORDERED_AMOUNT,
8656 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ANALYSIS_FY)),'x')),5) - 5,0,' ','ANALYSIS_FY :'||l_invalid_size||'(5)') ANALYSIS_FY,
8657 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CURR_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,' ','CURR_FY_POTENTIAL_REVENUE :'||l_invalid_number) CURR_FY_POTENTIAL_REVENUE,
8658 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(NEXT_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,' ','NEXT_FY_POTENTIAL_REVENUE :'||l_invalid_number) NEXT_FY_POTENTIAL_REVENUE,
8659 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GSA_INDICATOR_FLAG)),'x')),1) - 1,0,' ','GSA_INDICATOR_FLAG :'||l_invalid_size||'(1)') GSA_INDICATOR_FLAG,
8660 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OVERSEAS_ADDRESS_FLAG)),'x')),1) - 1,0,' ','OVERSEAS_ADDRESS_FLAG :'||l_invalid_size||'(1)') OVERSEAS_ADDRESS_FLAG,
8661 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,' ','identifying_address_flag :'||l_invalid_size||'(1)') identifying_address_flag,
8662 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(APARTMENT_FLAG)),'x')),1) - 1,0,' ','APARTMENT_FLAG :'||l_invalid_size||'(1)') APARTMENT_FLAG,
8663 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MISSION_STATEMENT)),'x')),2000) - 2000,0,' ','MISSION_STATEMENT :'||l_invalid_size||'(2000)') MISSION_STATEMENT,
8664 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_NAME_PHONETIC)),'x')),320) - 320,0,' ','ORGANIZATION_NAME_PHONETIC :'||l_invalid_size||'(320)') ORGANIZATION_NAME_PHONETIC,
8665 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CATEGORY_CODE)),'x')),30) -30,0,' ','CATEGORY_CODE:'||l_invalid_size||'(30)') CATEGORY_CODE,
8666 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JGZZ_FISCAL_CODE)),'x')),20) - 20,0,' ','JGZZ_FISCAL_CODE :'||l_invalid_size||'(20)') JGZZ_FISCAL_CODE,
8667 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_NAME)),'x')),60) - 60,0,' ','TAX_NAME :'||l_invalid_size||'(60)') TAX_NAME,
8668 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,' ','ADDRESS_LINES_PHONETIC :'||l_invalid_size||'(560)') ADDRESS_LINES_PHONETIC,
8669 -- bug 4641591: columns obsolete
8670 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,' ','PO_BOX_NUMBER :'||l_invalid_size||'(50)') PO_BOX_NUMBER,
8671 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,' ','FLOOR :'||l_invalid_size||'(50)') FLOOR,
8672 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,' ','HOUSE_NUMBER :'||l_invalid_size||'(50)') HOUSE_NUMBER,
8673 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),10) - 10,0,' ','POSTAL_PLUS4_CODE :'||l_invalid_size||'(10)') POSTAL_PLUS4_CODE,
8674 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,' ','STREET_SUFFIX :'||l_invalid_size||'(50)') STREET_SUFFIX,
8675 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECONDARY_SUFFIX_ELENENT)),'x')),240) - 240,0,' ','SECONDARY_SUFFIX_ELENENT :'||l_invalid_size||'(240)') SECONDARY_SUFFIX_ELENENT,
8676 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,' ','STREET :'||l_invalid_size||'(50)') STREET,
8677 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,' ','STREET_NUMBER :'||l_invalid_size||'(50)') STREET_NUMBER,
8678 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SUITE)),'x')),50) - 50,0,' ','SUITE :'||l_invalid_size||'(50)') SUITE,
8679 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_TYPE)),'x')),50) - 50,0,' ','RURAL_ROUTE_TYPE :'||l_invalid_size||'(50)') RURAL_ROUTE_TYPE,
8680 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_NUMBER)),'x')),50) - 50,0,' ','RURAL_ROUTE_NUMBER :'||l_invalid_size||'(50)') RURAL_ROUTE_NUMBER,
8681 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,' ','PARTY_ID :'||l_invalid_number) party_id,
8682 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_URL)),'x')),2000) - 2000,0,' ','ORGANIZATION_URL :'||l_invalid_size||'(2000)') ORGANIZATION_URL,
8683 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BRANCH_FLAG)),'x')),1) - 1,0,' ','BRANCH_FLAG :'||l_invalid_size||'(1)') BRANCH_FLAG,
8684 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_LINE)),'x')),240) - 240,0,' ','BUSINESS_LINE :'||l_invalid_size||'(240)') BUSINESS_LINE,
8685 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_SCOPE)),'x')),20) - 20,0,' ','BUSINESS_SCOPE :'||l_invalid_size||'(20)') BUSINESS_SCOPE,
8686 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CHIEF_EXECUTIVE_TITLE)),'x')),240) - 240,0,' ','CHIEF_EXECUTIVE_TITLE :'||l_invalid_size||'(240)') CHIEF_EXECUTIVE_TITLE,
8687 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONGRESSIONAL_DISTRICT_CODE)),'x')),2) - 2,0,' ','CONGRESSIONAL_DISTRICT_CODE :'||l_invalid_size||'(2)') CONGRESSIONAL_DISTRICT_CODE,
8688 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CORPORATION_CLASS)),'x')),60) - 60,0,' ','CORPORATION_CLASS :'||l_invalid_size||'(60)') CORPORATION_CLASS,
8689 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE)),'x')),30) - 30,0,' ','CREDIT_SCORE :'||l_invalid_size||'(30)') CREDIT_SCORE,
8690 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE_COMMENTARY)),'x')),30) - 30,0,' ','CREDIT_SCORE_COMMENTARY :'||l_invalid_size||'(30)') CREDIT_SCORE_COMMENTARY,
8691 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DB_RATING)),'x')),5) - 5,0,' ','DB_RATING :'||l_invalid_size||'(5)') DB_RATING,
8692 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,' ','DECLARED_ETHNICITY :'||l_invalid_size||'(60)') DECLARED_ETHNICITY,
8693 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT_INDICATOR)),'x')),30) - 30,0,' ','DEPARTMENT_INDICATOR :'||l_invalid_size||'(30)') DEPARTMENT_INDICATOR,
8694 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION:'||l_invalid_size||'(2000)') DESCRIPTION,
8695 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DISADVANTAGED_INDICATOR)),'x')),30) - 30,0,' ','DISADVANTAGED_INDICATOR :'||l_invalid_size||'(30)') DISADVANTAGED_INDICATOR,
8696 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ENQUIRY_DUNS)),'x')),15) - 15,0,' ','ENQUIRY_DUNS :'||l_invalid_size||'(15)') ENQUIRY_DUNS,
8697 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EXPORT_INDICATOR)),'x')),30) - 30,0,' ','EXPORT_INDICATOR :'||l_invalid_size||'(30)') EXPORT_INDICATOR,
8698 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE)),'x')),30) - 30,0,' ','FAILURE_SCORE :'||l_invalid_size||'(30)') FAILURE_SCORE,
8699 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_COMMENTARY)),'x')),30) - 30,0,' ','FAILURE_SCORE_COMMENTARY :'||l_invalid_size||'(30)') FAILURE_SCORE_COMMENTARY,
8700 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_OVERRIDE_CODE)),'x')),30) - 30,0,' ','FAILURE_SCORE_OVERRIDE_CODE :'||l_invalid_size||'(30)') FAILURE_SCORE_OVERRIDE_CODE,
8701 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GLOBAL_FAILURE_SCORE)),'x')),5) - 5,0,' ','GLOBAL_FAILURE_SCORE :'||l_invalid_size||'(5)') GLOBAL_FAILURE_SCORE,
8702 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEADQUARTER_BRANCH_INDICATOR)),'x')),30) - 30,0,' ','HEADQUARTER_BRANCH_INDICATOR :'||l_invalid_size||'(30)') HEADQUARTER_BRANCH_INDICATOR,
8703 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEAD_OF_HOUSEHOLD_FLAG)),'x')),1) - 1,0,' ','HEAD_OF_HOUSEHOLD_FLAG :'||l_invalid_size||'(1)') HEAD_OF_HOUSEHOLD_FLAG,
8704 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(IMPORT_INDICATOR)),'x')),30) - 30,0,' ','IMPORT_INDICATOR :'||l_invalid_size||'(30)') IMPORT_INDICATOR,
8705 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS,
8706 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS2)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS2 :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS2,
8707 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS3)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS3 :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS3,
8708 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS4)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS4 :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS4,
8709 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS5)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS5:'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS5,
8710 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS :'||l_invalid_size||'(240)') PERSON_KNOWN_AS,
8711 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS2 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS2,
8712 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS3 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS3,
8713 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS4 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS4,
8714 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS5 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS5,
8715 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LABOR_SURPLUS_INDICATOR)),'x')),30) - 30,0,' ','LABOR_SURPLUS_INDICATOR :'||l_invalid_size||'(30)') LABOR_SURPLUS_INDICATOR,
8716 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE)),'x')),30) - 30,0,' ','LOCAL_ACTIVITY_CODE :'||l_invalid_size||'(30)') LOCAL_ACTIVITY_CODE,
8717 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE_TYPE)),'x')),30) - 30,0,' ','LOCAL_ACTIVITY_CODE_TYPE :'||l_invalid_size||'(30)') LOCAL_ACTIVITY_CODE_TYPE,
8718 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,' ','LOCATION_DIRECTIONS :'||l_invalid_size||'(640)') LOCATION_DIRECTIONS,
8719 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,' ','MARITAL_STATUS :'||l_invalid_size||'(30)') MARITAL_STATUS,
8720 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_INDICATOR)),'x')),30) - 30,0,' ','MINORITY_OWNED_INDICATOR :'||l_invalid_size||'(30)') MINORITY_OWNED_INDICATOR,
8721 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_TYPE)),'x')),30) - 30,0,' ','MINORITY_OWNED_TYPE :'||l_invalid_size||'(30)') MINORITY_OWNED_TYPE,
8722 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_TYPE)),'x')),30) - 30,0,' ','ORGANIZATION_TYPE :'||l_invalid_size||'(30)') ORGANIZATION_TYPE,
8723 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OUT_OF_BUSINESS_INDICATOR)),'x')),30) - 30,0,' ','OUT_OF_BUSINESS_INDICATOR :'||l_invalid_size||'(30)') OUT_OF_BUSINESS_INDICATOR,
8724 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,' ','PERSON_ACADEMIC_TITLE :'||l_invalid_size||'(30)') PERSON_ACADEMIC_TITLE,
8725 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_FIRST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_FIRST_NAME_PHONETIC,
8726 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_LAST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_LAST_NAME_PHONETIC,
8727 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,' ','MIDDLE_NAME_PHONETIC :'||l_invalid_size||'(60)') MIDDLE_NAME_PHONETIC,
8728 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),320) - 320,0,' ','PERSON_NAME_PHONETIC :'||l_invalid_size||'(320)') PERSON_NAME_PHONETIC,
8729 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,' ','PERSON_PREVIOUS_TITLE_NAME :'||l_invalid_size||'(150)') PERSON_PREVIOUS_TITLE_NAME,
8730 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PLACE_OF_BIRTH)),'x')),60) - 60,0,' ','PLACE_OF_BIRTH :'||l_invalid_size||'(60)') PLACE_OF_BIRTH,
8731 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_NAME)),'x')),240) - 240,0,' ','PRINCIPAL_NAME :'||l_invalid_size||'(240)') PRINCIPAL_NAME,
8732 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_TITLE)),'x')),240) - 240,0,' ','PRINCIPAL_TITLE :'||l_invalid_size||'(240)') PRINCIPAL_TITLE,
8733 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PUBLIC_PRIVATE_OWNERSHIP_FLAG)),'x')),1) - 1,0,' ','PUBLIC_PRIVATE_OWNERSHIP_FLAG :'||l_invalid_size||'(1)') PUBLIC_PRIVATE_OWNERSHIP_FLAG,
8734 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,' ','RENT_OWNED_INDICATOR :'||l_invalid_size||'(30)') RENT_OWNED_INDICATOR,
8735 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECOND_TITLE)),'x')),30) - 30,0,' ','SECOND_TITLE :'||l_invalid_size||'(30)') SECOND_TITLE,
8736 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,
8737 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SMALL_BUSINESS_INDICATOR)),'x')),30) - 30,0,' ','SMALL_BUSINESS_INDICATOR :'||l_invalid_size||'(30)') SMALL_BUSINESS_INDICATOR,
8738 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_ID)),'x')),60) - 60,0,' ','TAX_ID :'||l_invalid_size||'(60)') TAX_ID,
8739 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(WOMAN_OWNED_INDICATOR)),'x')),30) - 30,0,' ',' WOMAN_OWNED_INDICATOR :'||l_invalid_size||'(30)') WOMAN_OWNED_INDICATOR,
8740 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE1,
8741 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE2,
8742 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE3,
8743 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE4,
8744 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE5,
8745 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE6,
8746 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE7,
8747 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE8,
8748 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE9,
8749 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE10,
8750 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE11)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE11 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE11,
8751 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE12,
8752 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE13,
8753 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE14,
8754 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE15,
8755 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE1)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE1 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE1,
8756 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE2)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE2 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE2,
8757 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE3)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE3 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE3,
8758 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE4)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE4 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE4,
8759 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE5)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE5 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE5,
8760 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE6)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE6 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE6,
8761 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE7)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE7 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE7,
8762 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE8)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE8 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE8,
8763 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE9)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE9 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE9,
8764 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE10)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE10 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE10,
8765 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE11)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE11 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE11,
8766 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE12)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE12 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE12,
8767 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE13)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE13 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE13,
8768 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE14)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE14 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE14,
8769 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE15)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE15 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE15,
8770 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE1,
8771 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE2,
8772 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE3,
8773 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE4,
8774 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE5,
8775 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE6,
8776 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE7,
8777 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE8,
8778 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE9,
8779 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE10,
8780 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE11,
8781 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE13,
8782 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE14,
8783 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE15,
8784 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE12,
8785 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE1 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE1,
8786 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE2 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE2,
8787 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE3 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE3,
8788 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE4 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE4,
8789 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE5 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE5,
8790 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE6 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE6,
8791 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE7 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE7,
8792 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE8 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE8,
8793 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE9 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE9,
8794 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE10 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE10,
8795 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE11 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE11,
8796 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE12 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE12,
8797 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE13 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE13,
8798 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE14 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE14,
8799 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE15 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE15,
8800 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,' ','FAX_COUNTRY_CODE :'||l_invalid_size||'(10)') FAX_COUNTRY_CODE,
8801 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,' ','FAX_AREA_CODE :'||l_invalid_size||'(10)') FAX_AREA_CODE,
8802 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,' ','FAX_NUMBER :'||l_invalid_size||'(40)') FAX_NUMBER,
8803 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_ATTRIBUTE_CATEGORY,
8804 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','PERSON_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') PERSON_ATTRIBUTE_CATEGORY,
8805 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_CONTACT_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_CONTACT_ATTRIBUTE_CATEGORY,
8806 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ADDRESS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ADDRESS_ATTRIBUTE_CATEGORY,
8807 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CONTROL_YEAR,' ','x'))),'0123456789.','           x'))),0),0,' ','CONTROL_YEAR :'||l_invalid_number) CONTROL_YEAR,
8808 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DEBARMENTS_COUNT,' ','x'))),'0123456789.','           x'))),0),0,' ','DEBARMENTS_COUNT :'||l_invalid_number) DEBARMENTS_COUNT,
8809 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,' ','HOUSEHOLD_SIZE :'||l_invalid_number) HOUSEHOLD_SIZE,
8810 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','PERSONAL_INCOME :'||l_invalid_number) PERSONAL_INCOME,
8811 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,' ','NOTES :'||l_invalid_size||'(2000)') NOTES,
8812 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,' ','VEHICLE_RESPONSE_CODE :'||l_invalid_size||'(30)') VEHICLE_RESPONSE_CODE,
8813 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,' ','SALES_AGENT_EMAIL_ADDRESS:'||l_invalid_size||'(2000)') SALES_AGENT_EMAIL_ADDRESS,
8814 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,' ','ORIG_SYSTEM_REFERENCE:'||l_invalid_size||'(240)') ORIG_SYSTEM_REFERENCE,
8815 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_EMAIL_ADDRESS)),'x')),240) - 240,0,' ','ORG_EMAIL_ADDRESS :'||l_invalid_size||'(240)') ORG_EMAIL_ADDRESS,
8816 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PHONE_TYPE)),'x')),30) - 30,0,' ','ORG_PHONE_TYPE :'||l_invalid_size||'(30)') ORG_PHONE_TYPE,
8817 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_TYPE)),'x')),30) - 30,0,' ','PHONE_TYPE :'||l_invalid_size||'(30)') PHONE_TYPE,
8818 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_COUNTRY_CODE)),'x')),30) - 30,0,' ','ORG_PH_COUNTRY_CODE :'||l_invalid_size||'(30)') ORG_PH_COUNTRY_CODE,
8819 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_AREA_CODE)),'x')),10) - 10,0,' ','ORG_PH_AREA_CODE :'||l_invalid_size||'(10)') ORG_PH_AREA_CODE,
8820 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_NUMBER)),'x')),25) - 25,0,' ','ORG_PH_NUMBER :'||l_invalid_size||'(25)') ORG_PH_NUMBER,
8821 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_EXTENSION)),'x')),20) - 20,0,' ','ORG_PH_EXTENSION :'||l_invalid_size||'(20)') ORG_PH_EXTENSION,
8822 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS1)),'x')),240) - 240,0,' ','ORG_ADDRESS1 :'||l_invalid_size||'(240)') ORG_ADDRESS1,
8823 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS2)),'x')),240) - 240,0,' ','ORG_ADDRESS2 :'||l_invalid_size||'(240)') ORG_ADDRESS2,
8824 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS3)),'x')),240) - 240,0,' ','ORG_ADDRESS3 :'||l_invalid_size||'(240)') ORG_ADDRESS3,
8825 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS4)),'x')),240) - 240,0,' ','ORG_ADDRESS4 :'||l_invalid_size||'(240)') ORG_ADDRESS4,
8826 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CITY)),'x')),60) - 60,0,' ','ORG_CITY :'||l_invalid_size||'(60)') ORG_CITY ,
8827 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_POSTAL_CODE)),'x')),60) - 60,0,' ','ORG_POSTAL_CODE :'||l_invalid_size||'(60)') ORG_POSTAL_CODE,
8828 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_STATE)),'x')),60) - 60,0,' ','ORG_STATE :'||l_invalid_size||'(60)') ORG_STATE,
8829 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PROVINCE)),'x')),60) - 60,0,' ','ORG_PROVINCE :'||l_invalid_size||'(60)') ORG_PROVINCE,
8830 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_COUNTY)),'x')),60) - 60,0,' ','ORG_COUNTY :'||l_invalid_size||'(60)') ORG_COUNTY,
8831 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_COUNTRY)),'x')),60) - 60,0,' ','ORG_COUNTRY :'||l_invalid_size||'(60)') ORG_COUNTRY,
8832 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_ADDR_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_ADDR_ATTRIBUTE_CATEGORY,
8833 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE1,
8834 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE2,
8835 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE3,
8836 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE4,
8837 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE5,
8838 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE6,
8839 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE7,
8840 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE8,
8841 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE9,
8842 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE10,
8843 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE11)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE11 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE11,
8844 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE12,
8845 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE13,
8846 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE14,
8847 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE15,
8848 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE16)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE16 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE16,
8849 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE17)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE17 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE17,
8850 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE18)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE18 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE18,
8851 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE19)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE19 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE19,
8852 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE20)),'x')),150) - 150,0,' ','ORG_ADDR_ATTRIBUTE20 :'||l_invalid_size||'(150)') ORG_ADDR_ATTRIBUTE20,
8853 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_CPS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_CPS_ATTRIBUTE_CATEGORY,
8854 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE1,
8855 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE2,
8856 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE3,
8857 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE4,
8858 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE5,
8859 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE6,
8860 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE7,
8861 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE8,
8862 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE9,
8863 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE10,
8864 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE11)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE11 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE11,
8865 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE12,
8866 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE13,
8867 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE14,
8868 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE15,
8869 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE16)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE16 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE16,
8870 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE17)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE17 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE17,
8871 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE18)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE18 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE18,
8872 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE19)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE19 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE19,
8873 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE20)),'x')),150) - 150,0,' ','ORG_CPS_ATTRIBUTE20 :'||l_invalid_size||'(150)') ORG_CPS_ATTRIBUTE20,
8874 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_PS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_PS_ATTRIBUTE_CATEGORY,
8875 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE1,
8876 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE2,
8877 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE3,
8878 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE4,
8879 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE5,
8880 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE6,
8881 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE7,
8882 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE8,
8883 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE9,
8884 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE10,
8885 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE11)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE11 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE11,
8886 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE12,
8887 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE13,
8888 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE14,
8889 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE15,
8890 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE16)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE16 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE16,
8891 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE17)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE17 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE17,
8892 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE18)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE18 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE18,
8893 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE19)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE19 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE19,
8894 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE20)),'x')),150) - 150,0,' ','ORG_PS_ATTRIBUTE20 :'||l_invalid_size||'(150)') ORG_PS_ATTRIBUTE20,
8895 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NATIVE_LANGUAGE)),'x')),4) - 4,0,' ','LANGUAGE :'||l_invalid_size||'(4)') NATIVE_LANGUAGE
8896  FROM AMS_HZ_B2B_MAPPING_V
8897  WHERE IMPORT_LIST_HEADER_ID =  p_import_list_header_id
8898   and load_status in ('ACTIVE','RELOAD')
8899    AND
8900  (
8901  DECODE(GREATEST(lengthb(LTRIM(RTRIM(PARTY_NAME))),255) - 255,0,'OK','NO') = 'NO'
8902 or
8903  DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FISCAL_YEAREND_MONTH)),'x')),30) - 30,0,'OK','NO') = 'NO'
8904 /* or
8905 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DUNS_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8906 */
8907 or
8908 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(EMPLOYEES_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8909 or
8910 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(YEAR_ESTABLISHED,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8911 or
8912 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_ORDERED_AMOUNT,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8913 or
8914 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(TOTAL_NUM_OF_ORDERS,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8915 or
8916 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CURR_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8917 or
8918 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(NEXT_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8919 or
8920 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
8921 or
8922   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LINE_OF_BUSINESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
8923 or
8924   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
8925 or
8926   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
8927 or
8928   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
8929 or
8930   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
8931 or
8932   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),50) - 50,0,'OK','NO') = 'NO'
8933 or
8934   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CEO_NAME)),'x')),240) - 240,0,'OK','NO') = 'NO'
8935 or
8936   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME)),'x')),50) - 50,0,'OK','NO') = 'NO'
8937 or
8938   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME)),'x')),40) - 40,0,'OK','NO') = 'NO'
8939 or
8940   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
8941 or
8942   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE)),'x')),100) - 100,0,'OK','NO') = 'NO'
8943 or
8944   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
8945 or
8946   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
8947 or
8948   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
8949 or
8950   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
8951 or
8952   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
8953 or
8954   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
8955 or
8956   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
8957 or
8958   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DUNS_NUMBER)),'x')),30) - 30,0,'OK','NO') = 'NO'
8959 or
8960   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
8961 or
8962   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,'OK','NO') = 'NO'
8963 or
8964   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
8965 or
8966   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
8967 or
8968   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
8969 or
8970   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
8971 or
8972   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,'OK','NO') = 'NO'
8973 or
8974   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT)),'x')),60) - 60,0,'OK','NO') = 'NO'
8975 or
8976   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
8977 or
8978   DECODE(GREATEST(lengthb(nvl(SIC_CODE,'x')),30) - 30,0,'OK','NO') = 'NO'
8979 or
8980   DECODE(GREATEST(lengthb(nvl(SIC_CODE_TYPE,'x')),30) - 30,0,'OK','NO') = 'NO'
8981 or
8982   DECODE(GREATEST(lengthb(nvl(ANALYSIS_FY,'x')),5) - 5,0,'OK','NO') = 'NO'
8983 or
8984   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,'OK','NO') = 'NO'
8985 or
8986   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GSA_INDICATOR_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
8987 or
8988   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OVERSEAS_ADDRESS_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
8989 or
8990   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(APARTMENT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
8991 or
8992   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MISSION_STATEMENT)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
8993 or
8994   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_NAME_PHONETIC)),'x')),320) - 320,0,'OK','NO') = 'NO'
8995 or
8996   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CATEGORY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
8997 or
8998   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JGZZ_FISCAL_CODE)),'x')),20) - 20,0,'OK','NO') = 'NO'
8999 or
9000   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
9001 or
9002   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,'OK','NO') = 'NO'
9003 or
9004 /*
9005   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9006 or
9007   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,'OK','NO') = 'NO'
9008 or
9009   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9010 or
9011 */
9012   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),50) - 50,0,'OK','NO') = 'NO'
9013 or
9014 --  DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,'OK','NO') = 'NO'
9015 --or
9016   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECONDARY_SUFFIX_ELENENT)),'x')),240) - 240,0,'OK','NO') = 'NO'
9017 or
9018 /*
9019   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,'OK','NO') = 'NO'
9020 or
9021   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9022 or
9023 */
9024   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_TYPE)),'x')),50) - 50,0,'OK','NO') = 'NO'
9025 or
9026   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9027 or
9028   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9029 or
9030   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BRANCH_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
9031 or
9032   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEAD_OF_HOUSEHOLD_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
9033 or
9034   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PUBLIC_PRIVATE_OWNERSHIP_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
9035 or
9036   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_LINE)),'x')),240) - 240,0,'OK','NO') = 'NO'
9037 or
9038   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_SCOPE)),'x')),20) - 20,0,'OK','NO') = 'NO'
9039 or
9040   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CHIEF_EXECUTIVE_TITLE)),'x')),240) - 240,0,'OK','NO') = 'NO'
9041 or
9042   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
9043 or
9044   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
9045 or
9046   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
9047 or
9048   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
9049 or
9050   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
9051 or
9052   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
9053 or
9054   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
9055 or
9056   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
9057 or
9058   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
9059 or
9060   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
9061 or
9062   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_NAME)),'x')),240) - 240,0,'OK','NO') = 'NO'
9063 or
9064   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_TITLE)),'x')),240) - 240,0,'OK','NO') = 'NO'
9065 or
9066   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,'OK','NO') = 'NO'
9067 or
9068   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),360) - 360,0,'OK','NO') = 'NO'
9069 or
9070   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,'OK','NO') = 'NO'
9071 or
9072   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONGRESSIONAL_DISTRICT_CODE)),'x')),2) - 2,0,'OK','NO') = 'NO'
9073 or
9074   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CORPORATION_CLASS)),'x')),60) - 60,0,'OK','NO') = 'NO'
9075 or
9076   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
9077 or
9078   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
9079 or
9080   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
9081 or
9082   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PLACE_OF_BIRTH)),'x')),60) - 60,0,'OK','NO') = 'NO'
9083 or
9084   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_ID)),'x')),60) - 60,0,'OK','NO') = 'NO'
9085 or
9086   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9087 or
9088   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(WOMAN_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9089 or
9090   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9091 or
9092   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,'OK','NO') = 'NO'
9093 or
9094   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,'OK','NO') = 'NO'
9095 or
9096   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECOND_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9097 or
9098   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SMALL_BUSINESS_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9099 or
9100   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9101 or
9102   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9103 or
9104   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9105 or
9106   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OUT_OF_BUSINESS_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9107 or
9108   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9109 or
9110   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LABOR_SURPLUS_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9111 or
9112   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9113 or
9114   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9115 or
9116   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(IMPORT_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9117 or
9118   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DISADVANTAGED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9119 or
9120   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9121 or
9122   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE_COMMENTARY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9123 or
9124   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EXPORT_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9125 or
9126   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9127 or
9128   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_COMMENTARY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9129 or
9130   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_OVERRIDE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9131 or
9132   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DB_RATING)),'x')),5) - 5,0,'OK','NO') = 'NO'
9133 or
9134   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GLOBAL_FAILURE_SCORE)),'x')),5) - 5,0,'OK','NO') = 'NO'
9135 or
9136   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ENQUIRY_DUNS)),'x')),15) - 15,0,'OK','NO') = 'NO'
9137 or
9138   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9139 or
9140   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9141 or
9142   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9143 or
9144   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9145 or
9146   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9147 or
9148   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9149 or
9150   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9151 or
9152   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9153 or
9154   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9155 or
9156   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9157 or
9158   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9159 or
9160   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9161 or
9162   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9163 or
9164   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9165 or
9166   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9167 or
9168   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9169 or
9170   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9171 or
9172   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9173 or
9174   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9175 or
9176   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9177 or
9178   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9179 or
9180   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9181 or
9182   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9183 or
9184   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9185 or
9186   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9187 or
9188   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9189 or
9190   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9191 or
9192   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9193 or
9194   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9195 or
9196   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9197 or
9198   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9199 or
9200   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9201 or
9202   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9203 or
9204   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9205 or
9206   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9207 or
9208   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9209 or
9210   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9211 or
9212   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9213 or
9214   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9215 or
9216   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9217 or
9218   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9219 or
9220   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9221 or
9222   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9223 or
9224   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9225 or
9226   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9227 or
9228   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9229 or
9230   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9231 or
9232   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9233 or
9234   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9235 or
9236   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9237 or
9238   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9239 or
9240   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9241 or
9242   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9243 or
9244   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9245 or
9246   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9247 or
9248   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9249 or
9250   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9251 or
9252   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9253 or
9254   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9255 or
9256   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9257 or
9258   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9259 or
9260   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9261 or
9262   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9263 or
9264   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9265 or
9266   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9267 or
9268   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9269 or
9270   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
9271 or
9272   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
9273 or
9274   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,'OK','NO') = 'NO'
9275 or
9276 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CONTROL_YEAR,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9277 or
9278 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DEBARMENTS_COUNT,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9279 or
9280 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9281 or
9282 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9283 or
9284   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9285 or
9286   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9287 or
9288   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9289 or
9290   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,'OK','NO') = 'NO'
9291 or
9292   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
9293 or
9294   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PHONE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9295 or
9296   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9297 or
9298   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
9299 or
9300   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
9301 or
9302   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PH_EXTENSION)),'x')),20) - 20,0,'OK','NO') = 'NO'
9303 or
9304   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
9305 or
9306   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
9307 or
9308   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
9309 or
9310   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
9311 or
9312   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9313 or
9314   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9315 or
9316   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9317 or
9318   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9319 or
9320   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9321 or
9322   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9323 or
9324   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9325 or
9326   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9327 or
9328   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9329 or
9330   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9331 or
9332   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9333 or
9334   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9335 or
9336   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9337 or
9338   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9339 or
9340   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9341 or
9342   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9343 or
9344   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9345 or
9346   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9347 or
9348   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9349 or
9350   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9351 or
9352   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9353 or
9354   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9355 or
9356   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE16)),'x')),150) - 150,0,'OK','NO') = 'NO'
9357 or
9358   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE17)),'x')),150) - 150,0,'OK','NO') = 'NO'
9359 or
9360   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE18)),'x')),150) - 150,0,'OK','NO') = 'NO'
9361 or
9362   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE19)),'x')),150) - 150,0,'OK','NO') = 'NO'
9363 or
9364   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ADDR_ATTRIBUTE20)),'x')),150) - 150,0,'OK','NO') = 'NO'
9365 or
9366   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9367 or
9368   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9369 or
9370   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9371 or
9372   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9373 or
9374   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9375 or
9376   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9377 or
9378   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9379 or
9380   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9381 or
9382   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9383 or
9384   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9385 or
9386   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9387 or
9388   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9389 or
9390   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9391 or
9392   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9393 or
9394   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9395 or
9396   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9397 or
9398   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE16)),'x')),150) - 150,0,'OK','NO') = 'NO'
9399 or
9400   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE17)),'x')),150) - 150,0,'OK','NO') = 'NO'
9401 or
9402   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE18)),'x')),150) - 150,0,'OK','NO') = 'NO'
9403 or
9404   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE19)),'x')),150) - 150,0,'OK','NO') = 'NO'
9405 or
9406   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CPS_ATTRIBUTE20)),'x')),150) - 150,0,'OK','NO') = 'NO'
9407 or
9408   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9409 or
9410   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9411 or
9412   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9413 or
9414   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9415 or
9416   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9417 or
9418   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9419 or
9420   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9421 or
9422   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9423 or
9424   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9425 or
9426   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9427 or
9428   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9429 or
9430   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9431 or
9432   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9433 or
9434   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9435 or
9436   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9437 or
9438   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9439 or
9440   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE16)),'x')),150) - 150,0,'OK','NO') = 'NO'
9441 or
9442   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE17)),'x')),150) - 150,0,'OK','NO') = 'NO'
9443 or
9444   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE18)),'x')),150) - 150,0,'OK','NO') = 'NO'
9445 or
9446   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE19)),'x')),150) - 150,0,'OK','NO') = 'NO'
9447 or
9448   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_PS_ATTRIBUTE20)),'x')),150) - 150,0,'OK','NO') = 'NO'
9449 or
9450   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9451 or
9452   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NATIVE_LANGUAGE)),'x')),4) - 4,0,'OK','NO') = 'NO'
9453 
9454  );
9455 
9456 
9457 
9458 
9459 -- Cursor for B2C party type
9460 
9461 cursor b2c is
9462  SELECT
9463  IMPORT_SOURCE_LINE_ID,
9464  import_list_header_id,
9465 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,' ','ADDRESS1 :'||l_invalid_size||'(240)') ADDRESS1,
9466 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,' ','ADDRESS2 :'||l_invalid_size||'(240)') ADDRESS2,
9467 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,' ','ADDRESS3 :'||l_invalid_size||'(240)') ADDRESS3,
9468 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,' ','ADDRESS4 :'||l_invalid_size||'(240)') ADDRESS4,
9469 DECODE(GREATEST(lengthb(LTRIM(RTRIM(PERSON_LAST_NAME))),50) - 50,0,' ','PERSON_LAST_NAME :'||decode(nvl(PERSON_LAST_NAME,'x'),'x',l_null_value,l_invalid_size)||'(50)') PERSON_LAST_NAME,
9470 DECODE(GREATEST(lengthb(LTRIM(RTRIM(PERSON_FIRST_NAME))),40) - 40,0,' ','PERSON_FIRST_NAME :'||decode(nvl(PERSON_FIRST_NAME,'x'),'x',l_null_value,l_invalid_size)||'(40)') PERSON_FIRST_NAME,
9471 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,' ','PERSON_NAME_PREFIX :'||l_invalid_size||'(30)') PERSON_NAME_PREFIX,
9472 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,' ','PERSON_MIDDLE_NAME :'||l_invalid_size||'(60)') PERSON_MIDDLE_NAME,
9473 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,' ','PERSON_NAME_SUFFIX :'||l_invalid_size||'(30)') PERSON_NAME_SUFFIX,
9474 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,' ','CITY :'||l_invalid_size||'(60)') CITY ,
9475 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALUTATION)),'x')),60) - 60,0,' ','SALUTATION :'||l_invalid_size||'(60)') SALUTATION,
9476 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,' ','POSTAL_CODE :'||l_invalid_size||'(60)') POSTAL_CODE,
9477 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,' ','STATE :'||l_invalid_size||'(60)') STATE,
9478 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,' ','PROVINCE :'||l_invalid_size||'(60)') PROVINCE,
9479 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,' ','COUNTY :'||l_invalid_size||'(60)') COUNTY,
9480 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,' ','COUNTRY :'||l_invalid_size||'(60)') COUNTRY,
9481 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,' ','TIME_ZONE :'||l_invalid_size||'(50)') TIME_ZONE,
9482 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,' ','EMAIL_ADDRESS :'||l_invalid_size||'(240)') EMAIL_ADDRESS,
9483 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,' ','PHONE_COUNTRY_CODE :'||l_invalid_size||'(30)') PHONE_COUNTRY_CODE,
9484 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,' ','PHONE_AREA_CODE :'||l_invalid_size||'(10)') PHONE_AREA_CODE,
9485 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,' ','PHONE_NUMBER :'||l_invalid_size||'(25)') PHONE_NUMBER,
9486 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,' ','PHONE_EXTENTION :'||l_invalid_size||'(20)') PHONE_EXTENTION,
9487 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OVERSEAS_ADDRESS_FLAG)),'x')),1) - 1,0,' ','OVERSEAS_ADDRESS_FLAG :'||l_invalid_size||'(1)') OVERSEAS_ADDRESS_FLAG,
9488 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,' ','identifying_address_flag :'||l_invalid_size||'(1)') identifying_address_flag,
9489 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(APARTMENT_FLAG)),'x')),1) - 1,0,' ','APARTMENT_FLAG :'||l_invalid_size||'(1)') APARTMENT_FLAG,
9490 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,' ','ADDRESS_LINES_PHONETIC :'||l_invalid_size||'(560)') ADDRESS_LINES_PHONETIC,
9491 -- bug 4641591: columns obsolete
9492 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,' ','PO_BOX_NUMBER :'||l_invalid_size||'(50)') PO_BOX_NUMBER,
9493 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,' ','FLOOR :'||l_invalid_size||'(50)') FLOOR,
9494 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,' ','HOUSE_NUMBER :'||l_invalid_size||'(50)') HOUSE_NUMBER,
9495 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),10) - 10,0,' ','POSTAL_PLUS4_CODE :'||l_invalid_size||'(10)') POSTAL_PLUS4_CODE,
9496 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,' ','STREET_SUFFIX :'||l_invalid_size||'(50)') STREET_SUFFIX,
9497 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECONDARY_SUFFIX_ELEMENT)),'x')),240) - 240,0,' ','SECONDARY_SUFFIX_ELEMENT :'||l_invalid_size||'(240)') SECONDARY_SUFFIX_ELEMENT,
9498 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,' ','STREET :'||l_invalid_size||'(50)') STREET,
9499 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,' ','STREET_NUMBER :'||l_invalid_size||'(50)') STREET_NUMBER,
9500 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SUITE)),'x')),50) - 50,0,' ','SUITE :'||l_invalid_size||'(50)') SUITE,
9501 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_TYPE)),'x')),50) - 50,0,' ','RURAL_ROUTE_TYPE :'||l_invalid_size||'(50)') RURAL_ROUTE_TYPE,
9502 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_NUMBER)),'x')),50) - 50,0,' ','RURAL_ROUTE_NUMBER :'||l_invalid_size||'(50)') RURAL_ROUTE_NUMBER,
9503 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,' ','PARTY_ID :'||l_invalid_number) party_id,
9504 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URL)),'x')),2000) - 2000,0,' ','URL :'||l_invalid_size||'(2000)') URL,
9505 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,' ','DECLARED_ETHNICITY :'||l_invalid_size||'(60)') DECLARED_ETHNICITY,
9506 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION:'||l_invalid_size||'(2000)') DESCRIPTION,
9507 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEAD_OF_HOUSEHOLD_FLAG)),'x')),1) - 1,0,' ','HEAD_OF_HOUSEHOLD_FLAG :'||l_invalid_size||'(1)') HEAD_OF_HOUSEHOLD_FLAG,
9508 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS :'||l_invalid_size||'(240)') PERSON_KNOWN_AS,
9509 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS2 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS2,
9510 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS3 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS3,
9511 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS4 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS4,
9512 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS5 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS5,
9513 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,' ','LOCATION_DIRECTIONS:'||l_invalid_size||'(640)') LOCATION_DIRECTIONS,
9514 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,' ','MARITAL_STATUS :'||l_invalid_size||'(30)') MARITAL_STATUS,
9515 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,' ','PERSON_ACADEMIC_TITLE :'||l_invalid_size||'(30)') PERSON_ACADEMIC_TITLE,
9516 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_FIRST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_FIRST_NAME_PHONETIC,
9517 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_LAST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_LAST_NAME_PHONETIC,
9518 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,' ','MIDDLE_NAME_PHONETIC :'||l_invalid_size||'(60)') MIDDLE_NAME_PHONETIC,
9519 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),320) - 320,0,' ','PERSON_NAME_PHONETIC :'||l_invalid_size||'(320)') PERSON_NAME_PHONETIC,
9520 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,' ','PERSON_PREVIOUS_TITLE_NAME :'||l_invalid_size||'(150)') PERSON_PREVIOUS_TITLE_NAME,
9521 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECOND_TITLE)),'x')),30) - 30,0,' ','SECOND_TITLE :'||l_invalid_size||'(30)') SECOND_TITLE,
9522 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,
9523 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE1)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE1 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE1,
9524 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE2)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE2 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE2,
9525 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE3)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE3 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE3,
9526 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE4)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE4 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE4,
9527 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE5)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE5 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE5,
9528 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE6)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE6 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE6,
9529 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE7)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE7 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE7,
9530 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE8)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE8 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE8,
9531 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE9)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE9 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE9,
9532 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE10)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE10 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE10,
9533 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE11)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE11 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE11,
9534 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE12)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE12 : '||l_invalid_size||'(150)') PERSON_ATTRIBUTE12,
9535 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE13)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE13 : '||l_invalid_size||'(150)') PERSON_ATTRIBUTE13,
9536 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE14)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE14 : '||l_invalid_size||'(150)') PERSON_ATTRIBUTE14,
9537 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE15)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE15 : '||l_invalid_size||'(150)') PERSON_ATTRIBUTE15,
9538 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE1 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE1,
9539 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE2 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE2,
9540 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE3 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE3,
9541 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE4 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE4,
9542 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE5 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE5,
9543 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE6 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE6,
9544 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE7 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE7,
9545 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE8 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE8,
9546 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE9 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE9,
9547 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE10 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE10,
9548 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE11 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE11,
9549 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE12 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE12,
9550 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE13 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE13,
9551 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE14 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE14,
9552 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE15 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE15,
9553 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,' ','FAX_COUNTRY_CODE :'||l_invalid_size||'(10)') FAX_COUNTRY_CODE,
9554 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,' ','FAX_AREA_CODE :'||l_invalid_size||'(10)') FAX_AREA_CODE,
9555 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,' ','FAX_NUMBER :'||l_invalid_size||'(40)') FAX_NUMBER,
9556 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','PERSON_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') PERSON_ATTRIBUTE_CATEGORY,
9557 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ADDRESS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ADDRESS_ATTRIBUTE_CATEGORY,
9558 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,' ','HOUSEHOLD_SIZE :'||l_invalid_number) HOUSEHOLD_SIZE,
9559 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','HOUSEHOLD_INCOME :'||l_invalid_number) HOUSEHOLD_INCOME,
9560 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','PERSONAL_INCOME :'||l_invalid_number) PERSONAL_INCOME,
9561 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION:'||l_invalid_size||'(2000)') DESCRIPTION,
9562 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,
9563 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,' ','NOTES :'||l_invalid_size||'(2000)') NOTES,
9564 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,' ','VEHICLE_RESPONSE_CODE :'||l_invalid_size||'(30)') VEHICLE_RESPONSE_CODE,
9565 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,' ','SALES_AGENT_EMAIL_ADDRESS:'||l_invalid_size||'(2000)') SALES_AGENT_EMAIL_ADDRESS,
9566 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),60) - 60,0,' ','TAX_REFERENCE :'||l_invalid_size||'(60)') TAX_REFERENCE,
9567 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,' ','RENT_OWNED_INDICATOR :'||l_invalid_size||'(30)') RENT_OWNED_INDICATOR,
9568 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GENDER)),'x')),30) - 30,0,' ','GENDER :'||l_invalid_size||'(30)') GENDER,
9569 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,' ','ORIG_SYSTEM_REFERENCE:'||l_invalid_size||'(240)') ORIG_SYSTEM_REFERENCE,
9570 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_TYPE)),'x')),30) - 30,0,' ','PHONE_TYPE :'||l_invalid_size||'(30)') PHONE_TYPE,
9571 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','PS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') PS_ATTRIBUTE_CATEGORY,
9572 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE1)),'x')),150) - 150,0,' ','PS_ATTRIBUTE1 :'||l_invalid_size||'(150)') PS_ATTRIBUTE1,
9573 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE2)),'x')),150) - 150,0,' ','PS_ATTRIBUTE2 :'||l_invalid_size||'(150)') PS_ATTRIBUTE2,
9574 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE3)),'x')),150) - 150,0,' ','PS_ATTRIBUTE3 :'||l_invalid_size||'(150)') PS_ATTRIBUTE3,
9575 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE4)),'x')),150) - 150,0,' ','PS_ATTRIBUTE4 :'||l_invalid_size||'(150)') PS_ATTRIBUTE4,
9576 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE5)),'x')),150) - 150,0,' ','PS_ATTRIBUTE5 :'||l_invalid_size||'(150)') PS_ATTRIBUTE5,
9577 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE6)),'x')),150) - 150,0,' ','PS_ATTRIBUTE6 :'||l_invalid_size||'(150)') PS_ATTRIBUTE6,
9578 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE7)),'x')),150) - 150,0,' ','PS_ATTRIBUTE7 :'||l_invalid_size||'(150)') PS_ATTRIBUTE7,
9579 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE8)),'x')),150) - 150,0,' ','PS_ATTRIBUTE8 :'||l_invalid_size||'(150)') PS_ATTRIBUTE8,
9580 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE9)),'x')),150) - 150,0,' ','PS_ATTRIBUTE9 :'||l_invalid_size||'(150)') PS_ATTRIBUTE9,
9581 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE10)),'x')),150) - 150,0,' ','PS_ATTRIBUTE10 :'||l_invalid_size||'(150)') PS_ATTRIBUTE10,
9582 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE11)),'x')),150) - 150,0,' ','PS_ATTRIBUTE11 :'||l_invalid_size||'(150)') PS_ATTRIBUTE11,
9583 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE12)),'x')),150) - 150,0,' ','PS_ATTRIBUTE12 :'||l_invalid_size||'(150)') PS_ATTRIBUTE12,
9584 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE13)),'x')),150) - 150,0,' ','PS_ATTRIBUTE13 :'||l_invalid_size||'(150)') PS_ATTRIBUTE13,
9585 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE14)),'x')),150) - 150,0,' ','PS_ATTRIBUTE14 :'||l_invalid_size||'(150)') PS_ATTRIBUTE14,
9586 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE15)),'x')),150) - 150,0,' ','PS_ATTRIBUTE15 :'||l_invalid_size||'(150)') PS_ATTRIBUTE15,
9587 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE16)),'x')),150) - 150,0,' ','PS_ATTRIBUTE16 :'||l_invalid_size||'(150)') PS_ATTRIBUTE16,
9588 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE17)),'x')),150) - 150,0,' ','PS_ATTRIBUTE17 :'||l_invalid_size||'(150)') PS_ATTRIBUTE17,
9589 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE18)),'x')),150) - 150,0,' ','PS_ATTRIBUTE18 :'||l_invalid_size||'(150)') PS_ATTRIBUTE18,
9590 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE19)),'x')),150) - 150,0,' ','PS_ATTRIBUTE19 :'||l_invalid_size||'(150)') PS_ATTRIBUTE19,
9591 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE20)),'x')),150) - 150,0,' ','PS_ATTRIBUTE20 :'||l_invalid_size||'(150)') PS_ATTRIBUTE20,
9592 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NATIVE_LANGUAGE)),'x')),4) - 4,0,' ','LANGUAGE :'||l_invalid_size||'(4)') NATIVE_LANGUAGE,
9593 Null  col1,
9594 Null  col2,
9595 Null  col3,
9596 Null  col4,
9597 Null  col5,
9598 Null  col6,
9599 Null  col7,
9600 Null  col8,
9601 Null  col9,
9602 Null  col10,
9603 Null  col11,
9604 Null  col12,
9605 Null  col13,
9606 Null  col14,
9607 Null  col15,
9608 Null  col16,
9609 Null  col17,
9610 Null  col18,
9611 Null  col19,
9612 Null  col20,
9613 Null  col21,
9614 Null  col22,
9615 Null  col23,
9616 Null  col24,
9617 Null  col25,
9618 Null  col26,
9619 Null  col27,
9620 Null  col28,
9621 Null  col29,
9622 Null  col30,
9623 Null  col31,
9624 Null  col32,
9625 Null  col33,
9626 Null  col34,
9627 Null  col35,
9628 Null  col36,
9629 Null  col37,
9630 Null  col38,
9631 Null  col39,
9632 Null  col40,
9633 Null  col41,
9634 Null  col42,
9635 Null  col43,
9636 Null  col44,
9637 Null  col45,
9638 Null  col46,
9639 Null  col47,
9640 Null  col48,
9641 Null  col49,
9642 Null  col50,
9643 Null  col51,
9644 Null  col52,
9645 Null  col53,
9646 Null  col54,
9647 Null  col55,
9648 Null  col56,
9649 Null  col57,
9650 Null  col58,
9651 Null  col59,
9652 Null  col60,
9653 Null  col61,
9654 Null  col62,
9655 Null  col63,
9656 Null  col64,
9657 Null  col65,
9658 Null  col66,
9659 Null  col67,
9660 Null  col68,
9661 Null  col69,
9662 Null  col70,
9663 Null  col71,
9664 Null  col72,
9665 Null  col73,
9666 Null  col74,
9667 Null  col75,
9668 Null  col76,
9669 Null  col77,
9670 Null  col78,
9671 Null  col79,
9672 Null  col80,
9673 Null  col81,
9674 Null  col82,
9675 Null  col83,
9676 Null  col84,
9677 Null  col85,
9678 Null  col86,
9679 Null  col87,
9680 Null  col88,
9681 Null  col89,
9682 Null  col90,
9683 Null  col91,
9684 Null  col92,
9685 Null  col93,
9686 Null  col94,
9687 Null  col95,
9688 Null  col96,
9689 Null  col97,
9690 Null  col98,
9691 Null  col99,
9692 Null  col100,
9693 Null  col101,
9694 Null  col102,
9695 Null  col103,
9696 Null  col104,
9697 Null  col105,
9698 Null  col106,
9699 Null  col107,
9700 Null  col108,
9701 Null  col109,
9702 Null  col110,
9703 Null  col111,
9704 Null  col112,
9705 Null  col113,
9706 Null  col114,
9707 Null  col115,
9708 Null  col116,
9709 Null  col117,
9710 Null  col118,
9711 Null  col119,
9712 Null  col120,
9713 Null  col121,
9714 Null  col122,
9715 Null  col123,
9716 Null  col124,
9717 Null  col125,
9718 Null  col126,
9719 Null  col127,
9720 Null  col128,
9721 Null  col129,
9722 Null  col130,
9723 Null  col131,
9724 Null  col132,
9725 Null  col133,
9726 Null  col134,
9727 Null  col135,
9728 Null  col136,
9729 Null  col137,
9730 Null  col138,
9731 Null  col139,
9732 Null  col140,
9733 Null  col141,
9734 Null  col142,
9735 Null  col143,
9736 Null  col144,
9737 Null  col145,
9738 Null  col146,
9739 Null  col147,
9740 Null  col148
9741  FROM AMS_HZ_B2C_MAPPING_V
9742  WHERE IMPORT_LIST_HEADER_ID =  p_import_list_header_id
9743   and load_status in ('ACTIVE','RELOAD')
9744    AND
9745  (
9746 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9747 or
9748   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
9749 or
9750   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
9751 or
9752   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
9753 or
9754   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
9755 or
9756   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME)),'x')),50) - 50,0,'OK','NO') = 'NO'
9757 or
9758   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME)),'x')),40) - 40,0,'OK','NO') = 'NO'
9759 or
9760   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
9761 or
9762   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
9763 or
9764   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
9765 or
9766   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9767 or
9768   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9769 or
9770   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9771 or
9772   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALUTATION)),'x')),60) - 60,0,'OK','NO') = 'NO'
9773 or
9774   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9775 or
9776   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9777 or
9778   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9779 or
9780   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,'OK','NO') = 'NO'
9781 or
9782   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
9783 or
9784   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9785 or
9786   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
9787 or
9788   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
9789 or
9790   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,'OK','NO') = 'NO'
9791 or
9792   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,'OK','NO') = 'NO'
9793 or
9794   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OVERSEAS_ADDRESS_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
9795 or
9796   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(APARTMENT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
9797 or
9798   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,'OK','NO') = 'NO'
9799 or
9800 /*
9801   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9802 or
9803   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,'OK','NO') = 'NO'
9804 or
9805   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9806 or
9807 */
9808   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),50) - 50,0,'OK','NO') = 'NO'
9809 or
9810 --  DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,'OK','NO') = 'NO'
9811 --or
9812   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECONDARY_SUFFIX_ELEMENT)),'x')),240) - 240,0,'OK','NO') = 'NO'
9813 or
9814   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,'OK','NO') = 'NO'
9815 or
9816   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9817 or
9818 /*
9819   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,'OK','NO') = 'NO'
9820 or
9821   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9822 or
9823 */
9824   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_TYPE)),'x')),50) - 50,0,'OK','NO') = 'NO'
9825 or
9826   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
9827 or
9828   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9829 or
9830   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
9831 or
9832   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
9833 or
9834   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
9835 or
9836   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
9837 or
9838   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
9839 or
9840   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,'OK','NO') = 'NO'
9841 or
9842   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),360) - 360,0,'OK','NO') = 'NO'
9843 or
9844   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,'OK','NO') = 'NO'
9845 or
9846   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
9847 or
9848   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
9849 or
9850   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
9851 or
9852   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PLACE_OF_BIRTH)),'x')),60) - 60,0,'OK','NO') = 'NO'
9853 or
9854   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,'OK','NO') = 'NO'
9855 or
9856   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,'OK','NO') = 'NO'
9857 or
9858   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SECOND_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9859 or
9860   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9861 or
9862   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
9863 or
9864   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9865 or
9866   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9867 or
9868   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9869 or
9870   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9871 or
9872   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9873 or
9874   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9875 or
9876   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9877 or
9878   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9879 or
9880   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9881 or
9882   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9883 or
9884   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9885 or
9886   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9887 or
9888   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9889 or
9890   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9891 or
9892   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9893 or
9894   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9895 or
9896   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9897 or
9898   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9899 or
9900   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9901 or
9902   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9903 or
9904   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9905 or
9906   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9907 or
9908   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9909 or
9910   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9911 or
9912   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9913 or
9914   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9915 or
9916   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9917 or
9918   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9919 or
9920   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9921 or
9922   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9923 or
9924   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9925 or
9926   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9927 or
9928   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9929 or
9930   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
9931 or
9932   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
9933 or
9934   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,'OK','NO') = 'NO'
9935 or
9936 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9937 or
9938 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9939 or
9940 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
9941 or
9942   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9943 or
9944   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9945 or
9946   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
9947 or
9948   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
9949 or
9950   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
9951 or
9952   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GENDER)),'x')),30) - 30,0,'OK','NO') = 'NO'
9953 or
9954   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,'OK','NO') = 'NO'
9955 or
9956   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
9957 or
9958   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
9959 or
9960   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
9961 or
9962   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
9963 or
9964   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
9965 or
9966   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
9967 or
9968   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
9969 or
9970   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
9971 or
9972   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
9973 or
9974   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
9975 or
9976   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
9977 or
9978   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
9979 or
9980   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
9981 or
9982   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
9983 or
9984   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
9985 or
9986   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
9987 or
9988   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
9989 or
9990   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE16)),'x')),150) - 150,0,'OK','NO') = 'NO'
9991 or
9992   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE17)),'x')),150) - 150,0,'OK','NO') = 'NO'
9993 or
9994   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE18)),'x')),150) - 150,0,'OK','NO') = 'NO'
9995 or
9996   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE19)),'x')),150) - 150,0,'OK','NO') = 'NO'
9997 or
9998   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PS_ATTRIBUTE20)),'x')),150) - 150,0,'OK','NO') = 'NO'
9999 or
10000   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(NATIVE_LANGUAGE)),'x')),4) - 4,0,'OK','NO') = 'NO'
10001  );
10002 
10003 
10004 
10005 -- Cursor to check if it's B2B or B2C party type.
10006 
10007 cursor b2borb2c is
10008           select import_type  from ams_imp_list_headers_all
10009           where  import_list_header_id = p_import_list_header_id;
10010 
10011 
10012 CURSOR c_b2b_date_fields is
10013 SELECT
10014 import_list_header_id,
10015 import_source_line_id,
10016 ADDRESS_EFFECTIVE_DATE,
10017 ADDRESS_EXPIRATION_DATE,
10018 DATE_OF_BIRTH,
10019 DATE_OF_DEATH,
10020 DEBARTMENTS_DATE,
10021 MARITAL_STATUS_EFFECTIVE_DATE
10022 FROM ams_hz_b2b_mapping_v
10023 WHERE import_list_header_id = p_import_list_header_id
10024   and load_status in ('ACTIVE','RELOAD')
10025   AND (ADDRESS_EFFECTIVE_DATE is not null or ADDRESS_EXPIRATION_DATE is not null or
10026        DATE_OF_BIRTH is not null or DATE_OF_DEATH is not null or DEBARTMENTS_DATE is not null
10027        or MARITAL_STATUS_EFFECTIVE_DATE is not null);
10028 
10029 CURSOR c_b2c_date_fields is
10030 SELECT
10031 import_list_header_id,
10032 import_source_line_id,
10033 ADDRESS_EFFECTIVE_DATE,
10034 ADDRESS_EXPIRATION_DATE,
10035 DATE_OF_BIRTH,
10036 DATE_OF_DEATH,
10037 null date1,
10038 MARITAL_STATUS_EFFECTIVE_DATE
10039 FROM ams_hz_b2c_mapping_v
10040 WHERE import_list_header_id = p_import_list_header_id
10041   and load_status in ('ACTIVE','RELOAD')
10042   AND (ADDRESS_EFFECTIVE_DATE is not null or ADDRESS_EXPIRATION_DATE is not null or
10043        DATE_OF_BIRTH is not null or DATE_OF_DEATH is not null or MARITAL_STATUS_EFFECTIVE_DATE is not null);
10044 
10045 begin
10046 
10047         IF p_import_list_header_id IS NULL THEN
10048                 RAISE FND_API.G_EXC_ERROR;
10049         END IF;
10050     p_return_status := FND_API.G_RET_STS_SUCCESS;
10051 
10052     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_DATATYPE_ERROR_CHK');
10053     l_invalid_number := FND_MESSAGE.get;
10054     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_SIZE_ERROR_CHK');
10055     l_invalid_size := FND_MESSAGE.get;
10056     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_NULL_ERROR_CHK');
10057     l_null_value := FND_MESSAGE.get;
10058 
10059         OPEN b2borb2c;
10060         FETCH b2borb2c into l_imp_type;
10061         CLOSE b2borb2c;
10062         x_b2b := l_imp_type;
10063     OPEN c_lead_batch_id;
10064     FETCH c_lead_batch_id into l_batch_id;
10065     CLOSE c_lead_batch_id;
10066 
10067     if x_b2b = 'B2B' then
10068     	OPEN b2b;
10069      else
10070     	OPEN b2c;
10071     end if;
10072      LOOP
10073     if x_b2b = 'B2B' then
10074       FETCH b2b BULK COLLECT INTO
10075        l_import_source_line_id,
10076        l_import_list_header_id,
10077        l_col1                                  ,
10078        l_col2                                  ,
10079        l_col3                                  ,
10080        l_col4                                  ,
10081        l_col5                                  ,
10082        l_col6                                  ,
10083        l_col7                                  ,
10084        l_col8                                  ,
10085        l_col9                                  ,
10086        l_col10                                 ,
10087        l_col11                                 ,
10088        l_col12                                 ,
10089        l_col13                                 ,
10090        l_col14                                 ,
10091        l_col15                                 ,
10092        l_col16                                 ,
10093        l_col17                                 ,
10094        l_col18                                 ,
10095        l_col19                                 ,
10096        l_col20                                 ,
10097        l_col21                                 ,
10098        l_col22                                 ,
10099        l_col23                                 ,
10100        l_col24                                 ,
10101        l_col25                                 ,
10102        l_col26                                 ,
10103        l_col27                                 ,
10104        l_col28                                 ,
10105        l_col29                                 ,
10106        l_col30                                 ,
10107        l_col31                                 ,
10108        l_col32                                 ,
10109        l_col33                                 ,
10110        l_col34                                 ,
10111        l_col35                                 ,
10112        l_col36                                 ,
10113        l_col37                                 ,
10114        l_col38                                 ,
10115        l_col39                                 ,
10116        l_col40                                 ,
10117        l_col41                                 ,
10118        l_col42                                 ,
10119        l_col43                                 ,
10120        l_col44                                 ,
10121        l_col45                                 ,
10122        l_col46                                 ,
10123        l_col47                                 ,
10124        l_col48                                 ,
10125        l_col49                                 ,
10126 --       l_col50                                 ,
10127 --       l_col51                                 ,
10128 --       l_col52                                 ,
10129        l_col53                                 ,
10130 --       l_col54                                 ,
10131        l_col55                                 ,
10132 --       l_col56                                 ,
10133 --       l_col57                                 ,
10134 --       l_col58                                 ,
10135        l_col59                                 ,
10136        l_col60                                 ,
10137        l_col61                                 ,
10138        l_col62                                 ,
10139        l_col63                                 ,
10140        l_col64                                 ,
10141        l_col65                                 ,
10142        l_col66                                 ,
10143        l_col67                                 ,
10144        l_col68                                 ,
10145        l_col69                                 ,
10146        l_col70                                 ,
10147        l_col71                                 ,
10148        l_col72                                 ,
10149        l_col73                                 ,
10150        l_col74                                 ,
10151        l_col75                                 ,
10152        l_col76                                 ,
10153        l_col77                                 ,
10154        l_col78                                 ,
10155        l_col79                                 ,
10156        l_col80                                 ,
10157        l_col81                                 ,
10158        l_col82                                 ,
10159        l_col83                                 ,
10160        l_col84                                 ,
10161        l_col85                                 ,
10162        l_col86                                 ,
10163        l_col87                                 ,
10164        l_col88                                 ,
10165        l_col89                                 ,
10166        l_col90                                 ,
10167        l_col91                                 ,
10168        l_col92                                 ,
10169        l_col93                                 ,
10170        l_col94                                 ,
10171        l_col95                                 ,
10172        l_col96                                 ,
10173        l_col97                                 ,
10174        l_col98                                 ,
10175        l_col99                                 ,
10176        l_col100                                ,
10177        l_col101                                ,
10178        l_col102                                ,
10179        l_col103                                ,
10180        l_col104                                ,
10181        l_col105                                ,
10182        l_col106                                ,
10183        l_col107                                ,
10184        l_col108                                ,
10185        l_col109                                ,
10186        l_col110                                ,
10187        l_col111                                ,
10188        l_col112                                ,
10189        l_col113                                ,
10190        l_col114                                ,
10191        l_col115                                ,
10192        l_col116                                ,
10193        l_col117                                ,
10194        l_col118                                ,
10195        l_col119                                ,
10196        l_col120                                ,
10197        l_col121                                ,
10198        l_col122                                ,
10199        l_col123                                ,
10200        l_col124                                ,
10201        l_col125                                ,
10202        l_col126                                ,
10203        l_col127                                ,
10204        l_col128                                ,
10205        l_col129                                ,
10206        l_col130                                ,
10207        l_col131                                ,
10208        l_col132                                ,
10209        l_col133                                ,
10210        l_col134                                ,
10211        l_col135                                ,
10212        l_col136                                ,
10213        l_col137                                ,
10214        l_col138                                ,
10215        l_col139                                ,
10216        l_col140                                ,
10217        l_col141                                ,
10218        l_col142                                ,
10219        l_col143                                ,
10220        l_col144                                ,
10221        l_col145                                ,
10222        l_col146                                ,
10223        l_col147                                ,
10224        l_col148                                ,
10225        l_col149                                ,
10226        l_col150                                ,
10227        l_col151                                ,
10228        l_col152                                ,
10229        l_col153                                ,
10230        l_col154                                ,
10231        l_col155                                ,
10232        l_col156                                ,
10233        l_col157                                ,
10234        l_col158                                ,
10235        l_col159                                ,
10236        l_col160                                ,
10237        l_col161                                ,
10238        l_col162                                ,
10239        l_col163                                ,
10240        l_col164                                ,
10241        l_col165                                ,
10242        l_col166                                ,
10243        l_col167                                ,
10244        l_col168                                ,
10245        l_col169                                ,
10246        l_col170                                ,
10247        l_col171                                ,
10248        l_col172                                ,
10249        l_col173                                ,
10250        l_col174                                ,
10251        l_col175                                ,
10252        l_col176                                ,
10253        l_col177                                ,
10254        l_col178                                ,
10255        l_col179                                ,
10256        l_col180                                ,
10257        l_col181                                ,
10258        l_col182                                ,
10259        l_col183                                ,
10260        l_col184                                ,
10261        l_col185                                ,
10262        l_col186                                ,
10263        l_col187                                ,
10264        l_col188                                ,
10265        l_col189                                ,
10266        l_col190                                ,
10267        l_col191                                ,
10268        l_col192                                ,
10269        l_col193                                ,
10270        l_col194                                ,
10271         l_col221,
10272         l_col222,
10273         l_col223,
10274         l_col224,
10275         l_col225,
10276         l_col226,
10277         l_col227,
10278         l_col228,
10279         l_col229,
10280         l_col230,
10281         l_col231,
10282         l_col232,
10283         l_col233,
10284         l_col234,
10285         l_col235,
10286         l_col236,
10287         l_col237,
10288         l_col238,
10289         l_col239,
10290         l_col240,
10291         l_col241,
10292         l_col242,
10293         l_col243,
10294         l_col244,
10295         l_col245,
10296         l_col246,
10297         l_col247,
10298         l_col248,
10299         l_col249,
10300         l_col251,
10301         l_col252,
10302         l_col253,
10303         l_col254,
10304         l_col255,
10305         l_col256,
10306         l_col257,
10307         l_col258,
10308         l_col259,
10309         l_col260,
10310         l_col261,
10311         l_col262,
10312         l_col263,
10313         l_col264,
10314         l_col265,
10315         l_col266,
10316         l_col267,
10317         l_col268,
10318         l_col269,
10319         l_col270,
10320         l_col271,
10321         l_col272,
10322         l_col273,
10323         l_col274,
10324         l_col275,
10325         l_col276,
10326         l_col277,
10327         l_col278,
10328         l_col279,
10329         l_col280,
10330         l_col281,
10331         l_col282,
10332         l_col283,
10333         l_col284,
10334         l_col285,
10335         l_col286,
10336         l_col287,
10337         l_col288,
10338         l_col289,
10339         l_col290,
10340         l_col291,
10341         l_col292,
10342         l_col293,
10343         l_col294,
10344         l_col295,
10345         l_col296,
10346         l_col297,
10347         l_col298,
10348         l_col299,
10349         l_col300,
10350         l_col301,
10351         l_col302
10352       LIMIT L_MAX_ROW_COUNT;
10353      else
10354      FETCH b2c BULK COLLECT INTO
10355        l_import_source_line_id,
10356        l_import_list_header_id,
10357        l_col1                                  ,
10358        l_col2                                  ,
10359        l_col3                                  ,
10360        l_col4                                  ,
10361        l_col5                                  ,
10362        l_col6                                  ,
10363        l_col7                                  ,
10364        l_col8                                  ,
10365        l_col9                                  ,
10366        l_col10                                 ,
10367        l_col11                                 ,
10368        l_col12                                 ,
10369        l_col13                                 ,
10370        l_col14                                 ,
10371        l_col15                                 ,
10372        l_col16                                 ,
10373        l_col17                                 ,
10374        l_col18                                 ,
10375        l_col19                                 ,
10376        l_col20                                 ,
10377        l_col21                                 ,
10378        l_col22                                 ,
10379        l_col23                                 ,
10380        l_col24                                 ,
10381        l_col25                                 ,
10382        l_col26                                 ,
10383 --       l_col27                                 ,
10384 --       l_col28                                 ,
10385 --       l_col29                                 ,
10386        l_col30                                 ,
10387 --       l_col31                                 ,
10388        l_col32                                 ,
10389 --       l_col33                                 ,
10390 --       l_col34                                 ,
10391 --       l_col35                                 ,
10392        l_col36                                 ,
10393        l_col37                                 ,
10394        l_col38                                 ,
10395        l_col39                                 ,
10396        l_col40                                 ,
10397        l_col41                                 ,
10398        l_col42                                 ,
10399        l_col43                                 ,
10400        l_col44                                 ,
10401        l_col45                                 ,
10402        l_col46                                 ,
10403        l_col47                                 ,
10404        l_col48                                 ,
10405        l_col49                                 ,
10406        l_col50                                 ,
10407        l_col51                                 ,
10408        l_col52                                 ,
10409        l_col53                                 ,
10410        l_col54                                 ,
10411        l_col55                                 ,
10412        l_col56                                 ,
10413        l_col57                                 ,
10414        l_col58                                 ,
10415        l_col59                                 ,
10416        l_col60                                 ,
10417        l_col61                                 ,
10418        l_col62                                 ,
10419        l_col63                                 ,
10420        l_col64                                 ,
10421        l_col65                                 ,
10422        l_col66                                 ,
10423        l_col67                                 ,
10424        l_col68                                 ,
10425        l_col69                                 ,
10426        l_col70                                 ,
10427        l_col71                                 ,
10428        l_col72                                 ,
10429        l_col73                                 ,
10430        l_col74                                 ,
10431        l_col75                                 ,
10432        l_col76                                 ,
10433        l_col77                                 ,
10434        l_col78                                 ,
10435        l_col79                                 ,
10436        l_col80                                 ,
10437        l_col81                                 ,
10438        l_col82                                 ,
10439        l_col83                                 ,
10440        l_col84                                 ,
10441        l_col85                                 ,
10442        l_col86                                 ,
10443        l_col87                                 ,
10444        l_col88                                 ,
10445        l_col89                                 ,
10446        l_col90                                 ,
10447        l_col91                                 ,
10448        l_col92                                 ,
10449        l_col93                                 ,
10450        l_col94                                 ,
10451        l_col95                                 ,
10452        l_col96                                 ,
10453        l_col97                                 ,
10454        l_col98                                 ,
10455        l_col99                                 ,
10456        l_col100                                ,
10457        l_col101                                ,
10458        l_col102                                ,
10459        l_col103                                ,
10460        l_col104                                ,
10461        l_col105                                ,
10462        l_col106                                ,
10463        l_col107                                ,
10464        l_col108                                ,
10465        l_col109                                ,
10466        l_col110                                ,
10467        l_col111                                ,
10468        l_col112                                ,
10469        l_col113                                ,
10470        l_col114                                ,
10471        l_col115                                ,
10472        l_col116                                ,
10473        l_col117                                ,
10474        l_col118                                ,
10475        l_col119                                ,
10476        l_col120                                ,
10477        l_col121                                ,
10478        l_col122                                ,
10479        l_col123                                ,
10480        l_col124                                ,
10481        l_col125                                ,
10482        l_col126                                ,
10483        l_col127                                ,
10484        l_col128                                ,
10485        l_col129                                ,
10486        l_col130                                ,
10487        l_col131                                ,
10488        l_col132                                ,
10489        l_col133                                ,
10490        l_col134                                ,
10491        l_col135                                ,
10492        l_col136                                ,
10493        l_col137                                ,
10494        l_col138                                ,
10495        l_col139                                ,
10496        l_col140                                ,
10497        l_col141                                ,
10498        l_col142                                ,
10499        l_col143                                ,
10500        l_col144                                ,
10501        l_col145                                ,
10502        l_col146                                ,
10503        l_col147                                ,
10504        l_col148                                ,
10505        l_col149                                ,
10506        l_col150                                ,
10507        l_col151                                ,
10508        l_col152                                ,
10509        l_col153                                ,
10510        l_col154                                ,
10511        l_col155                                ,
10512        l_col156                                ,
10513        l_col157                                ,
10514        l_col158                                ,
10515        l_col159                                ,
10516        l_col160                                ,
10517        l_col161                                ,
10518        l_col162                                ,
10519        l_col163                                ,
10520        l_col164                                ,
10521        l_col165                                ,
10522        l_col166                                ,
10523        l_col167                                ,
10524        l_col168                                ,
10525        l_col169                                ,
10526        l_col170                                ,
10527        l_col171                                ,
10528        l_col172                                ,
10529        l_col173                                ,
10530        l_col174                                ,
10531        l_col175                                ,
10532        l_col176                                ,
10533        l_col177                                ,
10534        l_col178                                ,
10535        l_col179                                ,
10536        l_col180                                ,
10537        l_col181                                ,
10538        l_col182                                ,
10539        l_col183                                ,
10540        l_col184                                ,
10541        l_col185                                ,
10542        l_col186                                ,
10543        l_col187                                ,
10544        l_col188                                ,
10545        l_col189                                ,
10546        l_col190                                ,
10547        l_col191                                ,
10548        l_col192                                ,
10549        l_col193                                ,
10550        l_col194                                ,
10551         l_col221,
10552         l_col222,
10553         l_col223,
10554         l_col224,
10555         l_col225,
10556         l_col226,
10557         l_col227,
10558         l_col228,
10559         l_col229,
10560         l_col230,
10561         l_col231,
10562         l_col232,
10563         l_col233,
10564         l_col234,
10565         l_col235,
10566         l_col236,
10567         l_col237,
10568         l_col238,
10569         l_col239,
10570         l_col240,
10571         l_col241,
10572         l_col242,
10573         l_col243,
10574         l_col244,
10575         l_col245,
10576         l_col246,
10577         l_col247,
10578         l_col248,
10579         l_col249,
10580         l_col251,
10581         l_col252,
10582         l_col253,
10583         l_col254,
10584         l_col255,
10585         l_col256,
10586         l_col257,
10587         l_col258,
10588         l_col259,
10589         l_col260,
10590         l_col261,
10591         l_col262,
10592         l_col263,
10593         l_col264,
10594         l_col265,
10595         l_col266,
10596         l_col267,
10597         l_col268,
10598         l_col269,
10599         l_col270,
10600         l_col271,
10601         l_col272,
10602         l_col273,
10603         l_col274,
10604         l_col275,
10605         l_col276,
10606         l_col277,
10607         l_col278,
10608         l_col279,
10609         l_col280,
10610         l_col281,
10611         l_col282,
10612         l_col283,
10613         l_col284,
10614         l_col285,
10615         l_col286,
10616         l_col287,
10617         l_col288,
10618         l_col289,
10619         l_col290,
10620         l_col291,
10621         l_col292,
10622         l_col293,
10623         l_col294,
10624         l_col295,
10625         l_col296,
10626         l_col297,
10627         l_col298,
10628         l_col299,
10629         l_col300,
10630         l_col301,
10631         l_col302
10632       LIMIT L_MAX_ROW_COUNT;
10633     end if;
10634 
10635       FORALL i IN 1 .. l_import_source_line_id.count
10636        INSERT INTO ams_list_import_errors
10637        (
10638         LIST_IMPORT_ERROR_ID,
10639         LAST_UPDATED_BY,
10640         LAST_UPDATE_DATE,
10641         CREATION_DATE,
10642         CREATED_BY,
10643         LAST_UPDATE_LOGIN,
10644         IMPORT_SOURCE_LINE_ID,
10645         IMPORT_LIST_HEADER_ID,
10646         IMPORT_TYPE,
10647         ERROR_TYPE,
10648         batch_id,
10649         error_flag,
10650         col1                                  ,
10651         col2                                  ,
10652         col3                                  ,
10653         col4                                  ,
10654         col5                                  ,
10655         col6                                  ,
10656         col7                                  ,
10657         col8                                  ,
10658         col9                                  ,
10659         col10                                 ,
10660         col11                                 ,
10661         col12                                 ,
10662         col13                                 ,
10663         col14                                 ,
10664         col15                                 ,
10665         col16                                 ,
10666         col17                                 ,
10667         col18                                 ,
10668         col19                                 ,
10669         col20                                 ,
10670         col21                                 ,
10671         col22                                 ,
10672         col23                                 ,
10673         col24                                 ,
10674         col25                                 ,
10675         col26                                 ,
10676         col27                                 ,
10677         col28                                 ,
10678         col29                                 ,
10679         col30                                 ,
10680         col31                                 ,
10681         col32                                 ,
10682         col33                                 ,
10683         col34                                 ,
10684         col35                                 ,
10685         col36                                 ,
10686         col37                                 ,
10687         col38                                 ,
10688         col39                                 ,
10689         col40                                 ,
10690         col41                                 ,
10691         col42                                 ,
10692         col43                                 ,
10693         col44                                 ,
10694         col45                                 ,
10695         col46                                 ,
10696         col47                                 ,
10697         col48                                 ,
10698         col49                                 ,
10699        -- col50                                 ,
10700         --col51                                 ,
10701         --col52                                 ,
10702         col53                                 ,
10703         --col54                                 ,
10704         col55                                 ,
10705         --col56                                 ,
10706         --col57                                 ,
10707         --col58                                 ,
10708         col59                                 ,
10709         col60                                 ,
10710         col61                                 ,
10711         col62                                 ,
10712         col63                                 ,
10713         col64                                 ,
10714         col65                                 ,
10715         col66                                 ,
10716         col67                                 ,
10717         col68                                 ,
10718         col69                                 ,
10719         col70                                 ,
10720         col71                                 ,
10721         col72                                 ,
10722         col73                                 ,
10723         col74                                 ,
10724         col75                                 ,
10725         col76                                 ,
10726         col77                                 ,
10727         col78                                 ,
10728         col79                                 ,
10729         col80                                 ,
10730         col81                                 ,
10731         col82                                 ,
10732         col83                                 ,
10733         col84                                 ,
10734         col85                                 ,
10735         col86                                 ,
10736         col87                                 ,
10737         col88                                 ,
10738         col89                                 ,
10739         col90                                 ,
10740         col91                                 ,
10741         col92                                 ,
10742         col93                                 ,
10743         col94                                 ,
10744         col95                                 ,
10745         col96                                 ,
10746         col97                                 ,
10747         col98                                 ,
10748         col99                                 ,
10749         col100                                ,
10750         col101                                ,
10751         col102                                ,
10752         col103                                ,
10753         col104                                ,
10754         col105                                ,
10755         col106                                ,
10756         col107                                ,
10757         col108                                ,
10758         col109                                ,
10759         col110                                ,
10760         col111                                ,
10761         col112                                ,
10762         col113                                ,
10763         col114                                ,
10764         col115                                ,
10765         col116                                ,
10766         col117                                ,
10767         col118                                ,
10768         col119                                ,
10769         col120                                ,
10770         col121                                ,
10771         col122                                ,
10772         col123                                ,
10773         col124                                ,
10774         col125                                ,
10775         col126                                ,
10776         col127                                ,
10777         col128                                ,
10778         col129                                ,
10779         col130                                ,
10780         col131                                ,
10781         col132                                ,
10782         col133                                ,
10783         col134                                ,
10784         col135                                ,
10785         col136                                ,
10786         col137                                ,
10787         col138                                ,
10788         col139                                ,
10789         col140                                ,
10790         col141                                ,
10791         col142                                ,
10792         col143                                ,
10793         col144                                ,
10794         col145                                ,
10795         col146                                ,
10796         col147                                ,
10797         col148                                ,
10798         col149                                ,
10799         col150                                ,
10800         col151                                ,
10801         col152                                ,
10802         col153                                ,
10803         col154                                ,
10804         col155                                ,
10805         col156                                ,
10806         col157                                ,
10807         col158                                ,
10808         col159                                ,
10809         col160                                ,
10810         col161                                ,
10811         col162                                ,
10812         col163                                ,
10813         col164                                ,
10814         col165                                ,
10815         col166                                ,
10816         col167                                ,
10817         col168                                ,
10818         col169                                ,
10819         col170                                ,
10820         col171                                ,
10821         col172                                ,
10822         col173                                ,
10823         col174                                ,
10824         col175                                ,
10825         col176                                ,
10826         col177                                ,
10827         col178                                ,
10828         col179                                ,
10829         col180                                ,
10830         col181                                ,
10831         col182                                ,
10832         col183                                ,
10833         col184                                ,
10834         col185                                ,
10835         col186                                ,
10836         col187                                ,
10837         col188                                ,
10838         col189                                ,
10839         col190                                ,
10840         col191                                ,
10841         col192                                ,
10842         col193                                ,
10843         col194
10844        )
10845        VALUES
10846        (
10847         ams_list_import_errors_s.nextval,      -- LIST_IMPORT_ERROR_ID,
10848         FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
10849         SYSDATE,                              -- LAST_UPDATE_DATE,
10850         SYSDATE,                              -- CREATION_DATE,
10851         FND_GLOBAL.User_ID,                   -- CREATED_BY,
10852         FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
10853         l_import_source_line_id(i),
10854         l_import_list_header_id(i),
10855         l_imp_type,  -- 'CUSTOMER',                                -- IMPORT_TYPE,
10856         'E',                                  -- ERROR_TYPE,
10857         l_batch_id,
10858        'Y',
10859        l_col1(i),
10860        l_col2(i),
10861        l_col3(i),
10862        l_col4(i),
10863        l_col5(i),
10864        l_col6(i),
10865        l_col7(i),
10866        l_col8(i),
10867        l_col9(i),
10868        l_col10(i),
10869        l_col11(i),
10870        l_col12(i),
10871        l_col13(i),
10872        l_col14(i),
10873        l_col15(i),
10874        l_col16(i),
10875        l_col17(i),
10876        l_col18(i),
10877        l_col19(i),
10878        l_col20(i),
10879        l_col21(i),
10880        l_col22(i),
10881        l_col23(i),
10882        l_col24(i),
10883        l_col25(i),
10884        l_col26(i),
10885        l_col27(i),
10886        l_col28(i),
10887        l_col29(i),
10888        l_col30(i),
10889        l_col31(i),
10890        l_col32(i),
10891        l_col33(i),
10892        l_col34(i),
10893        l_col35(i),
10894        l_col36(i),
10895        l_col37(i),
10896        l_col38(i),
10897        l_col39(i),
10898        l_col40(i),
10899        l_col41(i),
10900        l_col42(i),
10901        l_col43(i),
10902        l_col44(i),
10903        l_col45(i),
10904        l_col46(i),
10905        l_col47(i),
10906        l_col48(i),
10907        l_col49(i),
10908       -- l_col50(i),
10909      --  l_col51(i),
10910      --  l_col52(i),
10911        l_col53(i),
10912       -- l_col54(i),
10913        l_col55(i),
10914     --   l_col56(i),
10915       -- l_col57(i),
10916        --l_col58(i),
10917        l_col59(i),
10918        l_col60(i),
10919        l_col61(i),
10920        l_col62(i),
10921        l_col63(i),
10922        l_col64(i),
10923        l_col65(i),
10924        l_col66(i),
10925        l_col67(i),
10926        l_col68(i),
10927        l_col69(i),
10928        l_col70(i),
10929        l_col71(i),
10930        l_col72(i),
10931        l_col73(i),
10932        l_col74(i),
10933        l_col75(i),
10934        l_col76(i),
10935        l_col77(i),
10936        l_col78(i),
10937        l_col79(i),
10938        l_col80(i),
10939        l_col81(i),
10940        l_col82(i),
10941        l_col83(i),
10942        l_col84(i),
10943        l_col85(i),
10944        l_col86(i),
10945        l_col87(i),
10946        l_col88(i),
10947        l_col89(i),
10948        l_col90(i),
10949        l_col91(i),
10950        l_col92(i),
10951        l_col93(i),
10952        l_col94(i),
10953        l_col95(i),
10954        l_col96(i),
10955        l_col97(i),
10956        l_col98(i),
10957        l_col99(i),
10958        l_col100(i),
10959        l_col101(i),
10960        l_col102(i),
10961        l_col103(i),
10962        l_col104(i),
10963        l_col105(i),
10964        l_col106(i),
10965        l_col107(i),
10966        l_col108(i),
10967        l_col109(i),
10968        l_col110(i),
10969        l_col111(i),
10970        l_col112(i),
10971        l_col113(i),
10972        l_col114(i),
10973        l_col115(i),
10974        l_col116(i),
10975        l_col117(i),
10976        l_col118(i),
10977        l_col119(i),
10978        l_col120(i),
10979        l_col121(i),
10980        l_col122(i),
10981        l_col123(i),
10982        l_col124(i),
10983        l_col125(i),
10984        l_col126(i),
10985        l_col127(i),
10986        l_col128(i),
10987        l_col129(i),
10988        l_col130(i),
10989        l_col131(i),
10990        l_col132(i),
10991        l_col133(i),
10992        l_col134(i),
10993        l_col135(i),
10994        l_col136(i),
10995        l_col137(i),
10996        l_col138(i),
10997        l_col139(i),
10998        l_col140(i),
10999        l_col141(i),
11000        l_col142(i),
11001        l_col143(i),
11002        l_col144(i),
11003        l_col145(i),
11004        l_col146(i),
11005        l_col147(i),
11006        l_col148(i),
11007        l_col149(i),
11008        l_col150(i),
11009        l_col151(i),
11010        l_col152(i),
11011        l_col153(i),
11012        l_col154(i),
11013        l_col155(i),
11014        l_col156(i),
11015        l_col157(i),
11016        l_col158(i),
11017        l_col159(i),
11018        l_col160(i),
11019        l_col161(i),
11020        l_col162(i),
11021        l_col163(i),
11022        l_col164(i),
11023        l_col165(i),
11024        l_col166(i),
11025        l_col167(i),
11026        l_col168(i),
11027        l_col169(i),
11028        l_col170(i),
11029        l_col171(i),
11030        l_col172(i),
11031        l_col173(i),
11032        l_col174(i),
11033        l_col175(i),
11034        l_col176(i),
11035        l_col177(i),
11036        l_col178(i),
11037        l_col189(i),
11038        l_col180(i),
11039        l_col181(i),
11040        l_col182(i),
11041        l_col183(i),
11042        l_col184(i),
11043        l_col185(i),
11044        l_col186(i),
11045        l_col187(i),
11046        l_col188(i),
11047        l_col189(i),
11048        l_col190(i),
11049        l_col191(i),
11050        l_col192(i),
11051        l_col193(i),
11052        l_col194(i)
11053       );
11054     if x_b2b = 'B2B' then
11055       EXIT WHEN b2b%NOTFOUND;
11056      else
11057       EXIT WHEN b2c%NOTFOUND;
11058     end if;
11059     END LOOP;
11060     if x_b2b = 'B2B' then
11061       CLOSE b2b;
11062      else
11063       CLOSE b2c;
11064     end if;
11065          if x_b2b = 'B2B' then
11066            OPEN c_b2b_date_fields;
11067            LOOP
11068            FETCH c_b2b_date_fields into x_import_list_header_id,x_import_source_line_id,l_ADDRESS_EFFECTIVE_DATE,
11069                  l_ADDRESS_EXPIRATION_DATE,l_DATE_OF_BIRTH,l_DATE_OF_DEATH,l_DEBARTMENTS_DATE,
11070 		 l_MARITAL_STATUS_EFF_DATE;
11071            EXIT WHEN c_b2b_date_fields%NOTFOUND;
11072            date_validate( x_import_list_header_id,x_import_source_line_id,l_batch_id,l_ADDRESS_EFFECTIVE_DATE,
11073                  l_ADDRESS_EXPIRATION_DATE, l_DATE_OF_BIRTH,l_DATE_OF_DEATH,l_DEBARTMENTS_DATE,l_MARITAL_STATUS_EFF_DATE);
11074            End Loop;
11075            CLOSE c_b2b_date_fields;
11076          end if;
11077          if x_b2b = 'B2C' then
11078            OPEN c_b2c_date_fields;
11079            LOOP
11080            FETCH c_b2c_date_fields into x_import_list_header_id,x_import_source_line_id,l_ADDRESS_EFFECTIVE_DATE,
11081                  l_ADDRESS_EXPIRATION_DATE,l_DATE_OF_BIRTH,l_DATE_OF_DEATH,l_DEBARTMENTS_DATE,
11082 		 l_MARITAL_STATUS_EFF_DATE;
11083            EXIT WHEN c_b2c_date_fields%NOTFOUND;
11084            date_validate( x_import_list_header_id,x_import_source_line_id,l_batch_id,l_ADDRESS_EFFECTIVE_DATE,
11085                  l_ADDRESS_EXPIRATION_DATE, l_DATE_OF_BIRTH,l_DATE_OF_DEATH,null,l_MARITAL_STATUS_EFF_DATE);
11086            End Loop;
11087            CLOSE c_b2c_date_fields;
11088          end if;
11089        UPDATE ams_imp_source_lines
11090          SET load_status = decode(load_status,'DUPLICATE','DUPLICATE','ERROR')
11091        WHERE import_list_header_id = p_import_list_header_id
11092          and import_source_line_id in
11093        (select import_source_line_id from ams_list_import_errors
11094         where import_list_header_id = p_import_list_header_id
11095           and error_type = 'E');
11096 
11097 EXCEPTION
11098  WHEN OTHERS THEN
11099     p_return_status := FND_API.G_RET_STS_ERROR;
11100     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
11101     FND_MESSAGE.Set_Token('ROW','Error in execute_cust_data_validation:' || SQLERRM||' '||SQLCODE);
11102     AMS_Utility_PVT.Create_Log (
11103       x_return_status   => l_return_status,
11104       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
11105       p_log_used_by_id  => p_import_list_header_id,
11106       p_msg_data        => FND_MESSAGE.get,
11107       p_msg_type        => 'DEBUG'
11108    );
11109 
11110 end execute_cust_data_validation;
11111 -- ----------------------------------------------
11112 
11113 
11114 
11115 --
11116 -- This program performs error checks in ams_import_interface table.
11117 
11118 PROCEDURE exe_custxml_data_validation (
11119   			    p_import_list_header_id NUMBER,
11120                             p_return_status OUT NOCOPY     VARCHAR2
11121                             ) IS
11122 l_batch_id                                      NUMBER;
11123 l_import_list_header_id                         number;
11124 l_import_source_line_id                         number;
11125 l_invalid_number varchar2(4000) ;
11126 l_invalid_size   varchar2(4000) ;
11127 l_null_value     varchar2(4000) ;
11128 x_b2b                           varchar(30);
11129 l_return_status                 varchar(1);
11130 l_imp_type         varchar2(60);
11131 
11132    l_cust_b2b_rec		data_in_rec_type;
11133    l_cust_b2c_rec		data_in_rec_b2c_type;
11134 
11135 
11136 CURSOR c_lead_batch_id is
11137 SELECT
11138 batch_id
11139 FROM ams_imp_list_headers_all
11140 WHERE import_list_header_id = p_import_list_header_id;
11141 
11142 -- Cursor for B2B party type
11143 
11144 cursor b2b is
11145  SELECT
11146  IMPORT_SOURCE_LINE_ID,
11147  import_list_header_id,
11148  org_imp_xml_element_id,
11149  add_imp_xml_element_id,
11150  ocont_imp_xml_element_id,
11151  cp_imp_xml_element_id,
11152  em_imp_xml_element_id,
11153 DECODE(GREATEST(lengthb(LTRIM(RTRIM(PARTY_NAME))),255) - 255,0,' ','PARTY_NAME :'||decode(nvl(PARTY_NAME,'x'),'x',l_null_value,l_invalid_size)||'(255)') PARTY_NAME,
11154 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FISCAL_YEAREND_MONTH)),'x')),30) - 30,0,' ','FISCAL_YEAREND_MONTH :'||l_invalid_size||'(30)') FISCAL_YEAREND_MONTH,
11155 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DUNS_NUMBER,' ','x'))),'0123456789.',           'x'))),0),0,' ','DUNS_NUMBER :'||l_invalid_number) DUNS_NUMBER,
11156 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(EMPLOYEES_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,' ','EMPLOYEES_TOTAL :'||l_invalid_number) EMPLOYEES_TOTAL,
11157 DECODE(GREATEST(lengthb(nvl(LINE_OF_BUSINESS,'x')),240) - 240,0,' ','LINE_OF_BUSINESS :'||l_invalid_size) LINE_OF_BUSINESS,
11158 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,' ','ADDRESS1 :'||l_invalid_size||'(240)') ADDRESS1,
11159 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,' ','ADDRESS2 :'||l_invalid_size||'(240)') ADDRESS2,
11160 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,' ','ADDRESS3 :'||l_invalid_size||'(240)') ADDRESS3,
11161 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,' ','ADDRESS4 :'||l_invalid_size||'(240)') ADDRESS4,
11162 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(YEAR_ESTABLISHED,' ','x'))),'0123456789.','           x'))),0),0,' ','YEAR_ESTABLISHED :'||l_invalid_number) YEAR_ESTABLISHED,
11163 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),50) - 50,0,' ','TAX_REFERENCE :'||l_invalid_size||'(50)') TAX_REFERENCE,
11164 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CEO_NAME)),'x')),240) - 240,0,' ','CEO_NAME :'||l_invalid_size||'(240)') CEO_NAME,
11165 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME)),'x')),50) - 50,0,' ','PERSON_LAST_NAME :'||l_invalid_size||'(50)') PERSON_LAST_NAME,
11166 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME)),'x')),40) - 40,0,' ','PERSON_FIRST_NAME :'||l_invalid_size||'(40)') PERSON_FIRST_NAME,
11167 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,' ','PERSON_NAME_PREFIX :'||l_invalid_size||'(30)') PERSON_NAME_PREFIX,
11168 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE)),'x')),100) - 100,0,' ','JOB_TITLE :'||l_invalid_size||'(100)') JOB_TITLE,
11169 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,' ','PERSON_MIDDLE_NAME :'||l_invalid_size||'(60)') PERSON_MIDDLE_NAME,
11170 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,' ','PERSON_NAME_SUFFIX :'||l_invalid_size||'(30)') PERSON_NAME_SUFFIX,
11171 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,' ','CITY :'||l_invalid_size||'(60)') CITY ,
11172 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,' ','POSTAL_CODE :'||l_invalid_size||'(60)') POSTAL_CODE,
11173 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,' ','STATE :'||l_invalid_size||'(60)') STATE,
11174 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,' ','PROVINCE :'||l_invalid_size||'(60)') PROVINCE,
11175 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,' ','COUNTY :'||l_invalid_size||'(60)') COUNTY,
11176 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,' ','COUNTRY :'||l_invalid_size||'(60)') COUNTRY,
11177 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,' ','EMAIL_ADDRESS :'||l_invalid_size||'(240)') EMAIL_ADDRESS,
11178 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,' ','PHONE_COUNTRY_CODE :'||l_invalid_size||'(30)') PHONE_COUNTRY_CODE,
11179 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,' ','PHONE_AREA_CODE :'||l_invalid_size||'(10)') PHONE_AREA_CODE,
11180 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,' ','PHONE_NUMBER :'||l_invalid_size||'(25)') PHONE_NUMBER,
11181 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,' ','PHONE_EXTENTION :'||l_invalid_size||'(20)') PHONE_EXTENTION,
11182 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT)),'x')),60) - 60,0,' ','DEPARTMENT :'||l_invalid_size||'(60)') DEPARTMENT,
11183 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,' ','DECISION_MAKER_FLAG :'||l_invalid_size||'(1)') DECISION_MAKER_FLAG,
11184 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE)),'x')),30) - 30,0,' ','SIC_CODE :'||l_invalid_size||'(30)') SIC_CODE,
11185 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SIC_CODE_TYPE)),'x')),30) - 30,0,' ','SIC_CODE_TYPE :'||l_invalid_size||'(30)') SIC_CODE_TYPE,
11186 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ANALYSIS_FY)),'x')),5) - 5,0,' ','ANALYSIS_FY :'||l_invalid_size||'(5)') ANALYSIS_FY,
11187 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CURR_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,' ','CURR_FY_POTENTIAL_REVENUE :'||l_invalid_number) CURR_FY_POTENTIAL_REVENUE,
11188 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(NEXT_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,' ','NEXT_FY_POTENTIAL_REVENUE :'||l_invalid_number) NEXT_FY_POTENTIAL_REVENUE,
11189 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GSA_INDICATOR_FLAG)),'x')),1) - 1,0,' ','GSA_INDICATOR_FLAG :'||l_invalid_size||'(1)') GSA_INDICATOR_FLAG,
11190 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,' ','identifying_address_flag :'||l_invalid_size||'(1)') identifying_address_flag,
11191 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MISSION_STATEMENT)),'x')),2000) - 2000,0,' ','MISSION_STATEMENT :'||l_invalid_size||'(2000)') MISSION_STATEMENT,
11192 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_NAME_PHONETIC)),'x')),320) - 320,0,' ','ORGANIZATION_NAME_PHONETIC :'||l_invalid_size||'(320)') ORGANIZATION_NAME_PHONETIC,
11193 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CATEGORY_CODE)),'x')),30) -30,0,' ','CATEGORY_CODE:'||l_invalid_size||'(30)') CATEGORY_CODE,
11194 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JGZZ_FISCAL_CODE)),'x')),20) - 20,0,' ','JGZZ_FISCAL_CODE :'||l_invalid_size||'(20)') JGZZ_FISCAL_CODE,
11195 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,' ','ADDRESS_LINES_PHONETIC :'||l_invalid_size||'(560)') ADDRESS_LINES_PHONETIC,
11196 -- bug 4641591: columns obsolete
11197 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,' ','PO_BOX_NUMBER :'||l_invalid_size||'(50)') PO_BOX_NUMBER,
11198 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,' ','FLOOR :'||l_invalid_size||'(50)') FLOOR,
11199 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,' ','HOUSE_NUMBER :'||l_invalid_size||'(50)') HOUSE_NUMBER,
11200 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),10) - 10,0,' ','POSTAL_PLUS4_CODE :'||l_invalid_size||'(10)') POSTAL_PLUS4_CODE,
11201 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,' ','STREET_SUFFIX :'||l_invalid_size||'(50)') STREET_SUFFIX,
11202 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,' ','STREET :'||l_invalid_size||'(50)') STREET,
11203 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,' ','STREET_NUMBER :'||l_invalid_size||'(50)') STREET_NUMBER,
11204 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SUITE)),'x')),50) - 50,0,' ','SUITE :'||l_invalid_size||'(50)') SUITE,
11205 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,' ','PARTY_ID :'||l_invalid_number) party_id,
11206 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_URL)),'x')),2000) - 2000,0,' ','ORGANIZATION_URL :'||l_invalid_size||'(2000)') ORGANIZATION_URL,
11207 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BRANCH_FLAG)),'x')),1) - 1,0,' ','BRANCH_FLAG :'||l_invalid_size||'(1)') BRANCH_FLAG,
11208 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_LINE)),'x')),240) - 240,0,' ','BUSINESS_LINE :'||l_invalid_size||'(240)') BUSINESS_LINE,
11209 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_SCOPE)),'x')),20) - 20,0,' ','BUSINESS_SCOPE :'||l_invalid_size||'(20)') BUSINESS_SCOPE,
11210 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CHIEF_EXECUTIVE_TITLE)),'x')),240) - 240,0,' ','CHIEF_EXECUTIVE_TITLE :'||l_invalid_size||'(240)') CHIEF_EXECUTIVE_TITLE,
11211 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONGRESSIONAL_DISTRICT_CODE)),'x')),2) - 2,0,' ','CONGRESSIONAL_DISTRICT_CODE :'||l_invalid_size||'(2)') CONGRESSIONAL_DISTRICT_CODE,
11212 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CORPORATION_CLASS)),'x')),60) - 60,0,' ','CORPORATION_CLASS :'||l_invalid_size||'(60)') CORPORATION_CLASS,
11213 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE)),'x')),30) - 30,0,' ','CREDIT_SCORE :'||l_invalid_size||'(30)') CREDIT_SCORE,
11214 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE_COMMENTARY)),'x')),30) - 30,0,' ','CREDIT_SCORE_COMMENTARY :'||l_invalid_size||'(30)') CREDIT_SCORE_COMMENTARY,
11215 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DB_RATING)),'x')),5) - 5,0,' ','DB_RATING :'||l_invalid_size||'(5)') DB_RATING,
11216 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,' ','DECLARED_ETHNICITY :'||l_invalid_size||'(60)') DECLARED_ETHNICITY,
11217 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT_INDICATOR)),'x')),30) - 30,0,' ','DEPARTMENT_INDICATOR :'||l_invalid_size||'(30)') DEPARTMENT_INDICATOR,
11218 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION:'||l_invalid_size||'(2000)') DESCRIPTION,
11219 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DISADVANTAGED_INDICATOR)),'x')),30) - 30,0,' ','DISADVANTAGED_INDICATOR :'||l_invalid_size||'(30)') DISADVANTAGED_INDICATOR,
11220 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ENQUIRY_DUNS)),'x')),15) - 15,0,' ','ENQUIRY_DUNS :'||l_invalid_size||'(15)') ENQUIRY_DUNS,
11221 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EXPORT_INDICATOR)),'x')),30) - 30,0,' ','EXPORT_INDICATOR :'||l_invalid_size||'(30)') EXPORT_INDICATOR,
11222 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE)),'x')),30) - 30,0,' ','FAILURE_SCORE :'||l_invalid_size||'(30)') FAILURE_SCORE,
11223 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_COMMENTARY)),'x')),30) - 30,0,' ','FAILURE_SCORE_COMMENTARY :'||l_invalid_size||'(30)') FAILURE_SCORE_COMMENTARY,
11224 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_OVERRIDE_CODE)),'x')),30) - 30,0,' ','FAILURE_SCORE_OVERRIDE_CODE :'||l_invalid_size||'(30)') FAILURE_SCORE_OVERRIDE_CODE,
11225 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GLOBAL_FAILURE_SCORE)),'x')),5) - 5,0,' ','GLOBAL_FAILURE_SCORE :'||l_invalid_size||'(5)') GLOBAL_FAILURE_SCORE,
11226 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEADQUARTER_BRANCH_INDICATOR)),'x')),30) - 30,0,' ','HEADQUARTER_BRANCH_INDICATOR :'||l_invalid_size||'(30)') HEADQUARTER_BRANCH_INDICATOR,
11227 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEAD_OF_HOUSEHOLD_FLAG)),'x')),1) - 1,0,' ','HEAD_OF_HOUSEHOLD_FLAG :'||l_invalid_size||'(1)') HEAD_OF_HOUSEHOLD_FLAG,
11228 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(IMPORT_INDICATOR)),'x')),30) - 30,0,' ','IMPORT_INDICATOR :'||l_invalid_size||'(30)') IMPORT_INDICATOR,
11229 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS,
11230 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS2)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS2 :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS2,
11231 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS3)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS3 :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS3,
11232 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS4)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS4 :'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS4,
11233 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS5)),'x')),240) - 240,0,' ','ORGANIZATION_KNOWN_AS5:'||l_invalid_size||'(240)') ORGANIZATION_KNOWN_AS5,
11234 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS :'||l_invalid_size||'(240)') PERSON_KNOWN_AS,
11235 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS2 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS2,
11236 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS3 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS3,
11237 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS4 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS4,
11238 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS5 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS5,
11239 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LABOR_SURPLUS_INDICATOR)),'x')),30) - 30,0,' ','LABOR_SURPLUS_INDICATOR :'||l_invalid_size||'(30)') LABOR_SURPLUS_INDICATOR,
11240 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE)),'x')),30) - 30,0,' ','LOCAL_ACTIVITY_CODE :'||l_invalid_size||'(30)') LOCAL_ACTIVITY_CODE,
11241 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE_TYPE)),'x')),30) - 30,0,' ','LOCAL_ACTIVITY_CODE_TYPE :'||l_invalid_size||'(30)') LOCAL_ACTIVITY_CODE_TYPE,
11242 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,' ','LOCATION_DIRECTIONS :'||l_invalid_size||'(640)') LOCATION_DIRECTIONS,
11243 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,' ','MARITAL_STATUS :'||l_invalid_size||'(30)') MARITAL_STATUS,
11244 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_INDICATOR)),'x')),30) - 30,0,' ','MINORITY_OWNED_INDICATOR :'||l_invalid_size||'(30)') MINORITY_OWNED_INDICATOR,
11245 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_TYPE)),'x')),30) - 30,0,' ','MINORITY_OWNED_TYPE :'||l_invalid_size||'(30)') MINORITY_OWNED_TYPE,
11246 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_TYPE)),'x')),30) - 30,0,' ','ORGANIZATION_TYPE :'||l_invalid_size||'(30)') ORGANIZATION_TYPE,
11247 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OUT_OF_BUSINESS_INDICATOR)),'x')),30) - 30,0,' ','OUT_OF_BUSINESS_INDICATOR :'||l_invalid_size||'(30)') OUT_OF_BUSINESS_INDICATOR,
11248 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,' ','PERSON_ACADEMIC_TITLE :'||l_invalid_size||'(30)') PERSON_ACADEMIC_TITLE,
11249 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_FIRST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_FIRST_NAME_PHONETIC,
11250 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_LAST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_LAST_NAME_PHONETIC,
11251 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,' ','MIDDLE_NAME_PHONETIC :'||l_invalid_size||'(60)') MIDDLE_NAME_PHONETIC,
11252 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),320) - 320,0,' ','PERSON_NAME_PHONETIC :'||l_invalid_size||'(320)') PERSON_NAME_PHONETIC,
11253 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,' ','PERSON_PREVIOUS_TITLE_NAME :'||l_invalid_size||'(150)') PERSON_PREVIOUS_TITLE_NAME,
11254 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PLACE_OF_BIRTH)),'x')),60) - 60,0,' ','PLACE_OF_BIRTH :'||l_invalid_size||'(60)') PLACE_OF_BIRTH,
11255 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_NAME)),'x')),240) - 240,0,' ','PRINCIPAL_NAME :'||l_invalid_size||'(240)') PRINCIPAL_NAME,
11256 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_TITLE)),'x')),240) - 240,0,' ','PRINCIPAL_TITLE :'||l_invalid_size||'(240)') PRINCIPAL_TITLE,
11257 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PUBLIC_PRIVATE_OWNERSHIP_FLAG)),'x')),1) - 1,0,' ','PUBLIC_PRIVATE_OWNERSHIP_FLAG :'||l_invalid_size||'(1)') PUBLIC_PRIVATE_OWNERSHIP_FLAG,
11258 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,' ','RENT_OWNED_INDICATOR :'||l_invalid_size||'(30)') RENT_OWNED_INDICATOR,
11259 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,
11260 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SMALL_BUSINESS_INDICATOR)),'x')),30) - 30,0,' ','SMALL_BUSINESS_INDICATOR :'||l_invalid_size||'(30)') SMALL_BUSINESS_INDICATOR,
11261 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_ID)),'x')),60) - 60,0,' ','TAX_ID :'||l_invalid_size||'(60)') TAX_ID,
11262 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(WOMAN_OWNED_INDICATOR)),'x')),30) - 30,0,' ',' WOMAN_OWNED_INDICATOR :'||l_invalid_size||'(30)') WOMAN_OWNED_INDICATOR,
11263 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE1,
11264 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE2,
11265 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE3,
11266 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE4,
11267 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE5,
11268 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE6,
11269 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE7,
11270 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE8,
11271 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE9,
11272 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE10,
11273 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE11)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE11 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE11,
11274 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE12,
11275 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE13,
11276 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE14,
11277 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORGANIZATION_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORGANIZATION_ATTRIBUTE15,
11278 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE1)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE1 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE1,
11279 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE2)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE2 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE2,
11280 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE3)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE3 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE3,
11281 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE4)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE4 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE4,
11282 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE5)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE5 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE5,
11283 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE6)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE6 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE6,
11284 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE7)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE7 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE7,
11285 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE8)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE8 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE8,
11286 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE9)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE9 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE9,
11287 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE10)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE10 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE10,
11288 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE11,
11289 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE13)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE13 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE13,
11290 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE14)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE14 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE14,
11291 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE15)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE15 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE15,
11292 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE12)),'x')),150) - 150,0,' ','ORG_CONTACT_ATTRIBUTE12 :'||l_invalid_size||'(150)') ORG_CONTACT_ATTRIBUTE12,
11293 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE1 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE1,
11294 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE2 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE2,
11295 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE3 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE3,
11296 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE4 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE4,
11297 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE5 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE5,
11298 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE6 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE6,
11299 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE7 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE7,
11300 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE8 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE8,
11301 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE9 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE9,
11302 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE10 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE10,
11303 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE11 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE11,
11304 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE12 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE12,
11305 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE13 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE13,
11306 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE14 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE14,
11307 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE15 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE15,
11308 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,' ','FAX_COUNTRY_CODE :'||l_invalid_size||'(10)') FAX_COUNTRY_CODE,
11309 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,' ','FAX_AREA_CODE :'||l_invalid_size||'(10)') FAX_AREA_CODE,
11310 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,' ','FAX_NUMBER :'||l_invalid_size||'(40)') FAX_NUMBER,
11311 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_ATTRIBUTE_CATEGORY,
11312 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ORG_CONTACT_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ORG_CONTACT_ATTRIBUTE_CATEGORY,
11313 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ADDRESS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ADDRESS_ATTRIBUTE_CATEGORY,
11314 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CONTROL_YEAR,' ','x'))),'0123456789.','           x'))),0),0,' ','CONTROL_YEAR :'||l_invalid_number) CONTROL_YEAR,
11315 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DEBARMENTS_COUNT,' ','x'))),'0123456789.','           x'))),0),0,' ','DEBARMENTS_COUNT :'||l_invalid_number) DEBARMENTS_COUNT,
11316 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,' ','HOUSEHOLD_SIZE :'||l_invalid_number) HOUSEHOLD_SIZE,
11317 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','PERSONAL_INCOME :'||l_invalid_number) PERSONAL_INCOME,
11318 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,' ','NOTES :'||l_invalid_size||'(2000)') NOTES,
11319 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,' ','VEHICLE_RESPONSE_CODE :'||l_invalid_size||'(30)') VEHICLE_RESPONSE_CODE,
11320 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,' ','SALES_AGENT_EMAIL_ADDRESS:'||l_invalid_size||'(2000)') SALES_AGENT_EMAIL_ADDRESS,
11321 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) -240,0,' ','ORIG_SYSTEM_REFERENCE :'||l_invalid_size
11322 ||'(240)') ORIG_SYSTEM_REFERENCE
11323  FROM AMS_HZ_B2B_MAPPING_V
11324  WHERE IMPORT_LIST_HEADER_ID =  p_import_list_header_id
11325   and load_status = 'ERROR'
11326    AND
11327  (
11328  DECODE(GREATEST(lengthb(LTRIM(RTRIM(PARTY_NAME))),255) - 255,0,'OK','NO') = 'NO'
11329 or
11330  DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FISCAL_YEAREND_MONTH)),'x')),30) - 30,0,'OK','NO') = 'NO'
11331 or
11332 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DUNS_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11333 or
11334 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(EMPLOYEES_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11335 or
11336 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(YEAR_ESTABLISHED,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11337 or
11338 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CURR_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11339 or
11340 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(NEXT_FY_POTENTIAL_REVENUE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11341 or
11342 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11343 or
11344   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LINE_OF_BUSINESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
11345 or
11346   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
11347 or
11348   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
11349 or
11350   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
11351 or
11352   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
11353 or
11354   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),50) - 50,0,'OK','NO') = 'NO'
11355 or
11356   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CEO_NAME)),'x')),240) - 240,0,'OK','NO') = 'NO'
11357 or
11358   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME)),'x')),50) - 50,0,'OK','NO') = 'NO'
11359 or
11360   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME)),'x')),40) - 40,0,'OK','NO') = 'NO'
11361 or
11362   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
11363 or
11364   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JOB_TITLE)),'x')),100) - 100,0,'OK','NO') = 'NO'
11365 or
11366   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
11367 or
11368   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
11369 or
11370   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11371 or
11372   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11373 or
11374   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11375 or
11376   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11377 or
11378   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11379 or
11380   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11381 or
11382   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TIME_ZONE)),'x')),50) - 50,0,'OK','NO') = 'NO'
11383 or
11384   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
11385 or
11386   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11387 or
11388   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
11389 or
11390   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
11391 or
11392   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,'OK','NO') = 'NO'
11393 or
11394   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT)),'x')),60) - 60,0,'OK','NO') = 'NO'
11395 or
11396   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECISION_MAKER_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
11397 or
11398   DECODE(GREATEST(lengthb(nvl(SIC_CODE,'x')),30) - 30,0,'OK','NO') = 'NO'
11399 or
11400   DECODE(GREATEST(lengthb(nvl(SIC_CODE_TYPE,'x')),30) - 30,0,'OK','NO') = 'NO'
11401 or
11402   DECODE(GREATEST(lengthb(nvl(ANALYSIS_FY,'x')),5) - 5,0,'OK','NO') = 'NO'
11403 or
11404   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,'OK','NO') = 'NO'
11405 or
11406   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GSA_INDICATOR_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
11407 or
11408   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MISSION_STATEMENT)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11409 or
11410   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_NAME_PHONETIC)),'x')),320) - 320,0,'OK','NO') = 'NO'
11411 or
11412   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CATEGORY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11413 or
11414   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(JGZZ_FISCAL_CODE)),'x')),20) - 20,0,'OK','NO') = 'NO'
11415 or
11416   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,'OK','NO') = 'NO'
11417 or
11418 /*
11419   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11420 or
11421   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,'OK','NO') = 'NO'
11422 or
11423   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11424 or
11425 */
11426   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),50) - 50,0,'OK','NO') = 'NO'
11427 or
11428 /*
11429   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,'OK','NO') = 'NO'
11430 or
11431   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,'OK','NO') = 'NO'
11432 or
11433   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11434 or
11435 */
11436   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_TYPE)),'x')),50) - 50,0,'OK','NO') = 'NO'
11437 or
11438   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RURAL_ROUTE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11439 or
11440   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11441 or
11442   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BRANCH_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
11443 or
11444   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEAD_OF_HOUSEHOLD_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
11445 or
11446   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PUBLIC_PRIVATE_OWNERSHIP_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
11447 or
11448   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_LINE)),'x')),240) - 240,0,'OK','NO') = 'NO'
11449 or
11450   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(BUSINESS_SCOPE)),'x')),20) - 20,0,'OK','NO') = 'NO'
11451 or
11452   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CHIEF_EXECUTIVE_TITLE)),'x')),240) - 240,0,'OK','NO') = 'NO'
11453 or
11454   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
11455 or
11456   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
11457 or
11458   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
11459 or
11460   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
11461 or
11462   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
11463 or
11464   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
11465 or
11466   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
11467 or
11468   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
11469 or
11470   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
11471 or
11472   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
11473 or
11474   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_NAME)),'x')),240) - 240,0,'OK','NO') = 'NO'
11475 or
11476   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PRINCIPAL_TITLE)),'x')),240) - 240,0,'OK','NO') = 'NO'
11477 or
11478   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,'OK','NO') = 'NO'
11479 or
11480   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),360) - 360,0,'OK','NO') = 'NO'
11481 or
11482   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,'OK','NO') = 'NO'
11483 or
11484   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONGRESSIONAL_DISTRICT_CODE)),'x')),2) - 2,0,'OK','NO') = 'NO'
11485 or
11486   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CORPORATION_CLASS)),'x')),60) - 60,0,'OK','NO') = 'NO'
11487 or
11488   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
11489 or
11490   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
11491 or
11492   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
11493 or
11494   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PLACE_OF_BIRTH)),'x')),60) - 60,0,'OK','NO') = 'NO'
11495 or
11496   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_ID)),'x')),60) - 60,0,'OK','NO') = 'NO'
11497 or
11498   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11499 or
11500   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(WOMAN_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11501 or
11502   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11503 or
11504   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,'OK','NO') = 'NO'
11505 or
11506   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,'OK','NO') = 'NO'
11507 or
11508   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SMALL_BUSINESS_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11509 or
11510   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11511 or
11512   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MINORITY_OWNED_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11513 or
11514   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11515 or
11516   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(OUT_OF_BUSINESS_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11517 or
11518   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11519 or
11520   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LABOR_SURPLUS_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11521 or
11522   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11523 or
11524   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCAL_ACTIVITY_CODE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11525 or
11526   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(IMPORT_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11527 or
11528   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DISADVANTAGED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11529 or
11530   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DEPARTMENT_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11531 or
11532   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CREDIT_SCORE_COMMENTARY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11533 or
11534   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EXPORT_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11535 or
11536   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11537 or
11538   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_COMMENTARY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11539 or
11540   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAILURE_SCORE_OVERRIDE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11541 or
11542   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DB_RATING)),'x')),5) - 5,0,'OK','NO') = 'NO'
11543 or
11544   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(GLOBAL_FAILURE_SCORE)),'x')),5) - 5,0,'OK','NO') = 'NO'
11545 or
11546   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ENQUIRY_DUNS)),'x')),15) - 15,0,'OK','NO') = 'NO'
11547 or
11548   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11549 or
11550   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11551 or
11552   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
11553 or
11554   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
11555 or
11556   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
11557 or
11558   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
11559 or
11560   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
11561 or
11562   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
11563 or
11564   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
11565 or
11566   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
11567 or
11568   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
11569 or
11570   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
11571 or
11572   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
11573 or
11574   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
11575 or
11576   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
11577 or
11578   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
11579 or
11580   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORGANIZATION_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
11581 or
11582   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
11583 or
11584   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
11585 or
11586   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
11587 or
11588   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
11589 or
11590   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
11591 or
11592   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
11593 or
11594   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
11595 or
11596   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
11597 or
11598   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
11599 or
11600   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
11601 or
11602   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
11603 or
11604   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
11605 or
11606   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
11607 or
11608   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
11609 or
11610   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
11611 or
11612   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
11613 or
11614   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
11615 or
11616   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
11617 or
11618   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
11619 or
11620   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
11621 or
11622   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
11623 or
11624   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
11625 or
11626   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
11627 or
11628   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
11629 or
11630   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
11631 or
11632   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
11633 or
11634   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
11635 or
11636   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
11637 or
11638   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
11639 or
11640   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
11641 or
11642   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11643 or
11644   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORG_CONTACT_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11645 or
11646   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11647 or
11648   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
11649 or
11650   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
11651 or
11652   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,'OK','NO') = 'NO'
11653 or
11654 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(CONTROL_YEAR,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11655 or
11656 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(DEBARMENTS_COUNT,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11657 or
11658 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11659 or
11660 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11661 or
11662   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11663 or
11664   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11665 or
11666   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11667 or
11668   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,'OK','NO') = 'NO'
11669  );
11670 
11671 
11672 
11673 
11674 -- Cursor for B2C party type
11675 
11676 cursor b2c is
11677  SELECT
11678  IMPORT_SOURCE_LINE_ID,
11679  import_list_header_id,
11680  per_imp_xml_element_id,
11681  add_imp_xml_element_id,
11682  cp_imp_xml_element_id,
11683  em_imp_xml_element_id,
11684 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,' ','ADDRESS1 :'||l_invalid_size||'(240)') ADDRESS1,
11685 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,' ','ADDRESS2 :'||l_invalid_size||'(240)') ADDRESS2,
11686 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,' ','ADDRESS3 :'||l_invalid_size||'(240)') ADDRESS3,
11687 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,' ','ADDRESS4 :'||l_invalid_size||'(240)') ADDRESS4,
11688 DECODE(GREATEST(lengthb(LTRIM(RTRIM(PERSON_LAST_NAME))),50) - 50,0,' ','PERSON_LAST_NAME :'||decode(nvl(PERSON_LAST_NAME,'x'),'x',l_null_value,l_invalid_size)||'(50)') PERSON_LAST_NAME,
11689 DECODE(GREATEST(lengthb(LTRIM(RTRIM(PERSON_FIRST_NAME))),40) - 40,0,' ','PERSON_FIRST_NAME :'||decode(nvl(PERSON_FIRST_NAME,'x'),'x',l_null_value,l_invalid_size)||'(40)') PERSON_FIRST_NAME,
11690 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,' ','PERSON_NAME_PREFIX :'||l_invalid_size||'(30)') PERSON_NAME_PREFIX,
11691 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,' ','PERSON_MIDDLE_NAME :'||l_invalid_size||'(60)') PERSON_MIDDLE_NAME,
11692 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,' ','PERSON_NAME_SUFFIX :'||l_invalid_size||'(30)') PERSON_NAME_SUFFIX,
11693 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,' ','CITY :'||l_invalid_size||'(60)') CITY ,
11694 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALUTATION)),'x')),60) - 60,0,' ','SALUTATION :'||l_invalid_size||'(60)') SALUTATION,
11695 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,' ','POSTAL_CODE :'||l_invalid_size||'(60)') POSTAL_CODE,
11696 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,' ','STATE :'||l_invalid_size||'(60)') STATE,
11697 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,' ','PROVINCE :'||l_invalid_size||'(60)') PROVINCE,
11698 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,' ','COUNTY :'||l_invalid_size||'(60)') COUNTY,
11699 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,' ','COUNTRY :'||l_invalid_size||'(60)') COUNTRY,
11700 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,' ','EMAIL_ADDRESS :'||l_invalid_size||'(240)') EMAIL_ADDRESS,
11701 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,' ','PHONE_COUNTRY_CODE :'||l_invalid_size||'(30)') PHONE_COUNTRY_CODE,
11702 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,' ','PHONE_AREA_CODE :'||l_invalid_size||'(10)') PHONE_AREA_CODE,
11703 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,' ','PHONE_NUMBER :'||l_invalid_size||'(25)') PHONE_NUMBER,
11704 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,' ','PHONE_EXTENTION :'||l_invalid_size||'(20)') PHONE_EXTENTION,
11705 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,' ','identifying_address_flag :'||l_invalid_size||'(1)') identifying_address_flag,
11706 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,' ','ADDRESS_LINES_PHONETIC :'||l_invalid_size||'(560)') ADDRESS_LINES_PHONETIC,
11707 -- bug 4641591: columns obsolete
11708 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,' ','PO_BOX_NUMBER :'||l_invalid_size||'(50)') PO_BOX_NUMBER,
11709 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,' ','FLOOR :'||l_invalid_size||'(50)') FLOOR,
11710 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,' ','HOUSE_NUMBER :'||l_invalid_size||'(50)') HOUSE_NUMBER,
11711 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),10) - 10,0,' ','POSTAL_PLUS4_CODE :'||l_invalid_size||'(10)') POSTAL_PLUS4_CODE,
11712 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,' ','STREET_SUFFIX :'||l_invalid_size||'(50)') STREET_SUFFIX,
11713 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,' ','STREET :'||l_invalid_size||'(50)') STREET,
11714 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,' ','STREET_NUMBER :'||l_invalid_size||'(50)') STREET_NUMBER,
11715 -- DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SUITE)),'x')),50) - 50,0,' ','SUITE :'||l_invalid_size||'(50)') SUITE,
11716 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,' ','PARTY_ID :'||l_invalid_number) party_id,
11717 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URL)),'x')),2000) - 2000,0,' ','URL :'||l_invalid_size||'(2000)') URL,
11718 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,' ','DECLARED_ETHNICITY :'||l_invalid_size||'(60)') DECLARED_ETHNICITY,
11719 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION:'||l_invalid_size||'(2000)') DESCRIPTION,
11720 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HEAD_OF_HOUSEHOLD_FLAG)),'x')),1) - 1,0,' ','HEAD_OF_HOUSEHOLD_FLAG :'||l_invalid_size||'(1)') HEAD_OF_HOUSEHOLD_FLAG,
11721 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS :'||l_invalid_size||'(240)') PERSON_KNOWN_AS,
11722 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS2 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS2,
11723 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS3 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS3,
11724 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS4 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS4,
11725 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,' ','PERSON_KNOWN_AS5 :'||l_invalid_size||'(240)') PERSON_KNOWN_AS5,
11726 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,' ','LOCATION_DIRECTIONS:'||l_invalid_size||'(640)') LOCATION_DIRECTIONS,
11727 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,' ','MARITAL_STATUS :'||l_invalid_size||'(30)') MARITAL_STATUS,
11728 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,' ','PERSON_ACADEMIC_TITLE :'||l_invalid_size||'(30)') PERSON_ACADEMIC_TITLE,
11729 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_FIRST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_FIRST_NAME_PHONETIC,
11730 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,' ','PERSON_LAST_NAME_PHONETIC :'||l_invalid_size||'(60)') PERSON_LAST_NAME_PHONETIC,
11731 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,' ','MIDDLE_NAME_PHONETIC :'||l_invalid_size||'(60)') MIDDLE_NAME_PHONETIC,
11732 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),320) - 320,0,' ','PERSON_NAME_PHONETIC :'||l_invalid_size||'(320)') PERSON_NAME_PHONETIC,
11733 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,' ','PERSON_PREVIOUS_TITLE_NAME :'||l_invalid_size||'(150)') PERSON_PREVIOUS_TITLE_NAME,
11734 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,
11735 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE1)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE1 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE1,
11736 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE2)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE2 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE2,
11737 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE3)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE3 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE3,
11738 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE4)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE4 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE4,
11739 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE5)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE5 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE5,
11740 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE6)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE6 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE6,
11741 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE7)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE7 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE7,
11742 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE8)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE8 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE8,
11743 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE9)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE9 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE9,
11744 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE10)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE10 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE10,
11745 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE11)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE11 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE11,
11746 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE12)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE12 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE12,
11747 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE13)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE13 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE13,
11748 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE14)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE14 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE14,
11749 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE15)),'x')),150) - 150,0,' ','PERSON_ATTRIBUTE15 :'||l_invalid_size||'(150)') PERSON_ATTRIBUTE15,
11750 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE1 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE1,
11751 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE2 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE2,
11752 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE3 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE3,
11753 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE4 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE4,
11754 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE5 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE5,
11755 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE6 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE6,
11756 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE7 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE7,
11757 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE8 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE8,
11758 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE9 : '||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE9,
11759 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE10 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE10,
11760 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE11 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE11,
11761 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE12 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE12,
11762 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE13 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE13,
11763 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE14 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE14,
11764 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,' ','ADDRESS_ATTRIBUTE15 :'||l_invalid_size||'(150)') ADDRESS_ATTRIBUTE15,
11765 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,' ','FAX_COUNTRY_CODE :'||l_invalid_size||'(10)') FAX_COUNTRY_CODE,
11766 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,' ','FAX_AREA_CODE :'||l_invalid_size||'(10)') FAX_AREA_CODE,
11767 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,' ','FAX_NUMBER :'||l_invalid_size||'(40)') FAX_NUMBER,
11768 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','ADDRESS_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') ADDRESS_ATTRIBUTE_CATEGORY,
11769 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,' ','PERSON_ATTRIBUTE_CATEGORY :'||l_invalid_size||'(30)') PERSON_ATTRIBUTE_CATEGORY,
11770 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,' ','HOUSEHOLD_SIZE :'||l_invalid_number) HOUSEHOLD_SIZE,
11771 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','PERSONAL_INCOME :'||l_invalid_number) PERSONAL_INCOME,
11772 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,' ','DESCRIPTION:'||l_invalid_size||'(2000)') DESCRIPTION,
11773 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,' ','SHORT_DESCRIPTION :'||l_invalid_size||'(240)') SHORT_DESCRIPTION,
11774 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,' ','NOTES :'||l_invalid_size||'(2000)') NOTES,
11775 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,' ','VEHICLE_RESPONSE_CODE :'||l_invalid_size||'(30)') VEHICLE_RESPONSE_CODE,
11776 DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,' ','SALES_AGENT_EMAIL_ADDRESS:'||l_invalid_size||'(2000)') SALES_AGENT_EMAIL_ADDRESS,
11777 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) -240,0,' ','ORIG_SYSTEM_REFERENCE :'||l_invalid_size
11778 ||'(240)') ORIG_SYSTEM_REFERENCE,
11779 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),60) - 60,0,' ','TAX_REFERENCE :'||l_invalid_size||'(60)') TAX_REFERENCE,
11780 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,' ','RENT_OWNED_INDICATOR :'||l_invalid_size||'(30)') RENT_OWNED_INDICATOR
11781  FROM AMS_HZ_B2C_MAPPING_V
11782  WHERE IMPORT_LIST_HEADER_ID =  p_import_list_header_id
11783   and load_status = 'ERROR'
11784    AND
11785  (
11786 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(party_id,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11787 or
11788   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
11789 or
11790   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
11791 or
11792   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
11793 or
11794   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
11795 or
11796   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME)),'x')),50) - 50,0,'OK','NO') = 'NO'
11797 or
11798   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME)),'x')),40) - 40,0,'OK','NO') = 'NO'
11799 or
11800   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PREFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
11801 or
11802   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_MIDDLE_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
11803 or
11804   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
11805 or
11806   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11807 or
11808   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11809 or
11810   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11811 or
11812   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SALUTATION)),'x')),60) - 60,0,'OK','NO') = 'NO'
11813 or
11814   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11815 or
11816   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11817 or
11818   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11819 or
11820   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
11821 or
11822   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_COUNTRY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11823 or
11824   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
11825 or
11826   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
11827 or
11828   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PHONE_EXTENTION)),'x')),20) - 20,0,'OK','NO') = 'NO'
11829 or
11830   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(identifying_address_flag)),'x')),1) - 1,0,'OK','NO') = 'NO'
11831 or
11832   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_LINES_PHONETIC)),'x')),560) - 560,0,'OK','NO') = 'NO'
11833 or
11834 /*
11835   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PO_BOX_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11836 or
11837   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FLOOR)),'x')),50) - 50,0,'OK','NO') = 'NO'
11838 or
11839   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(HOUSE_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11840 or
11841 */
11842   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(POSTAL_PLUS4_CODE)),'x')),50) - 50,0,'OK','NO') = 'NO'
11843 or
11844 /*
11845   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_SUFFIX)),'x')),50) - 50,0,'OK','NO') = 'NO'
11846 or
11847   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET)),'x')),50) - 50,0,'OK','NO') = 'NO'
11848 or
11849   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(STREET_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
11850 or
11851 */
11852   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11853 or
11854   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS)),'x')),240) - 240,0,'OK','NO') = 'NO'
11855 or
11856   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
11857 or
11858   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
11859 or
11860   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
11861 or
11862   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_KNOWN_AS5)),'x')),240) - 240,0,'OK','NO') = 'NO'
11863 or
11864   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(SHORT_DESCRIPTION)),'x')),240) - 240,0,'OK','NO') = 'NO'
11865 or
11866   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_NAME_PHONETIC)),'x')),360) - 360,0,'OK','NO') = 'NO'
11867 or
11868   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(LOCATION_DIRECTIONS)),'x')),640) - 640,0,'OK','NO') = 'NO'
11869 or
11870   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_FIRST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
11871 or
11872   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_LAST_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
11873 or
11874   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MIDDLE_NAME_PHONETIC)),'x')),60) - 60,0,'OK','NO') = 'NO'
11875 or
11876   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PLACE_OF_BIRTH)),'x')),60) - 60,0,'OK','NO') = 'NO'
11877 or
11878   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_PREVIOUS_TITLE_NAME)),'x')),150) - 150,0,'OK','NO') = 'NO'
11879 or
11880   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(MARITAL_STATUS)),'x')),30) - 30,0,'OK','NO') = 'NO'
11881 or
11882   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ACADEMIC_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11883 or
11884   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DECLARED_ETHNICITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
11885 or
11886   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(DESCRIPTION)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11887 or
11888   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
11889 or
11890   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
11891 or
11892   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
11893 or
11894   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
11895 or
11896   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
11897 or
11898   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
11899 or
11900   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
11901 or
11902   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
11903 or
11904   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
11905 or
11906   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
11907 or
11908   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
11909 or
11910   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
11911 or
11912   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
11913 or
11914   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
11915 or
11916   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
11917 or
11918   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE1)),'x')),150) - 150,0,'OK','NO') = 'NO'
11919 or
11920   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE2)),'x')),150) - 150,0,'OK','NO') = 'NO'
11921 or
11922   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE3)),'x')),150) - 150,0,'OK','NO') = 'NO'
11923 or
11924   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE4)),'x')),150) - 150,0,'OK','NO') = 'NO'
11925 or
11926   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE5)),'x')),150) - 150,0,'OK','NO') = 'NO'
11927 or
11928   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE6)),'x')),150) - 150,0,'OK','NO') = 'NO'
11929 or
11930   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE7)),'x')),150) - 150,0,'OK','NO') = 'NO'
11931 or
11932   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE8)),'x')),150) - 150,0,'OK','NO') = 'NO'
11933 or
11934   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE9)),'x')),150) - 150,0,'OK','NO') = 'NO'
11935 or
11936   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE10)),'x')),150) - 150,0,'OK','NO') = 'NO'
11937 or
11938   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE11)),'x')),150) - 150,0,'OK','NO') = 'NO'
11939 or
11940   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE12)),'x')),150) - 150,0,'OK','NO') = 'NO'
11941 or
11942   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE13)),'x')),150) - 150,0,'OK','NO') = 'NO'
11943 or
11944   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE14)),'x')),150) - 150,0,'OK','NO') = 'NO'
11945 or
11946   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE15)),'x')),150) - 150,0,'OK','NO') = 'NO'
11947 or
11948   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(PERSON_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11949 or
11950   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ADDRESS_ATTRIBUTE_CATEGORY)),'x')),30) - 30,0,'OK','NO') = 'NO'
11951 or
11952   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_COUNTRY_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
11953 or
11954   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
11955 or
11956   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(FAX_NUMBER)),'x')),40) - 40,0,'OK','NO') = 'NO'
11957 or
11958 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(HOUSEHOLD_SIZE,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11959 or
11960 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(PERSONAL_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
11961 or
11962   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(NOTES)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11963 or
11964   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(VEHICLE_RESPONSE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
11965 or
11966   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(SALES_AGENT_EMAIL_ADDRESS)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
11967 or
11968   DECODE(GREATEST(LENGTH(nvl(LTRIM(RTRIM(ORIG_SYSTEM_REFERENCE)),'x')),240) - 240,0,'OK','NO') = 'NO'
11969 or
11970   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(TAX_REFERENCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
11971 or
11972   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(RENT_OWNED_INDICATOR)),'x')),30) - 30,0,'OK','NO') = 'NO'
11973  );
11974 
11975 
11976 -- Cursor to check if it's B2B or B2C party type.
11977 
11978 cursor b2borb2c is
11979           select import_type  from ams_imp_list_headers_all
11980           where  import_list_header_id = p_import_list_header_id;
11981 
11982 
11983 begin
11984 
11985         IF p_import_list_header_id IS NULL THEN
11986                 RAISE FND_API.G_EXC_ERROR;
11987         END IF;
11988     p_return_status := FND_API.G_RET_STS_SUCCESS;
11989 
11990     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_DATATYPE_ERROR_CHK');
11991     l_invalid_number := FND_MESSAGE.get;
11992     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_SIZE_ERROR_CHK');
11993     l_invalid_size := FND_MESSAGE.get;
11994     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_NULL_ERROR_CHK');
11995     l_null_value := FND_MESSAGE.get;
11996 
11997         OPEN b2borb2c;
11998         FETCH b2borb2c into x_b2b;
11999         close b2borb2c;
12000     OPEN c_lead_batch_id;
12001     FETCH c_lead_batch_id into l_batch_id;
12002     CLOSE c_lead_batch_id;
12003 
12004     if x_b2b = 'B2B' then
12005     	OPEN b2b;
12006      LOOP
12007       FETCH b2b  INTO
12008         l_import_source_line_id,
12009         l_import_list_header_id,
12010         l_cust_b2b_rec.org_imp_xml_element_id,
12011 	l_cust_b2b_rec.add_imp_xml_element_id,
12012 	l_cust_b2b_rec.ocont_imp_xml_element_id,
12013 	l_cust_b2b_rec.cp_imp_xml_element_id,
12014 	l_cust_b2b_rec.em_imp_xml_element_id,
12015 	l_cust_b2b_rec.PARTY_NAME,
12016 	l_cust_b2b_rec.FISCAL_YEAREND_MONTH,
12017 	l_cust_b2b_rec.DUNS_NUMBER,
12018 	l_cust_b2b_rec.EMPLOYEES_TOTAL,
12019 	l_cust_b2b_rec.LINE_OF_BUSINESS,
12020 	l_cust_b2b_rec.ADDRESS1,
12021 	l_cust_b2b_rec.ADDRESS2,
12022 	l_cust_b2b_rec.ADDRESS3,
12023 	l_cust_b2b_rec.ADDRESS4,
12024 	l_cust_b2b_rec.YEAR_ESTABLISHED,
12025 	l_cust_b2b_rec.TAX_REFERENCE,
12026 	l_cust_b2b_rec.CEO_NAME,
12027 	l_cust_b2b_rec.PERSON_LAST_NAME,
12028 	l_cust_b2b_rec.PERSON_FIRST_NAME,
12029 	l_cust_b2b_rec.PERSON_NAME_PREFIX,
12030 	l_cust_b2b_rec.JOB_TITLE,
12031 	l_cust_b2b_rec.PERSON_MIDDLE_NAME,
12032 	l_cust_b2b_rec.PERSON_NAME_SUFFIX,
12033 	l_cust_b2b_rec.CITY,
12034 	l_cust_b2b_rec.POSTAL_CODE,
12035 	l_cust_b2b_rec.STATE,
12036 	l_cust_b2b_rec.PROVINCE,
12037 	l_cust_b2b_rec.COUNTY,
12038 	l_cust_b2b_rec.COUNTRY,
12039 	l_cust_b2b_rec.EMAIL_ADDRESS,
12040 	l_cust_b2b_rec.PHONE_COUNTRY_CODE,
12041 	l_cust_b2b_rec.PHONE_AREA_CODE,
12042 	l_cust_b2b_rec.PHONE_NUMBER,
12043 	l_cust_b2b_rec.PHONE_EXTENSION,
12044 	l_cust_b2b_rec.DEPARTMENT,
12045 	l_cust_b2b_rec.DECISION_MAKER_FLAG,
12046 	l_cust_b2b_rec.SIC_CODE,
12047 	l_cust_b2b_rec.SIC_CODE_TYPE,
12048 	l_cust_b2b_rec.ANALYSIS_FY,
12049 	l_cust_b2b_rec.CURR_FY_POTENTIAL_REVENUE,
12050 	l_cust_b2b_rec.NEXT_FY_POTENTIAL_REVENUE,
12051 	l_cust_b2b_rec.GSA_INDICATOR_FLAG,
12052 	l_cust_b2b_rec.identifying_address_flag,
12053 	l_cust_b2b_rec.MISSION_STATEMENT,
12054 	l_cust_b2b_rec.ORGANIZATION_NAME_PHONETIC,
12055 	l_cust_b2b_rec.CATEGORY_CODE,
12056 	l_cust_b2b_rec.JGZZ_FISCAL_CODE,
12057 	l_cust_b2b_rec.ADDRESS_LINES_PHONETIC,
12058 -- bug 4641591: columns obsolete
12059 --	l_cust_b2b_rec.PO_BOX_NUMBER,
12060 --	l_cust_b2b_rec.FLOOR,
12061 --	l_cust_b2b_rec.HOUSE_NUMBER,
12062 	l_cust_b2b_rec.POSTAL_PLUS4_CODE,
12063 --	l_cust_b2b_rec.STREET_SUFFIX,
12064 --	l_cust_b2b_rec.STREET,
12065 --	l_cust_b2b_rec.STREET_NUMBER,
12066 --	l_cust_b2b_rec.SUITE,
12067 	l_cust_b2b_rec.party_id,
12068 	l_cust_b2b_rec.ORGANIZATION_URL,
12069 	l_cust_b2b_rec.BRANCH_FLAG,
12070 	l_cust_b2b_rec.BUSINESS_LINE,
12071 	l_cust_b2b_rec.BUSINESS_SCOPE,
12072 	l_cust_b2b_rec.CHIEF_EXECUTIVE_TITLE,
12073 	l_cust_b2b_rec.CONGRESSIONAL_DISTRICT_CODE,
12074 	l_cust_b2b_rec.CORPORATION_CLASS,
12075 	l_cust_b2b_rec.CREDIT_SCORE,
12076 	l_cust_b2b_rec.CREDIT_SCORE_COMMENTARY,
12077 	l_cust_b2b_rec.DB_RATING,
12078 	l_cust_b2b_rec.DECLARED_ETHNICITY,
12079 	l_cust_b2b_rec.DEPARTMENT_INDICATOR,
12080 	l_cust_b2b_rec.DESCRIPTION,
12081 	l_cust_b2b_rec.DISADVANTAGED_INDICATOR,
12082 	l_cust_b2b_rec.ENQUIRY_DUNS,
12083 	l_cust_b2b_rec.EXPORT_INDICATOR,
12084 	l_cust_b2b_rec.FAILURE_SCORE,
12085 	l_cust_b2b_rec.FAILURE_SCORE_COMMENTARY,
12086 	l_cust_b2b_rec.FAILURE_SCORE_OVERRIDE_CODE,
12087 	l_cust_b2b_rec.GLOBAL_FAILURE_SCORE,
12088 	l_cust_b2b_rec.HEADQUARTER_BRANCH_INDICATOR,
12089 	l_cust_b2b_rec.HEAD_OF_HOUSEHOLD_FLAG,
12090 	l_cust_b2b_rec.IMPORT_INDICATOR,
12091 	l_cust_b2b_rec.ORGANIZATION_KNOWN_AS,
12092 	l_cust_b2b_rec.ORGANIZATION_KNOWN_AS2,
12093 	l_cust_b2b_rec.ORGANIZATION_KNOWN_AS3,
12094 	l_cust_b2b_rec.ORGANIZATION_KNOWN_AS4,
12095 	l_cust_b2b_rec.ORGANIZATION_KNOWN_AS5,
12096 	l_cust_b2b_rec.PERSON_KNOWN_AS,
12097 	l_cust_b2b_rec.PERSON_KNOWN_AS2,
12098 	l_cust_b2b_rec.PERSON_KNOWN_AS3,
12099 	l_cust_b2b_rec.PERSON_KNOWN_AS4,
12100 	l_cust_b2b_rec.PERSON_KNOWN_AS5,
12101 	l_cust_b2b_rec.LABOR_SURPLUS_INDICATOR,
12102 	l_cust_b2b_rec.LOCAL_ACTIVITY_CODE,
12103 	l_cust_b2b_rec.LOCAL_ACTIVITY_CODE_TYPE,
12104 	l_cust_b2b_rec.LOCATION_DIRECTIONS,
12105 	l_cust_b2b_rec.MARITAL_STATUS,
12106 	l_cust_b2b_rec.MINORITY_OWNED_INDICATOR,
12107 	l_cust_b2b_rec.MINORITY_OWNED_TYPE,
12108 	l_cust_b2b_rec.ORGANIZATION_TYPE,
12109 	l_cust_b2b_rec.OUT_OF_BUSINESS_INDICATOR,
12110 	l_cust_b2b_rec.PERSON_ACADEMIC_TITLE,
12111 	l_cust_b2b_rec.PERSON_FIRST_NAME_PHONETIC,
12112 	l_cust_b2b_rec.PERSON_LAST_NAME_PHONETIC,
12113 	l_cust_b2b_rec.MIDDLE_NAME_PHONETIC,
12114 	l_cust_b2b_rec.PERSON_NAME_PHONETIC,
12115 	l_cust_b2b_rec.PERSON_PREVIOUS_TITLE_NAME,
12116 	l_cust_b2b_rec.PLACE_OF_BIRTH,
12117 	l_cust_b2b_rec.PRINCIPAL_NAME,
12118 	l_cust_b2b_rec.PRINCIPAL_TITLE,
12119 	l_cust_b2b_rec.PUBLIC_PRIVATE_OWNERSHIP_FLAG,
12120 	l_cust_b2b_rec.RENT_OWNED_INDICATOR,
12121 	-- l_cust_b2b_rec.SECOND_TITLE,
12122 	l_cust_b2b_rec.SHORT_DESCRIPTION,
12123 	l_cust_b2b_rec.SMALL_BUSINESS_INDICATOR,
12124 	l_cust_b2b_rec.TAX_ID,
12125 	l_cust_b2b_rec.WOMAN_OWNED_INDICATOR,
12126 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE1,
12127 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE2,
12128 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE3,
12129 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE4,
12130 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE5,
12131 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE6,
12132 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE7,
12133 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE8,
12134 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE9,
12135 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE10,
12136 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE11,
12137 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE12,
12138 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE13,
12139 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE14,
12140 	l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE15,
12141 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE1,
12142 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE2,
12143 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE3,
12144 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE4,
12145 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE5,
12146 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE6,
12147 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE7,
12148 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE8,
12149 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE9,
12150 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE10,
12151 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE11,
12152 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE12,
12153 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE13,
12154 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE14,
12155 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE15,
12156 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE1,
12157 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE2,
12158 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE3,
12159 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE4,
12160 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE5,
12161 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE6,
12162 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE7,
12163 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE8,
12164 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE9,
12165 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE10,
12166 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE11,
12167 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE12,
12168 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE13,
12169 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE14,
12170 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE15,
12171 	l_cust_b2b_rec.FAX_COUNTRY_CODE,
12172 	l_cust_b2b_rec.FAX_AREA_CODE,
12173 	l_cust_b2b_rec.FAX_NUMBER,
12174 	l_cust_b2b_rec.ORG_ATTRIBUTE_CATEGORY,
12175 	-- l_cust_b2b_rec.PERSON_ATTRIBUTE_CATEGORY,
12176 	l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE_CATEGORY,
12177 	l_cust_b2b_rec.ADDRESS_ATTRIBUTE_CATEGORY,
12178 	l_cust_b2b_rec.CONTROL_YEAR,
12179 	l_cust_b2b_rec.DEBARMENTS_COUNT,
12180 	l_cust_b2b_rec.HOUSEHOLD_SIZE,
12181 	l_cust_b2b_rec.PERSONAL_INCOME,
12182 	l_cust_b2b_rec.NOTES,
12183 	l_cust_b2b_rec.VEHICLE_RESPONSE_CODE,
12184 	l_cust_b2b_rec.SALES_AGENT_EMAIL_ID,
12185 	l_cust_b2b_rec.orig_system_reference;
12186 
12187 
12188       EXIT WHEN b2b%NOTFOUND;
12189 
12190        if trim(l_cust_b2b_rec.PARTY_NAME) is not null then
12191  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12192 			       'PARTY_NAME', l_cust_b2b_rec.PARTY_NAME);
12193        end if;
12194 
12195        if trim(l_cust_b2b_rec.FISCAL_YEAREND_MONTH) is not null then
12196  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12197 			       'FISCAL_YEAREND_MONTH', l_cust_b2b_rec.FISCAL_YEAREND_MONTH);
12198        end if;
12199        if trim(l_cust_b2b_rec.DUNS_NUMBER) is not null then
12200  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12201 			       'DUNS_NUMBER', l_cust_b2b_rec.DUNS_NUMBER);
12202        end if;
12203        if trim(l_cust_b2b_rec.EMPLOYEES_TOTAL) is not null then
12204  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12205 			       'EMPLOYEES_TOTAL', l_cust_b2b_rec.EMPLOYEES_TOTAL);
12206        end if;
12207        if trim(l_cust_b2b_rec.LINE_OF_BUSINESS) is not null then
12208  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12209 			       'LINE_OF_BUSINESS', l_cust_b2b_rec.LINE_OF_BUSINESS);
12210        end if;
12211        if trim(l_cust_b2b_rec.ORIG_SYSTEM_REFERENCE) is not null then
12212  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12213 			       'ORIG_SYSTEM_REFERENCE', l_cust_b2b_rec.ORIG_SYSTEM_REFERENCE);
12214        end if;
12215        if trim(l_cust_b2b_rec.ADDRESS1) is not null then
12216  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12217 			       'ADDRESS1', l_cust_b2b_rec.ADDRESS1);
12218        end if;
12219        if trim(l_cust_b2b_rec.ADDRESS2) is not null then
12220  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12221 			       'ADDRESS2', l_cust_b2b_rec.ADDRESS2);
12222        end if;
12223        if trim(l_cust_b2b_rec.ADDRESS3) is not null then
12224  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12225 			       'ADDRESS3', l_cust_b2b_rec.ADDRESS3);
12226        end if;
12227        if trim(l_cust_b2b_rec.ADDRESS4) is not null then
12228  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12229 			       'ADDRESS4', l_cust_b2b_rec.ADDRESS4);
12230        end if;
12231        if trim(l_cust_b2b_rec.YEAR_ESTABLISHED) is not null then
12232  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12233 			       'YEAR_ESTABLISHED', l_cust_b2b_rec.YEAR_ESTABLISHED);
12234        end if;
12235        if trim(l_cust_b2b_rec.TAX_REFERENCE) is not null then
12236  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12237 			       'TAX_REFERENCE', l_cust_b2b_rec.TAX_REFERENCE);
12238        end if;
12239        if trim(l_cust_b2b_rec.CEO_NAME) is not null then
12240  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12241 			       'CEO_NAME', l_cust_b2b_rec.CEO_NAME);
12242        end if;
12243 
12244        if trim(l_cust_b2b_rec.PERSON_LAST_NAME) is not null then
12245  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12246 			       'PERSON_LAST_NAME', l_cust_b2b_rec.PERSON_LAST_NAME);
12247        end if;
12248        if trim(l_cust_b2b_rec.PERSON_FIRST_NAME) is not null then
12249  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12250 			       'PERSON_FIRST_NAME', l_cust_b2b_rec.PERSON_FIRST_NAME);
12251        end if;
12252        if trim(l_cust_b2b_rec.PERSON_NAME_PREFIX) is not null then
12253  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12254 			       'PERSON_NAME_PREFIX', l_cust_b2b_rec.PERSON_NAME_PREFIX);
12255        end if;
12256        if trim(l_cust_b2b_rec.JOB_TITLE) is not null then
12257  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12258 			       'JOB_TITLE', l_cust_b2b_rec.JOB_TITLE);
12259        end if;
12260        if trim(l_cust_b2b_rec.PERSON_MIDDLE_NAME) is not null then
12261  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12262 			       'PERSON_MIDDLE_NAME', l_cust_b2b_rec.PERSON_MIDDLE_NAME);
12263        end if;
12264        if trim(l_cust_b2b_rec.PERSON_NAME_SUFFIX) is not null then
12265  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12266 			       'PERSON_NAME_SUFFIX', l_cust_b2b_rec.PERSON_NAME_SUFFIX);
12267        end if;
12268        if trim(l_cust_b2b_rec.CITY) is not null then
12269  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12270 			       'CITY', l_cust_b2b_rec.CITY);
12271        end if;
12272        if trim(l_cust_b2b_rec.POSTAL_CODE) is not null then
12273  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12274 			       'POSTAL_CODE', l_cust_b2b_rec.POSTAL_CODE);
12275        end if;
12276        if trim(l_cust_b2b_rec.STATE) is not null then
12277  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12278 			       'STATE', l_cust_b2b_rec.STATE);
12279        end if;
12280        if trim(l_cust_b2b_rec.PROVINCE) is not null then
12281  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12282 			       'PROVINCE', l_cust_b2b_rec.PROVINCE);
12283        end if;
12284        if trim(l_cust_b2b_rec.COUNTY) is not null then
12285  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12286 			       'COUNTY', l_cust_b2b_rec.COUNTY);
12287        end if;
12288 
12289        if trim(l_cust_b2b_rec.COUNTRY) is not null then
12290  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12291 			       'COUNTRY', l_cust_b2b_rec.COUNTRY);
12292        end if;
12293        if trim(l_cust_b2b_rec.EMAIL_ADDRESS) is not null then
12294  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.em_imp_xml_element_id,
12295 			       'EMAIL_ADDRESS', l_cust_b2b_rec.EMAIL_ADDRESS);
12296        end if;
12297        if trim(l_cust_b2b_rec.PHONE_COUNTRY_CODE) is not null then
12298  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.cp_imp_xml_element_id,
12299 			       'PHONE_COUNTRY_CODE', l_cust_b2b_rec.PHONE_COUNTRY_CODE);
12300        end if;
12301        if trim(l_cust_b2b_rec.PHONE_AREA_CODE) is not null then
12302  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.cp_imp_xml_element_id,
12303 			       'PHONE_AREA_CODE', l_cust_b2b_rec.PHONE_AREA_CODE);
12304        end if;
12305        if trim(l_cust_b2b_rec.PHONE_NUMBER) is not null then
12306  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.cp_imp_xml_element_id,
12307 			       'PHONE_NUMBER', l_cust_b2b_rec.PHONE_NUMBER);
12308        end if;
12309        if trim(l_cust_b2b_rec.PHONE_EXTENSION) is not null then
12310  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.cp_imp_xml_element_id,
12311 			       'PHONE_EXTENSION', l_cust_b2b_rec.PHONE_EXTENSION);
12312        end if;
12313        if trim(l_cust_b2b_rec.DEPARTMENT) is not null then
12314  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12315 			       'DEPARTMENT', l_cust_b2b_rec.DEPARTMENT);
12316        end if;
12317        if trim(l_cust_b2b_rec.DECISION_MAKER_FLAG) is not null then
12318  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12319 			       'DECISION_MAKER_FLAG', l_cust_b2b_rec.DECISION_MAKER_FLAG);
12320        end if;
12321        if trim(l_cust_b2b_rec.SIC_CODE) is not null then
12322  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12323 			       'SIC_CODE', l_cust_b2b_rec.SIC_CODE);
12324        end if;
12325        if trim(l_cust_b2b_rec.SIC_CODE_TYPE) is not null then
12326  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12327 			       'SIC_CODE_TYPE', l_cust_b2b_rec.SIC_CODE_TYPE);
12328        end if;
12329        if trim(l_cust_b2b_rec.ANALYSIS_FY) is not null then
12330  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12331 			       'ANALYSIS_FY', l_cust_b2b_rec.ANALYSIS_FY);
12332        end if;
12333 
12334        if trim(l_cust_b2b_rec.CURR_FY_POTENTIAL_REVENUE) is not null then
12335  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12336 			       'CURR_FY_POTENTIAL_REVENUE', l_cust_b2b_rec.CURR_FY_POTENTIAL_REVENUE);
12337        end if;
12338        if trim(l_cust_b2b_rec.NEXT_FY_POTENTIAL_REVENUE) is not null then
12339  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12340 			       'NEXT_FY_POTENTIAL_REVENUE', l_cust_b2b_rec.NEXT_FY_POTENTIAL_REVENUE);
12341        end if;
12342        if trim(l_cust_b2b_rec.GSA_INDICATOR_FLAG) is not null then
12343  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12344 			       'GSA_INDICATOR_FLAG', l_cust_b2b_rec.GSA_INDICATOR_FLAG);
12345        end if;
12346        if trim(l_cust_b2b_rec.identifying_address_flag) is not null then
12347  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12348 			       'IDENTIFYING_ADDRESS_FLAG', l_cust_b2b_rec.IDENTIFYING_ADDRESS_FLAG);
12349        end if;
12350        if trim(l_cust_b2b_rec.MISSION_STATEMENT) is not null then
12351  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12352 			       'MISSION_STATEMENT', l_cust_b2b_rec.MISSION_STATEMENT);
12353        end if;
12354        if trim(l_cust_b2b_rec.ORGANIZATION_NAME_PHONETIC) is not null then
12355  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12356 			       'ORGANIZATION_NAME_PHONETIC', l_cust_b2b_rec.ORGANIZATION_NAME_PHONETIC);
12357        end if;
12358        if trim(l_cust_b2b_rec.CATEGORY_CODE) is not null then
12359  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12360 			       'CATEGORY_CODE', l_cust_b2b_rec.CATEGORY_CODE);
12361        end if;
12362        if trim(l_cust_b2b_rec.JGZZ_FISCAL_CODE) is not null then
12363  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12364 			       'JGZZ_FISCAL_CODE', l_cust_b2b_rec.JGZZ_FISCAL_CODE);
12365        end if;
12366        if trim(l_cust_b2b_rec.ADDRESS_LINES_PHONETIC) is not null then
12367  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12368 			       'ADDRESS_LINES_PHONETIC', l_cust_b2b_rec.ADDRESS_LINES_PHONETIC);
12369        end if;
12370 /* -- bug 4641591: columns obsolete
12371        if trim(l_cust_b2b_rec.PO_BOX_NUMBER) is not null then
12372  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12373 			       'PO_BOX_NUMBER', l_cust_b2b_rec.PO_BOX_NUMBER);
12374        end if;
12375        if trim(l_cust_b2b_rec.FLOOR) is not null then
12376  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12377 			       'FLOOR', l_cust_b2b_rec.FLOOR);
12378        end if;
12379 
12380        if trim(l_cust_b2b_rec.HOUSE_NUMBER) is not null then
12381  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12382 			       'HOUSE_NUMBER', l_cust_b2b_rec.HOUSE_NUMBER);
12383        end if;
12384 */
12385        if trim(l_cust_b2b_rec.POSTAL_PLUS4_CODE) is not null then
12386  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12387 			       'POSTAL_PLUS4_CODE', l_cust_b2b_rec.POSTAL_PLUS4_CODE);
12388        end if;
12389 /* -- bug 4641591: columns obsolete
12390        if trim(l_cust_b2b_rec.STREET_SUFFIX) is not null then
12391  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12392 			       'STREET_SUFFIX', l_cust_b2b_rec.STREET_SUFFIX);
12393        end if;
12394        if trim(l_cust_b2b_rec.STREET) is not null then
12395  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12396 			       'STREET', l_cust_b2b_rec.STREET);
12397        end if;
12398        if trim(l_cust_b2b_rec.STREET_NUMBER) is not null then
12399  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12400 			       'STREET_NUMBER', l_cust_b2b_rec.STREET_NUMBER);
12401        end if;
12402        if trim(l_cust_b2b_rec.SUITE) is not null then
12403  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12404 			       'SUITE', l_cust_b2b_rec.SUITE);
12405        end if;
12406 */
12407        if trim(l_cust_b2b_rec.party_id) is not null then
12408  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12409 			       'PARTY_ID', l_cust_b2b_rec.PARTY_ID);
12410        end if;
12411 
12412     -- **********************************
12413        if trim(l_cust_b2b_rec.ORGANIZATION_URL) is not null then
12414  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12415 			       'ORGANIZATION_URL', l_cust_b2b_rec.ORGANIZATION_URL);
12416        end if;
12417        if trim(l_cust_b2b_rec.BRANCH_FLAG) is not null then
12418  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12419 			       'BRANCH_FLAG', l_cust_b2b_rec.BRANCH_FLAG);
12420        end if;
12421        if trim(l_cust_b2b_rec.BUSINESS_LINE) is not null then
12422  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12423 			       'BUSINESS_LINE', l_cust_b2b_rec.BUSINESS_LINE);
12424        end if;
12425        if trim(l_cust_b2b_rec.BUSINESS_SCOPE) is not null then
12426  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12427 			       'BUSINESS_SCOPE', l_cust_b2b_rec.BUSINESS_SCOPE);
12428        end if;
12429        if trim(l_cust_b2b_rec.CHIEF_EXECUTIVE_TITLE) is not null then
12430  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12431 			       'CHIEF_EXECUTIVE_TITLE', l_cust_b2b_rec.CHIEF_EXECUTIVE_TITLE);
12432        end if;
12433        if trim(l_cust_b2b_rec.CONGRESSIONAL_DISTRICT_CODE) is not null then
12434  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12435 			       'CONGRESSIONAL_DISTRICT_CODE', l_cust_b2b_rec.CONGRESSIONAL_DISTRICT_CODE);
12436        end if;
12437        if trim(l_cust_b2b_rec.CORPORATION_CLASS) is not null then
12438  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12439 			       'CORPORATION_CLASS', l_cust_b2b_rec.CORPORATION_CLASS);
12440        end if;
12441        if trim(l_cust_b2b_rec.CREDIT_SCORE) is not null then
12442  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12443 			       'CREDIT_SCORE', l_cust_b2b_rec.CREDIT_SCORE);
12444        end if;
12445        if trim(l_cust_b2b_rec.CREDIT_SCORE_COMMENTARY) is not null then
12446  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12447 			       'CREDIT_SCORE_COMMENTARY', l_cust_b2b_rec.CREDIT_SCORE_COMMENTARY);
12448        end if;
12449        if trim(l_cust_b2b_rec.DB_RATING) is not null then
12450  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12451 			       'DB_RATING', l_cust_b2b_rec.DB_RATING);
12452        end if;
12453        if trim(l_cust_b2b_rec.DECLARED_ETHNICITY) is not null then
12454  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12455 			       'DECLARED_ETHNICITY', l_cust_b2b_rec.DECLARED_ETHNICITY);
12456        end if;
12457        if trim(l_cust_b2b_rec.DEPARTMENT_INDICATOR) is not null then
12458  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12459 			       'DEPARTMENT_INDICATOR', l_cust_b2b_rec.DEPARTMENT_INDICATOR);
12460        end if;
12461        if trim(l_cust_b2b_rec.DESCRIPTION) is not null then
12462  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12463 			       'DESCRIPTION', l_cust_b2b_rec.DESCRIPTION);
12464        end if;
12465        if trim(l_cust_b2b_rec.DISADVANTAGED_INDICATOR) is not null then
12466  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12467 			       'DISADVANTAGED_INDICATOR', l_cust_b2b_rec.DISADVANTAGED_INDICATOR);
12468        end if;
12469        if trim(l_cust_b2b_rec.ENQUIRY_DUNS) is not null then
12470  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12471 			       'ENQUIRY_DUNS', l_cust_b2b_rec.ENQUIRY_DUNS);
12472        end if;
12473        if trim(l_cust_b2b_rec.EXPORT_INDICATOR) is not null then
12474  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12475 			       'EXPORT_INDICATOR', l_cust_b2b_rec.EXPORT_INDICATOR);
12476        end if;
12477        if trim(l_cust_b2b_rec.FAILURE_SCORE) is not null then
12478  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12479 			       'FAILURE_SCORE', l_cust_b2b_rec.FAILURE_SCORE);
12480        end if;
12481        if trim(l_cust_b2b_rec.FAILURE_SCORE_COMMENTARY) is not null then
12482  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12483 			       'FAILURE_SCORE_COMMENTARY', l_cust_b2b_rec.FAILURE_SCORE_COMMENTARY);
12484        end if;
12485        if trim(l_cust_b2b_rec.FAILURE_SCORE_OVERRIDE_CODE) is not null then
12486  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12487 			       'FAILURE_SCORE_OVERRIDE_CODE', l_cust_b2b_rec.FAILURE_SCORE_OVERRIDE_CODE);
12488        end if;
12489        if trim(l_cust_b2b_rec.GLOBAL_FAILURE_SCORE) is not null then
12490  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12491 			       'GLOBAL_FAILURE_SCORE', l_cust_b2b_rec.GLOBAL_FAILURE_SCORE);
12492        end if;
12493        if trim(l_cust_b2b_rec.HEADQUARTER_BRANCH_INDICATOR) is not null then
12494  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12495 			       'HEADQUARTER_BRANCH_INDICATOR', l_cust_b2b_rec.HEADQUARTER_BRANCH_INDICATOR);
12496        end if;
12497        if trim(l_cust_b2b_rec.HEAD_OF_HOUSEHOLD_FLAG) is not null then
12498  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12499 			       'HEAD_OF_HOUSEHOLD_FLAG', l_cust_b2b_rec.HEAD_OF_HOUSEHOLD_FLAG);
12500        end if;
12501        if trim(l_cust_b2b_rec.IMPORT_INDICATOR) is not null then
12502  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12503 			       'IMPORT_INDICATOR', l_cust_b2b_rec.IMPORT_INDICATOR);
12504        end if;
12505        if trim(l_cust_b2b_rec.ORGANIZATION_KNOWN_AS) is not null then
12506  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12507 			       'ORGANIZATION_KNOWN_AS', l_cust_b2b_rec.ORGANIZATION_KNOWN_AS);
12508        end if;
12509               if trim(l_cust_b2b_rec.ORGANIZATION_KNOWN_AS2) is not null then
12510  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12511 			       'ORGANIZATION_KNOWN_AS2', l_cust_b2b_rec.ORGANIZATION_KNOWN_AS2);
12512        end if;
12513        if trim(l_cust_b2b_rec.ORGANIZATION_KNOWN_AS3) is not null then
12514  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12515 			       'ORGANIZATION_KNOWN_AS3', l_cust_b2b_rec.ORGANIZATION_KNOWN_AS3);
12516        end if;
12517        if trim(l_cust_b2b_rec.ORGANIZATION_KNOWN_AS4) is not null then
12518  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12519 			       'ORGANIZATION_KNOWN_AS4', l_cust_b2b_rec.ORGANIZATION_KNOWN_AS4);
12520        end if;
12521        if trim(l_cust_b2b_rec.ORGANIZATION_KNOWN_AS5) is not null then
12522  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12523 			       'ORGANIZATION_KNOWN_AS5', l_cust_b2b_rec.ORGANIZATION_KNOWN_AS5);
12524        end if;
12525 
12526        if trim(l_cust_b2b_rec.PERSON_KNOWN_AS) is not null then
12527  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12528 			       'PERSON_KNOWN_AS', l_cust_b2b_rec.PERSON_KNOWN_AS);
12529        end if;
12530               if trim(l_cust_b2b_rec.PERSON_KNOWN_AS2) is not null then
12531  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12532 			       'PERSON_KNOWN_AS2', l_cust_b2b_rec.PERSON_KNOWN_AS2);
12533        end if;
12534               if trim(l_cust_b2b_rec.PERSON_KNOWN_AS3) is not null then
12535  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12536 			       'PERSON_KNOWN_AS3', l_cust_b2b_rec.PERSON_KNOWN_AS3);
12537        end if;
12538               if trim(l_cust_b2b_rec.PERSON_KNOWN_AS4) is not null then
12539  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12540 			       'PERSON_KNOWN_AS4', l_cust_b2b_rec.PERSON_KNOWN_AS4);
12541        end if;
12542               if trim(l_cust_b2b_rec.PERSON_KNOWN_AS5) is not null then
12543  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12544 			       'PERSON_KNOWN_AS5', l_cust_b2b_rec.PERSON_KNOWN_AS5);
12545        end if;
12546        if trim(l_cust_b2b_rec.LABOR_SURPLUS_INDICATOR) is not null then
12547  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12548 			       'LABOR_SURPLUS_INDICATOR', l_cust_b2b_rec.LABOR_SURPLUS_INDICATOR);
12549        end if;
12550        if trim(l_cust_b2b_rec.LOCAL_ACTIVITY_CODE) is not null then
12551  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12552 			       'LOCAL_ACTIVITY_CODE', l_cust_b2b_rec.LOCAL_ACTIVITY_CODE);
12553        end if;
12554        if trim(l_cust_b2b_rec.LOCAL_ACTIVITY_CODE_TYPE) is not null then
12555  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12556 			       'LOCAL_ACTIVITY_CODE_TYPE', l_cust_b2b_rec.LOCAL_ACTIVITY_CODE_TYPE);
12557        end if;
12558        if trim(l_cust_b2b_rec.LOCATION_DIRECTIONS) is not null then
12559  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12560 			       'LOCATION_DIRECTIONS', l_cust_b2b_rec.LOCATION_DIRECTIONS);
12561        end if;
12562        if trim(l_cust_b2b_rec.MARITAL_STATUS) is not null then
12563  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12564 			       'MARITAL_STATUS', l_cust_b2b_rec.MARITAL_STATUS);
12565        end if;
12566 
12567        if trim(l_cust_b2b_rec.MINORITY_OWNED_INDICATOR) is not null then
12568  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12569 			       'MINORITY_OWNED_INDICATOR', l_cust_b2b_rec.MINORITY_OWNED_INDICATOR);
12570        end if;
12571 
12572        if trim(l_cust_b2b_rec.MINORITY_OWNED_TYPE) is not null then
12573  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12574 			       'MINORITY_OWNED_TYPE', l_cust_b2b_rec.MINORITY_OWNED_TYPE);
12575        end if;
12576 
12577        if trim(l_cust_b2b_rec.ORGANIZATION_TYPE) is not null then
12578  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12579 			       'ORGANIZATION_TYPE', l_cust_b2b_rec.ORGANIZATION_TYPE);
12580        end if;
12581 
12582        if trim(l_cust_b2b_rec.OUT_OF_BUSINESS_INDICATOR) is not null then
12583  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12584 			       'OUT_OF_BUSINESS_INDICATOR', l_cust_b2b_rec.OUT_OF_BUSINESS_INDICATOR);
12585        end if;
12586 
12587        if trim(l_cust_b2b_rec.PERSON_ACADEMIC_TITLE) is not null then
12588  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12589 			       'PERSON_ACADEMIC_TITLE', l_cust_b2b_rec.PERSON_ACADEMIC_TITLE);
12590        end if;
12591        if trim(l_cust_b2b_rec.PERSON_FIRST_NAME_PHONETIC) is not null then
12592  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12593 			       'PERSON_FIRST_NAME_PHONETIC', l_cust_b2b_rec.PERSON_FIRST_NAME_PHONETIC);
12594        end if;
12595        if trim(l_cust_b2b_rec.PERSON_LAST_NAME_PHONETIC) is not null then
12596  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12597 			       'PERSON_LAST_NAME_PHONETIC', l_cust_b2b_rec.PERSON_LAST_NAME_PHONETIC);
12598        end if;
12599        if trim(l_cust_b2b_rec.MIDDLE_NAME_PHONETIC) is not null then
12600  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12601 			       'MIDDLE_NAME_PHONETIC', l_cust_b2b_rec.MIDDLE_NAME_PHONETIC);
12602        end if;
12603        if trim(l_cust_b2b_rec.PERSON_NAME_PHONETIC) is not null then
12604  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12605 			       'PERSON_NAME_PHONETIC', l_cust_b2b_rec.PERSON_NAME_PHONETIC);
12606        end if;
12607        if trim(l_cust_b2b_rec.PERSON_PREVIOUS_TITLE_NAME) is not null then
12608  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12609 			       'PERSON_PREVIOUS_TITLE_NAME', l_cust_b2b_rec.PERSON_PREVIOUS_TITLE_NAME);
12610        end if;
12611        if trim(l_cust_b2b_rec.PLACE_OF_BIRTH) is not null then
12612  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12613 			       'PLACE_OF_BIRTH', l_cust_b2b_rec.PLACE_OF_BIRTH);
12614        end if;
12615        if trim(l_cust_b2b_rec.PRINCIPAL_NAME) is not null then
12616  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12617 			       'PRINCIPAL_NAME', l_cust_b2b_rec.PRINCIPAL_NAME);
12618        end if;
12619        if trim(l_cust_b2b_rec.PRINCIPAL_TITLE) is not null then
12620  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12621 			       'PRINCIPAL_TITLE', l_cust_b2b_rec.PRINCIPAL_TITLE);
12622        end if;
12623 
12624        if trim(l_cust_b2b_rec.PUBLIC_PRIVATE_OWNERSHIP_FLAG) is not null then
12625  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12626 			       'PUBLIC_PRIVATE_OWNERSHIP_FLAG', l_cust_b2b_rec.PUBLIC_PRIVATE_OWNERSHIP_FLAG);
12627        end if;
12628        if trim(l_cust_b2b_rec.RENT_OWNED_INDICATOR) is not null then
12629  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12630 			       'RENT_OWNED_INDICATOR', l_cust_b2b_rec.RENT_OWNED_INDICATOR);
12631        end if;
12632 
12633        if trim(l_cust_b2b_rec.SHORT_DESCRIPTION) is not null then
12634  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12635 			       'SHORT_DESCRIPTION', l_cust_b2b_rec.SHORT_DESCRIPTION);
12636        end if;
12637 
12638        if trim(l_cust_b2b_rec.SMALL_BUSINESS_INDICATOR) is not null then
12639  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12640 			       'SMALL_BUSINESS_INDICATOR', l_cust_b2b_rec.SMALL_BUSINESS_INDICATOR);
12641        end if;
12642 
12643        if trim(l_cust_b2b_rec.TAX_ID) is not null then
12644  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12645 			       'TAX_ID', l_cust_b2b_rec.TAX_ID);
12646        end if;
12647 
12648        if trim(l_cust_b2b_rec.WOMAN_OWNED_INDICATOR) is not null then
12649  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12650 			       'WOMAN_OWNED_INDICATOR', l_cust_b2b_rec.WOMAN_OWNED_INDICATOR);
12651        end if;
12652 
12653        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE1) is not null then
12654  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12655 			       'ORGANIZATION_ATTRIBUTE1', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE1);
12656        end if;
12657        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE2) is not null then
12658  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12659 			       'ORGANIZATION_ATTRIBUTE2', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE2);
12660        end if;
12661        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE3) is not null then
12662  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12663 			       'ORGANIZATION_ATTRIBUTE3', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE3);
12664        end if;
12665 
12666        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE4) is not null then
12667  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12668 			       'ORGANIZATION_ATTRIBUTE4', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE4);
12669        end if;
12670        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE5) is not null then
12671  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12672 			       'ORGANIZATION_ATTRIBUTE5', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE5);
12673        end if;
12674        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE6) is not null then
12675  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12676 			       'ORGANIZATION_ATTRIBUTE6', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE6);
12677        end if;
12678        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE7) is not null then
12679  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12680 			       'ORGANIZATION_ATTRIBUTE7', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE7);
12681        end if;
12682        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE8) is not null then
12683  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12684 			       'ORGANIZATION_ATTRIBUTE8', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE8);
12685        end if;
12686        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE9) is not null then
12687  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12688 			       'ORGANIZATION_ATTRIBUTE9', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTe9);
12689        end if;
12690        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE10) is not null then
12691  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12692 			       'ORGANIZATION_ATTRIBUTE10', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE10);
12693        end if;
12694        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE11) is not null then
12695  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12696 			       'ORGANIZATION_ATTRIBUTE11', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE11);
12697        end if;
12698        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE12) is not null then
12699  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12700 			       'ORGANIZATION_ATTRIBUTE12', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE12);
12701        end if;
12702        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE13) is not null then
12703  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12704 			       'ORGANIZATION_ATTRIBUTE13', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE13);
12705        end if;
12706        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE14) is not null then
12707  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12708 			       'ORGANIZATION_ATTRIBUTE14', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE14);
12709        end if;
12710        if trim(l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE15) is not null then
12711  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12712 			       'ORGANIZATION_ATTRIBUTE15', l_cust_b2b_rec.ORGANIZATION_ATTRIBUTE15);
12713        end if;
12714 
12715        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE1) is not null then
12716  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12717 			       'ORG_CONTACT_ATTRIBUTE1', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE1);
12718        end if;
12719        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE2) is not null then
12720  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12721 			       'ORG_CONTACT_ATTRIBUTE2', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE2);
12722        end if;
12723        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE3) is not null then
12724  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12725 			       'ORG_CONTACT_ATTRIBUTE3', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE3);
12726        end if;
12727        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE4) is not null then
12728  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12729 			       'ORG_CONTACT_ATTRIBUTE4', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE4);
12730        end if;
12731        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE5) is not null then
12732  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12733 			       'ORG_CONTACT_ATTRIBUTE5', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE5);
12734        end if;
12735        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE6) is not null then
12736  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12737 			       'ORG_CONTACT_ATTRIBUTE6', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE6);
12738        end if;
12739        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE7) is not null then
12740  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12741 			       'ORG_CONTACT_ATTRIBUTE7', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE7);
12742        end if;
12743        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE8) is not null then
12744  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12745 			       'ORG_CONTACT_ATTRIBUTE8', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE8);
12746        end if;
12747        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE9) is not null then
12748  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12749 			       'ORG_CONTACT_ATTRIBUTE9', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE9);
12750        end if;
12751        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE10) is not null then
12752  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12753 			       'ORG_CONTACT_ATTRIBUTE10', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE10);
12754        end if;
12755        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE11) is not null then
12756  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12757 			       'ORG_CONTACT_ATTRIBUTE11', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE11);
12758        end if;
12759        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE12) is not null then
12760  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12761 			       'ORG_CONTACT_ATTRIBUTE12', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE12);
12762        end if;
12763        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE13) is not null then
12764  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12765 			       'ORG_CONTACT_ATTRIBUTE13', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE13);
12766        end if;
12767        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE14) is not null then
12768  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12769 			       'ORG_CONTACT_ATTRIBUTE14', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE14);
12770        end if;
12771        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE15) is not null then
12772  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12773 			       'ORG_CONTACT_ATTRIBUTE15', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE15);
12774        end if;
12775 
12776        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE1) is not null then
12777  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12778 			       'ADDRESS_ATTRIBUTE1', l_cust_b2b_rec.ADDRESS_ATTRIBUTE1);
12779        end if;
12780        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE2) is not null then
12781  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12782 			       'ADDRESS_ATTRIBUTE2', l_cust_b2b_rec.ADDRESS_ATTRIBUTE2);
12783        end if;
12784        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE3) is not null then
12785  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12786 			       'ADDRESS_ATTRIBUTE3', l_cust_b2b_rec.ADDRESS_ATTRIBUTE3);
12787        end if;
12788        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE4) is not null then
12789  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12790 			       'ADDRESS_ATTRIBUTE4', l_cust_b2b_rec.ADDRESS_ATTRIBUTE4);
12791        end if;
12792        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE5) is not null then
12793  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12794 			       'ADDRESS_ATTRIBUTE5', l_cust_b2b_rec.ADDRESS_ATTRIBUTE5);
12795        end if;
12796        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE6) is not null then
12797  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12798 			       'ADDRESS_ATTRIBUTE6', l_cust_b2b_rec.ADDRESS_ATTRIBUTE6);
12799        end if;
12800        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE7) is not null then
12801  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12802 			       'ADDRESS_ATTRIBUTE7', l_cust_b2b_rec.ADDRESS_ATTRIBUTE7);
12803        end if;
12804        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE8) is not null then
12805  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12806 			       'ADDRESS_ATTRIBUTE8', l_cust_b2b_rec.ADDRESS_ATTRIBUTE8);
12807        end if;
12808        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE9) is not null then
12809  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12810 			       'ADDRESS_ATTRIBUTE9', l_cust_b2b_rec.ADDRESS_ATTRIBUTE9);
12811        end if;
12812        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE10) is not null then
12813  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12814 			       'ADDRESS_ATTRIBUTE10', l_cust_b2b_rec.ADDRESS_ATTRIBUTE10);
12815        end if;
12816        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE11) is not null then
12817  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12818 			       'ADDRESS_ATTRIBUTE11', l_cust_b2b_rec.ADDRESS_ATTRIBUTE11);
12819        end if;
12820        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE12) is not null then
12821  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12822 			       'ADDRESS_ATTRIBUTE12', l_cust_b2b_rec.ADDRESS_ATTRIBUTE12);
12823        end if;
12824        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE13) is not null then
12825  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12826 			       'ADDRESS_ATTRIBUTE13', l_cust_b2b_rec.ADDRESS_ATTRIBUTE13);
12827        end if;
12828        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE14) is not null then
12829  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12830 			       'ADDRESS_ATTRIBUTE14', l_cust_b2b_rec.ADDRESS_ATTRIBUTE14);
12831        end if;
12832        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE15) is not null then
12833  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12834 			       'ADDRESS_ATTRIBUTE15', l_cust_b2b_rec.ADDRESS_ATTRIBUTE15);
12835        end if;
12836 
12837        if trim(l_cust_b2b_rec.FAX_COUNTRY_CODE) is not null then
12838  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.fx_imp_xml_element_id,
12839 			       'FAX_COUNTRY_CODE', l_cust_b2b_rec.FAX_COUNTRY_CODE);
12840        end if;
12841        if trim(l_cust_b2b_rec.FAX_AREA_CODE) is not null then
12842  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.fx_imp_xml_element_id,
12843 			       'FAX_AREA_CODE', l_cust_b2b_rec.FAX_AREA_CODE);
12844        end if;
12845        if trim(l_cust_b2b_rec.FAX_NUMBER) is not null then
12846  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.fx_imp_xml_element_id,
12847 			       'FAX_NUMBER', l_cust_b2b_rec.FAX_NUMBER);
12848        end if;
12849        if trim(l_cust_b2b_rec.ORG_ATTRIBUTE_CATEGORY) is not null then
12850  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12851 			       'ORG_ATTRIBUTE_CATEGORY', l_cust_b2b_rec.ORG_ATTRIBUTE_CATEGORY);
12852        end if;
12853 
12854        if trim(l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE_CATEGORY) is not null then
12855  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12856 			       'ORG_CONTACT_ATTRIBUTE_CATEGORY', l_cust_b2b_rec.ORG_CONTACT_ATTRIBUTE_CATEGORY);
12857        end if;
12858        if trim(l_cust_b2b_rec.ADDRESS_ATTRIBUTE_CATEGORY) is not null then
12859  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.add_imp_xml_element_id,
12860 			       'ADDRESS_ATTRIBUTE_CATEGORY', l_cust_b2b_rec.ADDRESS_ATTRIBUTE_CATEGORY);
12861        end if;
12862        if trim(l_cust_b2b_rec.CONTROL_YEAR) is not null then
12863  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12864 			       'CONTROL_YEAR', l_cust_b2b_rec.CONTROL_YEAR);
12865        end if;
12866        if trim(l_cust_b2b_rec.DEBARMENTS_COUNT) is not null then
12867  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12868 			       'DEBARMENTS_COUNT', l_cust_b2b_rec.DEBARMENTS_COUNT);
12869        end if;
12870        if trim(l_cust_b2b_rec.HOUSEHOLD_SIZE) is not null then
12871  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12872 			       'HOUSEHOLD_SIZE', l_cust_b2b_rec.HOUSEHOLD_SIZE);
12873        end if;
12874        if trim(l_cust_b2b_rec.PERSONAL_INCOME) is not null then
12875  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.ocont_imp_xml_element_id,
12876 			       'PERSONAL_INCOME', l_cust_b2b_rec.PERSONAL_INCOME);
12877        end if;
12878        if trim(l_cust_b2b_rec.NOTES) is not null then
12879  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12880 			       'NOTES', l_cust_b2b_rec.NOTES);
12881        end if;
12882        if trim(l_cust_b2b_rec.VEHICLE_RESPONSE_CODE) is not null then
12883  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12884 			       'VEHICLE_RESPONSE_CODE', l_cust_b2b_rec.VEHICLE_RESPONSE_CODE);
12885        end if;
12886        if trim(l_cust_b2b_rec.SALES_AGENT_EMAIL_ID) is not null then
12887  	 update_element_error (p_import_list_header_id,l_cust_b2b_rec.org_imp_xml_element_id,
12888 			       'SALES_AGENT_EMAIL_ID', l_cust_b2b_rec.SALES_AGENT_EMAIL_ID);
12889        end if;
12890 
12891     -- **********************************
12892     END LOOP;
12893      CLOSE b2b;
12894     end if;
12895 
12896 -- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
12897 if x_b2b = 'B2C' then
12898         OPEN b2c;
12899      LOOP
12900       FETCH b2c  INTO
12901         l_import_source_line_id,
12902         l_import_list_header_id,
12903         l_cust_b2c_rec.per_imp_xml_element_id,
12904         l_cust_b2c_rec.add_imp_xml_element_id,
12905         l_cust_b2c_rec.cp_imp_xml_element_id,
12906         l_cust_b2c_rec.em_imp_xml_element_id,
12907         l_cust_b2c_rec.ADDRESS1,
12908         l_cust_b2c_rec.ADDRESS2,
12909         l_cust_b2c_rec.ADDRESS3,
12910         l_cust_b2c_rec.ADDRESS4,
12911         l_cust_b2c_rec.PERSON_LAST_NAME,
12912         l_cust_b2c_rec.PERSON_FIRST_NAME,
12913         l_cust_b2c_rec.PERSON_NAME_PREFIX,
12914         l_cust_b2c_rec.PERSON_MIDDLE_NAME,
12915         l_cust_b2c_rec.PERSON_NAME_SUFFIX,
12916         -- l_cust_b2c_rec.PERSON_PRE_NAME_ADJUNCT,
12917         l_cust_b2c_rec.CITY,
12918         l_cust_b2c_rec.SALUTATION,
12919         l_cust_b2c_rec.POSTAL_CODE,
12920         l_cust_b2c_rec.STATE,
12921         l_cust_b2c_rec.PROVINCE,
12922         l_cust_b2c_rec.COUNTY,
12923         l_cust_b2c_rec.COUNTRY,
12924         l_cust_b2c_rec.EMAIL_ADDRESS,
12925         l_cust_b2c_rec.PHONE_COUNTRY_CODE,
12926         l_cust_b2c_rec.PHONE_AREA_CODE,
12927         l_cust_b2c_rec.PHONE_NUMBER,
12928         l_cust_b2c_rec.PHONE_EXTENSION,
12929         l_cust_b2c_rec.identifying_address_flag,
12930         l_cust_b2c_rec.ADDRESS_LINES_PHONETIC,
12931 -- bug 4641591: columns obsolete
12932 --	l_cust_b2c_rec.PO_BOX_NUMBER,
12933 --        l_cust_b2c_rec.FLOOR,
12934 --        l_cust_b2c_rec.HOUSE_NUMBER,
12935         l_cust_b2c_rec.POSTAL_PLUS4_CODE,
12936 --        l_cust_b2c_rec.STREET_SUFFIX,
12937 --        l_cust_b2c_rec.STREET,
12938 --        l_cust_b2c_rec.STREET_NUMBER,
12939 --        l_cust_b2c_rec.SUITE,
12940         l_cust_b2c_rec.party_id,
12941         l_cust_b2c_rec.URL,
12942 	l_cust_b2c_rec.DECLARED_ETHNICITY,
12943 	l_cust_b2c_rec.DESCRIPTION,
12944 	l_cust_b2c_rec.HEAD_OF_HOUSEHOLD_FLAG,
12945 	l_cust_b2c_rec.PERSON_KNOWN_AS,
12946 	l_cust_b2c_rec.PERSON_KNOWN_AS2,
12947 	l_cust_b2c_rec.PERSON_KNOWN_AS3,
12948 	l_cust_b2c_rec.PERSON_KNOWN_AS4,
12949 	l_cust_b2c_rec.PERSON_KNOWN_AS5,
12950 	l_cust_b2c_rec.LOCATION_DIRECTIONS,
12951 	l_cust_b2c_rec.MARITAL_STATUS,
12952 	l_cust_b2c_rec.PERSON_ACADEMIC_TITLE,
12953 	l_cust_b2c_rec.PERSON_FIRST_NAME_PHONETIC,
12954 	l_cust_b2c_rec.PERSON_LAST_NAME_PHONETIC,
12955 	l_cust_b2c_rec.MIDDLE_NAME_PHONETIC,
12956 	l_cust_b2c_rec.PERSON_NAME_PHONETIC,
12957 	l_cust_b2c_rec.PERSON_PREVIOUS_TITLE_NAME,
12958 	-- l_cust_b2c_rec.SECOND_TITLE,
12959 	l_cust_b2c_rec.SHORT_DESCRIPTION,
12960 	l_cust_b2c_rec.PERSON_ATTRIBUTE1,
12961 	l_cust_b2c_rec.PERSON_ATTRIBUTE2,
12962 	l_cust_b2c_rec.PERSON_ATTRIBUTE3,
12963 	l_cust_b2c_rec.PERSON_ATTRIBUTE4,
12964 	l_cust_b2c_rec.PERSON_ATTRIBUTE5,
12965 	l_cust_b2c_rec.PERSON_ATTRIBUTE6,
12966 	l_cust_b2c_rec.PERSON_ATTRIBUTE7,
12967 	l_cust_b2c_rec.PERSON_ATTRIBUTE8,
12968 	l_cust_b2c_rec.PERSON_ATTRIBUTE9,
12969 	l_cust_b2c_rec.PERSON_ATTRIBUTE10,
12970 	l_cust_b2c_rec.PERSON_ATTRIBUTE11,
12971 	l_cust_b2c_rec.PERSON_ATTRIBUTE12,
12972 	l_cust_b2c_rec.PERSON_ATTRIBUTE13,
12973 	l_cust_b2c_rec.PERSON_ATTRIBUTE14,
12974 	l_cust_b2c_rec.PERSON_ATTRIBUTE15,
12975 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE1,
12976 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE2,
12977 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE3,
12978 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE4,
12979 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE5,
12980 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE6,
12981 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE7,
12982 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE8,
12983 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE9,
12984 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE10,
12985 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE11,
12986 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE12,
12987 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE13,
12988 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE14,
12989 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE15,
12990 	l_cust_b2c_rec.FAX_COUNTRY_CODE,
12991 	l_cust_b2c_rec.FAX_AREA_CODE,
12992 	l_cust_b2c_rec.FAX_NUMBER,
12993 	l_cust_b2c_rec.PERSON_ATTRIBUTE_CATEGORY,
12994 	l_cust_b2c_rec.ADDRESS_ATTRIBUTE_CATEGORY,
12995 	l_cust_b2c_rec.HOUSEHOLD_SIZE,
12996 	l_cust_b2c_rec.PERSONAL_INCOME,
12997 	l_cust_b2c_rec.DESCRIPTION,
12998 	l_cust_b2c_rec.SHORT_DESCRIPTION,
12999 	l_cust_b2c_rec.NOTES,
13000 	l_cust_b2c_rec.VEHICLE_RESPONSE_CODE,
13001 	l_cust_b2c_rec.SALES_AGENT_EMAIL_ID,
13002 	l_cust_b2c_rec.orig_system_reference,
13003 	l_cust_b2c_rec.tax_reference,
13004 	l_cust_b2c_rec.rent_owned_indicator;
13005       EXIT WHEN b2c%NOTFOUND;
13006 
13007        if trim(l_cust_b2c_rec.ADDRESS1) is not null then
13008          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13009                                'ADDRESS1', l_cust_b2c_rec.ADDRESS1);
13010        end if;
13011        if trim(l_cust_b2c_rec.ADDRESS2) is not null then
13012          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13013                                'ADDRESS2', l_cust_b2c_rec.ADDRESS2);
13014        end if;
13015        if trim(l_cust_b2c_rec.ADDRESS3) is not null then
13016          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13017                                'ADDRESS3', l_cust_b2c_rec.ADDRESS3);
13018        end if;
13019        if trim(l_cust_b2c_rec.ADDRESS4) is not null then
13020          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13021                                'ADDRESS4', l_cust_b2c_rec.ADDRESS4);
13022        end if;
13023        if trim(l_cust_b2c_rec.PERSON_LAST_NAME) is not null then
13024          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13025                                'PERSON_LAST_NAME', l_cust_b2c_rec.PERSON_LAST_NAME);
13026        end if;
13027        if trim(l_cust_b2c_rec.PERSON_FIRST_NAME) is not null then
13028          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13029                                'PERSON_FIRST_NAME', l_cust_b2c_rec.PERSON_FIRST_NAME);
13030        end if;
13031        if trim(l_cust_b2c_rec.orig_system_reference) is not null then
13032          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13033                                'ORIG_SYSTEM_REFERENCE', l_cust_b2c_rec.ORIG_SYSTEM_REFERENCE);
13034        end if;
13035        if trim(l_cust_b2c_rec.TAX_REFERENCE) is not null then
13036          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13037                                'TAX_REFERENCE', l_cust_b2c_rec.TAX_REFERENCE);
13038        end if;
13039        if trim(l_cust_b2c_rec.RENT_OWNED_INDICATOR) is not null then
13040          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13041                                'RENT_OWNED_INDICATOR', l_cust_b2c_rec.RENT_OWNED_INDICATOR);
13042        end if;
13043        if trim(l_cust_b2c_rec.PERSON_NAME_PREFIX) is not null then
13044          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13045                                'PERSON_NAME_PREFIX', l_cust_b2c_rec.PERSON_NAME_PREFIX);
13046        end if;
13047        if trim(l_cust_b2c_rec.PERSON_MIDDLE_NAME) is not null then
13048          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13049                                'PERSON_MIDDLE_NAME', l_cust_b2c_rec.PERSON_MIDDLE_NAME);
13050        end if;
13051        if trim(l_cust_b2c_rec.PERSON_NAME_SUFFIX) is not null then
13052          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13053                                'PERSON_NAME_SUFFIX', l_cust_b2c_rec.PERSON_NAME_SUFFIX);
13054        end if;
13055        if trim(l_cust_b2c_rec.CITY) is not null then
13056          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13057                                'CITY', l_cust_b2c_rec.CITY);
13058        end if;
13059        if trim(l_cust_b2c_rec.SALUTATION) is not null then
13060          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13061                                'SALUTATION', l_cust_b2c_rec.SALUTATION);
13062        end if;
13063        if trim(l_cust_b2c_rec.POSTAL_CODE) is not null then
13064          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13065                                'POSTAL_CODE', l_cust_b2c_rec.POSTAL_CODE);
13066        end if;
13067        if trim(l_cust_b2c_rec.STATE) is not null then
13068          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13069                                'STATE', l_cust_b2c_rec.STATE);
13070        end if;
13071        if trim(l_cust_b2c_rec.PROVINCE) is not null then
13072          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13073                                'PROVINCE', l_cust_b2c_rec.PROVINCE);
13074        end if;
13075        if trim(l_cust_b2c_rec.COUNTY) is not null then
13076          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13077                                'COUNTY', l_cust_b2c_rec.COUNTY);
13078        end if;
13079 
13080        if trim(l_cust_b2c_rec.COUNTRY) is not null then
13081          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13082                                'COUNTRY', l_cust_b2c_rec.COUNTRY);
13083        end if;
13084        if trim(l_cust_b2c_rec.EMAIL_ADDRESS) is not null then
13085          update_element_error (p_import_list_header_id,l_cust_b2c_rec.em_imp_xml_element_id,
13086                                'EMAIL_ADDRESS', l_cust_b2c_rec.EMAIL_ADDRESS);
13087        end if;
13088        if trim(l_cust_b2c_rec.PHONE_COUNTRY_CODE) is not null then
13089          update_element_error (p_import_list_header_id,l_cust_b2c_rec.cp_imp_xml_element_id,
13090                                'PHONE_COUNTRY_CODE', l_cust_b2c_rec.PHONE_COUNTRY_CODE);
13091        end if;
13092        if trim(l_cust_b2c_rec.PHONE_AREA_CODE) is not null then
13093          update_element_error (p_import_list_header_id,l_cust_b2c_rec.cp_imp_xml_element_id,
13094                                'PHONE_AREA_CODE', l_cust_b2c_rec.PHONE_AREA_CODE);
13095        end if;
13096        if trim(l_cust_b2c_rec.PHONE_NUMBER) is not null then
13097          update_element_error (p_import_list_header_id,l_cust_b2c_rec.cp_imp_xml_element_id,
13098                                'PHONE_NUMBER', l_cust_b2c_rec.PHONE_NUMBER);
13099        end if;
13100        if trim(l_cust_b2c_rec.PHONE_EXTENSION) is not null then
13101          update_element_error (p_import_list_header_id,l_cust_b2c_rec.cp_imp_xml_element_id,
13102                                'PHONE_EXTENSION', l_cust_b2c_rec.PHONE_EXTENSION);
13103        end if;
13104        if trim(l_cust_b2c_rec.identifying_address_flag) is not null then
13105          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13106                                'IDENTIFYING_ADDRESS_FLAG', l_cust_b2c_rec.IDENTIFYING_ADDRESS_FLAG);
13107        end if;
13108        if trim(l_cust_b2c_rec.ADDRESS_LINES_PHONETIC) is not null then
13109          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13110                                'ADDRESS_LINES_PHONETIC', l_cust_b2c_rec.ADDRESS_LINES_PHONETIC);
13111        end if;
13112 /* -- bug 4641591: columns obsolete
13113        if trim(l_cust_b2c_rec.PO_BOX_NUMBER) is not null then
13114          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13115                                'PO_BOX_NUMBER', l_cust_b2c_rec.PO_BOX_NUMBER);
13116        end if;
13117        if trim(l_cust_b2c_rec.FLOOR) is not null then
13118          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13119                                'FLOOR', l_cust_b2c_rec.FLOOR);
13120        end if;
13121        if trim(l_cust_b2c_rec.HOUSE_NUMBER) is not null then
13122          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13123                                'HOUSE_NUMBER', l_cust_b2c_rec.HOUSE_NUMBER);
13124        end if;
13125 */
13126        if trim(l_cust_b2c_rec.POSTAL_PLUS4_CODE) is not null then
13127          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13128                                'POSTAL_PLUS4_CODE', l_cust_b2c_rec.POSTAL_PLUS4_CODE);
13129        end if;
13130 /* -- bug 4641591: columns obsolete
13131        if trim(l_cust_b2c_rec.STREET_SUFFIX) is not null then
13132          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13133                                'STREET_SUFFIX', l_cust_b2c_rec.STREET_SUFFIX);
13134        end if;
13135        if trim(l_cust_b2c_rec.STREET) is not null then
13136          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13137                                'STREET', l_cust_b2c_rec.STREET);
13138        end if;
13139        if trim(l_cust_b2c_rec.STREET_NUMBER) is not null then
13140          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13141                                'STREET_NUMBER', l_cust_b2c_rec.STREET_NUMBER);
13142        end if;
13143        if trim(l_cust_b2c_rec.SUITE) is not null then
13144          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13145                                'SUITE', l_cust_b2c_rec.SUITE);
13146        end if;
13147 */
13148        if trim(l_cust_b2c_rec.party_id) is not null then
13149          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13150                                'PARTY_ID', l_cust_b2c_rec.PARTY_ID);
13151        end if;
13152 
13153        if trim(l_cust_b2c_rec.URL) is not null then
13154          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13155                                'URL', l_cust_b2c_rec.URL);
13156        end if;
13157        if trim(l_cust_b2c_rec.DECLARED_ETHNICITY) is not null then
13158          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13159                                'DECLARED_ETHNICITY', l_cust_b2c_rec.DECLARED_ETHNICITY);
13160        end if;
13161        if trim(l_cust_b2c_rec.DESCRIPTION) is not null then
13162          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13163                                'DESCRIPTION', l_cust_b2c_rec.DESCRIPTION);
13164        end if;
13165        if trim(l_cust_b2c_rec.HEAD_OF_HOUSEHOLD_FLAG) is not null then
13166          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13167                                'HEAD_OF_HOUSEHOLD_FLAG', l_cust_b2c_rec.HEAD_OF_HOUSEHOLD_FLAG);
13168        end if;
13169        if trim(l_cust_b2c_rec.PERSON_KNOWN_AS) is not null then
13170          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13171                                'PERSON_KNOWN_AS', l_cust_b2c_rec.PERSON_KNOWN_AS);
13172        end if;
13173               if trim(l_cust_b2c_rec.PERSON_KNOWN_AS2) is not null then
13174          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13175                                'PERSON_KNOWN_AS2', l_cust_b2c_rec.PERSON_KNOWN_AS2);
13176        end if;
13177        if trim(l_cust_b2c_rec.PERSON_KNOWN_AS3) is not null then
13178          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13179                                'PERSON_KNOWN_AS3', l_cust_b2c_rec.PERSON_KNOWN_AS3);
13180        end if;
13181        if trim(l_cust_b2c_rec.PERSON_KNOWN_AS4) is not null then
13182          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13183                                'PERSON_KNOWN_AS4', l_cust_b2c_rec.PERSON_KNOWN_AS4);
13184        end if;
13185        if trim(l_cust_b2c_rec.PERSON_KNOWN_AS5) is not null then
13186          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13187                                'PERSON_KNOWN_AS5', l_cust_b2c_rec.PERSON_KNOWN_AS5);
13188        end if;
13189 
13190        if trim(l_cust_b2c_rec.LOCATION_DIRECTIONS) is not null then
13191          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13192                                'LOCATION_DIRECTIONS', l_cust_b2c_rec.LOCATION_DIRECTIONS);
13193        end if;
13194        if trim(l_cust_b2c_rec.MARITAL_STATUS) is not null then
13195          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13196                                'MARITAL_STATUS', l_cust_b2c_rec.MARITAL_STATUS);
13197        end if;
13198        if trim(l_cust_b2c_rec.PERSON_ACADEMIC_TITLE) is not null then
13199          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13200                                'PERSON_ACADEMIC_TITLE', l_cust_b2c_rec.PERSON_ACADEMIC_TITLE);
13201        end if;
13202        if trim(l_cust_b2c_rec.PERSON_FIRST_NAME_PHONETIC) is not null then
13203          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13204                                'PERSON_FIRST_NAME_PHONETIC', l_cust_b2c_rec.PERSON_FIRST_NAME_PHONETIC);
13205        end if;
13206        if trim(l_cust_b2c_rec.PERSON_LAST_NAME_PHONETIC) is not null then
13207          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13208                                'PERSON_LAST_NAME_PHONETIC', l_cust_b2c_rec.PERSON_LAST_NAME_PHONETIC);
13209        end if;
13210        if trim(l_cust_b2c_rec.MIDDLE_NAME_PHONETIC) is not null then
13211          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13212                                'MIDDLE_NAME_PHONETIC', l_cust_b2c_rec.MIDDLE_NAME_PHONETIC);
13213        end if;
13214        if trim(l_cust_b2c_rec.PERSON_NAME_PHONETIC) is not null then
13215          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13216                                'PERSON_NAME_PHONETIC', l_cust_b2c_rec.PERSON_NAME_PHONETIC);
13217        end if;
13218        if trim(l_cust_b2c_rec.PERSON_PREVIOUS_TITLE_NAME) is not null then
13219          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13220                                'PERSON_PREVIOUS_TITLE_NAME', l_cust_b2c_rec.PERSON_PREVIOUS_TITLE_NAME);
13221        end if;
13222        if trim(l_cust_b2c_rec.SHORT_DESCRIPTION) is not null then
13223          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13224                                'SHORT_DESCRIPTION', l_cust_b2c_rec.SHORT_DESCRIPTION);
13225        end if;
13226        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE1) is not null then
13227          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13228                                'PERSON_ATTRIBUTE1', l_cust_b2c_rec.PERSON_ATTRIBUTE1);
13229        end if;
13230        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE2) is not null then
13231          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13232                                'PERSON_ATTRIBUTE2', l_cust_b2c_rec.PERSON_ATTRIBUTE2);
13233        end if;
13234        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE3) is not null then
13235          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13236                                'PERSON_ATTRIBUTE3', l_cust_b2c_rec.PERSON_ATTRIBUTE3);
13237        end if;
13238        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE4) is not null then
13239          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13240                                'PERSON_ATTRIBUTE4', l_cust_b2c_rec.PERSON_ATTRIBUTE4);
13241        end if;
13242        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE5) is not null then
13243          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13244                                'PERSON_ATTRIBUTE5', l_cust_b2c_rec.PERSON_ATTRIBUTE5);
13245        end if;
13246        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE6) is not null then
13247          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13248                                'PERSON_ATTRIBUTE6', l_cust_b2c_rec.PERSON_ATTRIBUTE6);
13249        end if;
13250        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE7) is not null then
13251          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13252                                'PERSON_ATTRIBUTE7', l_cust_b2c_rec.PERSON_ATTRIBUTE7);
13253        end if;
13254        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE8) is not null then
13255          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13256                                'PERSON_ATTRIBUTE8', l_cust_b2c_rec.PERSON_ATTRIBUTE8);
13257        end if;
13258        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE9) is not null then
13259          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13260                                'PERSON_ATTRIBUTE9', l_cust_b2c_rec.PERSON_ATTRIBUTE9);
13261        end if;
13262        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE10) is not null then
13263          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13264                                'PERSON_ATTRIBUTE10', l_cust_b2c_rec.PERSON_ATTRIBUTE10);
13265        end if;
13266        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE11) is not null then
13267          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13268                                'PERSON_ATTRIBUTE11', l_cust_b2c_rec.PERSON_ATTRIBUTE11);
13269        end if;
13270        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE12) is not null then
13271          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13272                                'PERSON_ATTRIBUTE12', l_cust_b2c_rec.PERSON_ATTRIBUTE12);
13273        end if;
13274        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE13) is not null then
13275          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13276                                'PERSON_ATTRIBUTE13', l_cust_b2c_rec.PERSON_ATTRIBUTE13);
13277        end if;
13278        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE14) is not null then
13279          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13280                                'PERSON_ATTRIBUTE14', l_cust_b2c_rec.PERSON_ATTRIBUTE14);
13281        end if;
13282        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE15) is not null then
13283          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13284                                'PERSON_ATTRIBUTE15', l_cust_b2c_rec.PERSON_ATTRIBUTE15);
13285        end if;
13286 
13287        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE1) is not null then
13288          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13289                                'ADDRESS_ATTRIBUTE1', l_cust_b2c_rec.ADDRESS_ATTRIBUTE1);
13290        end if;
13291        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE2) is not null then
13292          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13293                                'ADDRESS_ATTRIBUTE2', l_cust_b2c_rec.ADDRESS_ATTRIBUTE2);
13294        end if;
13295        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE3) is not null then
13296          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13297                                'ADDRESS_ATTRIBUTE3', l_cust_b2c_rec.ADDRESS_ATTRIBUTE3);
13298        end if;
13299        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE4) is not null then
13300          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13301                                'ADDRESS_ATTRIBUTE4', l_cust_b2c_rec.ADDRESS_ATTRIBUTE4);
13302        end if;
13303        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE5) is not null then
13304          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13305                                'ADDRESS_ATTRIBUTE5', l_cust_b2c_rec.ADDRESS_ATTRIBUTE5);
13306        end if;
13307        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE6) is not null then
13308          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13309                                'ADDRESS_ATTRIBUTE6', l_cust_b2c_rec.ADDRESS_ATTRIBUTE6);
13310        end if;
13311        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE7) is not null then
13312          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13313                                'ADDRESS_ATTRIBUTE7', l_cust_b2c_rec.ADDRESS_ATTRIBUTE7);
13314        end if;
13315        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE8) is not null then
13316          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13317                                'ADDRESS_ATTRIBUTE8', l_cust_b2c_rec.ADDRESS_ATTRIBUTE8);
13318        end if;
13319        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE9) is not null then
13320          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13321                                'ADDRESS_ATTRIBUTE9', l_cust_b2c_rec.ADDRESS_ATTRIBUTE9);
13322        end if;
13323        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE10) is not null then
13324          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13325                                'ADDRESS_ATTRIBUTE11', l_cust_b2c_rec.ADDRESS_ATTRIBUTE11);
13326        end if;
13327        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE12) is not null then
13328          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13329                                'ADDRESS_ATTRIBUTE12', l_cust_b2c_rec.ADDRESS_ATTRIBUTE12);
13330        end if;
13331        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE13) is not null then
13332          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13333                                'ADDRESS_ATTRIBUTE13', l_cust_b2c_rec.ADDRESS_ATTRIBUTE13);
13334        end if;
13335        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE14) is not null then
13336          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13337                                'ADDRESS_ATTRIBUTE14', l_cust_b2c_rec.ADDRESS_ATTRIBUTE14);
13338        end if;
13339        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE15) is not null then
13340          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13341                                'ADDRESS_ATTRIBUTE15', l_cust_b2c_rec.ADDRESS_ATTRIBUTE15);
13342        end if;
13343        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE11) is not null then
13344          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13345                                'ADDRESS_ATTRIBUTE11', l_cust_b2c_rec.ADDRESS_ATTRIBUTE11);
13346        end if;
13347        if trim(l_cust_b2c_rec.FAX_COUNTRY_CODE) is not null then
13348          update_element_error (p_import_list_header_id,l_cust_b2c_rec.fx_imp_xml_element_id,
13349                                'FAX_COUNTRY_CODE', l_cust_b2c_rec.FAX_COUNTRY_CODE);
13350        end if;
13351        if trim(l_cust_b2c_rec.FAX_AREA_CODE) is not null then
13352          update_element_error (p_import_list_header_id,l_cust_b2c_rec.fx_imp_xml_element_id,
13353                                'FAX_AREA_CODE', l_cust_b2c_rec.FAX_AREA_CODE);
13354        end if;
13355        if trim(l_cust_b2c_rec.FAX_NUMBER) is not null then
13356          update_element_error (p_import_list_header_id,l_cust_b2c_rec.fx_imp_xml_element_id,
13357                                'FAX_NUMBER', l_cust_b2c_rec.FAX_NUMBER);
13358        end if;
13359 
13360        if trim(l_cust_b2c_rec.PERSON_ATTRIBUTE_CATEGORY) is not null then
13361          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13362                                'PERSON_ATTRIBUTE_CATEGORY', l_cust_b2c_rec.PERSON_ATTRIBUTE_CATEGORY);
13363        end if;
13364        if trim(l_cust_b2c_rec.ADDRESS_ATTRIBUTE_CATEGORY) is not null then
13365          update_element_error (p_import_list_header_id,l_cust_b2c_rec.add_imp_xml_element_id,
13366                                'ADDRESS_ATTRIBUTE_CATEGORY', l_cust_b2c_rec.ADDRESS_ATTRIBUTE_CATEGORY);
13367        end if;
13368        if trim(l_cust_b2c_rec.HOUSEHOLD_SIZE) is not null then
13369          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13370                                'HOUSEHOLD_SIZE', l_cust_b2c_rec.HOUSEHOLD_SIZE);
13371        end if;
13372        if trim(l_cust_b2c_rec.PERSONAL_INCOME) is not null then
13373          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13374                                'PERSONAL_INCOME', l_cust_b2c_rec.PERSONAL_INCOME);
13375        end if;
13376        if trim(l_cust_b2c_rec.DESCRIPTION) is not null then
13377          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13378                                'DESCRIPTION', l_cust_b2c_rec.DESCRIPTION);
13379        end if;
13380        if trim(l_cust_b2c_rec.SHORT_DESCRIPTION) is not null then
13381          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13382                                'SHORT_DESCRIPTION', l_cust_b2c_rec.SHORT_DESCRIPTION);
13383        end if;
13384        if trim(l_cust_b2c_rec.NOTES) is not null then
13385          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13386                                'NOTES', l_cust_b2c_rec.NOTES);
13387        end if;
13388        if trim(l_cust_b2c_rec.VEHICLE_RESPONSE_CODE) is not null then
13389          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13390                                'VEHICLE_RESPONSE_CODE', l_cust_b2c_rec.VEHICLE_RESPONSE_CODE);
13391        end if;
13392        if trim(l_cust_b2c_rec.SALES_AGENT_EMAIL_ID) is not null then
13393          update_element_error (p_import_list_header_id,l_cust_b2c_rec.per_imp_xml_element_id,
13394                                'SALES_AGENT_EMAIL_ID', l_cust_b2c_rec.SALES_AGENT_EMAIL_ID);
13395        end if;
13396 
13397     END LOOP;
13398      CLOSE b2c;
13399     end if;
13400 
13401 -- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
13402 
13403 EXCEPTION
13404  WHEN OTHERS THEN
13405     p_return_status := FND_API.G_RET_STS_ERROR;
13406     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
13407     FND_MESSAGE.Set_Token('ROW','Error in exe_custxml_data_validation:' || SQLERRM||' '||SQLCODE);
13408     AMS_Utility_PVT.Create_Log (
13409       x_return_status   => l_return_status,
13410       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13411       p_log_used_by_id  => p_import_list_header_id,
13412       p_msg_data        => FND_MESSAGE.get,
13413       p_msg_type        => 'DEBUG'
13414    );
13415 
13416 end exe_custxml_data_validation;
13417 -- ----------------------------------------------
13418 
13419 procedure create_contact_point(
13420         p_cpoint_rec              IN      hz_contact_point_v2pub.contact_point_rec_type,
13421         p_edi_rec                 IN      hz_contact_point_v2pub.edi_rec_type,
13422         p_email_rec               IN      hz_contact_point_v2pub.email_rec_type,
13423         p_phone_rec               IN      hz_contact_point_v2pub.phone_rec_type,
13424         p_telex_rec               IN      hz_contact_point_v2pub.telex_rec_type,
13425         p_web_rec                 IN      hz_contact_point_v2pub.web_rec_type,
13426         x_return_status         OUT NOCOPY     VARCHAR2,
13427         x_msg_count             OUT NOCOPY     NUMBER,
13428         x_msg_data              OUT NOCOPY     VARCHAR2,
13429         x_contact_point_id      OUT NOCOPY     NUMBER
13430 ) is
13431 
13432  cpoint_rec      hz_contact_point_v2pub.contact_point_rec_type := p_cpoint_rec;
13433  email_rec       hz_contact_point_v2pub.email_rec_type := p_email_rec;
13434  phone_rec       hz_contact_point_v2pub.phone_rec_type := p_phone_rec;
13435  edi_rec         hz_contact_point_v2pub.edi_rec_type := p_edi_rec;
13436  telex_rec       hz_contact_point_v2pub.telex_rec_type := p_telex_rec;
13437  web_rec         hz_contact_point_v2pub.web_rec_type := p_web_rec ;
13438 
13439 begin
13440    SELECT  hz_contact_points_s.nextval into x_contact_point_id from dual;
13441 
13442   cpoint_rec.contact_point_id       := x_contact_point_id;
13443   cpoint_rec.orig_system_reference  := x_contact_point_id;
13444   cpoint_rec.CREATED_BY_MODULE      := 'AMS_LIST_IMPORT';
13445   cpoint_rec.application_id      := 530;
13446   hz_contact_point_v2pub.create_contact_point(
13447                    'F',
13448                    cpoint_rec,
13449                    edi_rec,
13450                    email_rec,
13451                    phone_rec,
13452                    telex_rec,
13453                    web_rec,
13454                    x_contact_point_id,
13455                    x_return_status,
13456                    x_msg_count,
13457                    x_msg_data);
13458 
13459 end create_contact_point;
13460 -- ---------------------------------------------------------------------
13461 --
13462 -- This procedure is used for existence checking for address.
13463 --
13464 --
13465 PROCEDURE address_echeck(
13466    p_party_id              IN       NUMBER,
13467    x_return_status      OUT NOCOPY    VARCHAR2,
13468    x_msg_count          OUT NOCOPY    NUMBER,
13469    x_msg_data           OUT NOCOPY    VARCHAR2,
13470    p_location_id           IN OUT NOCOPY   NUMBER,
13471    p_address1              IN       VARCHAR2,
13472    p_city                  IN       VARCHAR2,
13473    p_pcode                 IN       VARCHAR2,
13474    p_country               IN       VARCHAR2
13475                        ) is
13476 
13477 l_address_key       varchar(1000);
13478 l_loc_id            number;
13479 l_ret_status        varchar(1);
13480 
13481 
13482 cursor c_addr_ps is
13483        select max(loc.location_id)
13484        from  hz_party_sites ps, hz_locations loc
13485        where ps.party_id          = p_party_id
13486          and ps.location_id       = loc.location_id
13487          and loc.address_key      = l_address_key
13488          and loc.country          = p_country
13489          and nvl(loc.city,nvl(p_city,'x')) = nvl(p_city,'x');
13490 
13491 cursor c_addr is
13492        select max(loc.location_id)
13493        from   hz_locations loc
13494        where  loc.address_key     = l_address_key
13495          and loc.country          = p_country
13496          and nvl(loc.city,nvl(p_city,'x')) = nvl(p_city,'x');
13497 
13498 begin
13499  x_return_status := FND_API.g_ret_sts_success;
13500       l_address_key := hz_fuzzy_pub.Generate_Key (
13501                                 p_key_type => 'ADDRESS',
13502                                 p_address1 =>  p_address1,
13503                                 p_postal_code => p_pcode
13504                                );
13505 
13506       open c_addr_ps;
13507       fetch c_addr_ps into l_loc_id;
13508       close c_addr_ps;
13509       if l_loc_id is null then
13510          open c_addr;
13511          fetch c_addr into l_loc_id;
13512          close c_addr;
13513       end if;
13514       p_location_id := l_loc_id;
13515  exception
13516      when others then
13517       x_return_status := FND_API.g_ret_sts_unexp_error ;
13518       IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
13519          FND_MSG_PUB.add_exc_msg(g_pkg_name,'address_echeck');
13520       END IF;
13521       FND_MSG_PUB.count_and_get(
13522             p_encoded => FND_API.g_false,
13523             p_count   => x_msg_count,
13524             p_data    => x_msg_data
13525       );
13526 
13527 end address_echeck;
13528 -- --------------------------------------------------
13529 
13530 procedure create_location (
13531         p_location_rec          IN      HZ_LOCATION_v2PUB.LOCATION_REC_TYPE,
13532         x_return_status         OUT NOCOPY     VARCHAR2,
13533         x_msg_count             OUT NOCOPY     NUMBER,
13534         x_msg_data              OUT NOCOPY     VARCHAR2,
13535         x_location_id           OUT NOCOPY     NUMBER
13536 ) IS
13537 
13538 location_rec    hz_location_v2pub.location_rec_type := p_location_rec;
13539 
13540 BEGIN
13541 
13542    select hr_locations_s.nextval into x_location_id from dual;
13543    location_rec.location_id           := x_location_Id;
13544    location_rec.orig_system_reference := x_location_id ;
13545    location_rec.CREATED_BY_MODULE := 'AMS_LIST_IMPORT';
13546    location_rec.application_id := 530;
13547 
13548        hz_location_v2pub.create_location(
13549         'F',
13550         location_rec,
13551         x_location_id,
13552         x_return_status,
13553         x_msg_count,
13554         x_msg_data
13555         );
13556 
13557 end create_location;
13558 
13559 -- --------------------------------------------------------
13560 
13561 procedure create_party_site (
13562         p_psite_rec             IN      hz_party_site_v2pub.party_site_rec_type,
13563         x_return_status         OUT NOCOPY     VARCHAR2,
13564         x_msg_count             OUT NOCOPY     NUMBER,
13565         x_msg_data              OUT NOCOPY     VARCHAR2,
13566         x_party_site_id         OUT NOCOPY     NUMBER,
13567         x_party_site_number     OUT NOCOPY     VARCHAR2
13568 ) IS
13569 
13570 x_gen_party_site_number       VARCHAR2(1);
13571 psite_rec       hz_party_site_v2pub.party_site_rec_type := p_psite_rec;
13572 
13573 begin
13574   x_gen_party_site_number := fnd_profile.value('HZ_GENERATE_PARTY_SITE_NUMBER');
13575   x_party_site_number := null;
13576    select hz_party_sites_s.nextval into x_party_site_id from dual;
13577    if x_gen_party_site_number = 'N' then
13578        select hz_party_site_number_s.nextval into x_party_site_number from dual;
13579    end if;
13580 
13581   psite_rec.party_site_id            := x_party_site_id;
13582   psite_rec.party_site_number        := x_party_site_number;
13583   psite_rec.orig_system_reference    := x_party_site_id;
13584   psite_rec.CREATED_BY_MODULE        := 'AMS_LIST_IMPORT';
13585   psite_rec.application_id := 530;
13586 /*
13587   hz_party_pub.create_party_site(
13588                 1,
13589                 'T',
13590                 'F',
13591                 psite_rec,
13592                 x_return_status,
13593                 x_msg_count,
13594                 x_msg_data,
13595                 x_party_site_id,
13596                 x_party_site_number
13597                 );
13598 */
13599   hz_party_site_v2pub.create_party_site(
13600                 'F',
13601                 psite_rec,
13602                 x_party_site_id,
13603                 x_party_site_number,
13604                 x_return_status,
13605                 x_msg_count,
13606                 x_msg_data
13607                 );
13608 end create_party_site;
13609 -- -------------------------------------------------------
13610 
13611 PROCEDURE client_load_direct (
13612                       p_import_list_header_id  IN NUMBER,
13613                       p_owner_user_id          IN NUMBER,
13614                       p_generate_list          IN    VARCHAR2 ,
13615                       p_list_name              IN    VARCHAR2   -- For list generation name.
13616                      ) IS
13617    l_import_type        VARCHAR2(30);
13618    l_msg_code           NUMBER;
13619    l_msg_buf            VARCHAR2(4000);
13620    l_batch_id           NUMBER;
13621    l_lookup_code        VARCHAR2(30);
13622    l_return_status      VARCHAR2(1);
13623    i_return_status      VARCHAR2(1);
13624    l_dedupe_flag        VARCHAR2(1);
13625    l_validate_file      VARCHAR2(1);
13626    i_msg_data           VARCHAR2(2000);
13627    i_msg_buf            VARCHAR2(4000);
13628    i_msg_count          NUMBER;
13629    l_list_header_id     NUMBER;
13630    l_duplicate_records  NUMBER;
13631    l_user_status_id     NUMBER;
13632 
13633    x_rstatus         VARCHAR2(1);
13634    x_mdata           VARCHAR2(2000);
13635    x_mcount          NUMBER;
13636 
13637    l_lead_status        VARCHAR2(30);
13638    i_processed_records  NUMBER;
13639    i_failed_records     NUMBER;
13640    l_request_id         NUMBER;
13641    l_conc_prog_name     VARCHAR2(60);
13642    l_finish_status      VARCHAR2(30);
13643    l_status_code        VARCHAR2(30);
13644 
13645    l_error_exist        VARCHAR2(1);
13646    l_execute_mode       VARCHAR2(1);
13647    l_rec_in_stag_tab    VARCHAR2(1);
13648    l_loaded_records     NUMBER;
13649    l_failed_records     NUMBER;
13650    l_string         VARCHAR2(4000);
13651    l_program        varchar2(100);
13652    l_file_type        VARCHAR2(30);
13653    l_loaded_rows        NUMBER;
13654    l_rec_update_flag    VARCHAR2(1);
13655    x_tmp_var                  	VARCHAR2(4000);
13656    x_tmp_var1                 	VARCHAR2(4000);
13657 L_TOTAL_RECORDS      NUMBER;
13658    l_numb_of_inst       number;
13659    x_hz_dup_check  VARCHAR2(60);
13660    l_b2b_flag           VARCHAR2(1);
13661    x_import_list_header_id number;
13662    X_RETURN_STATUS      VARCHAR2(1);
13663    x_msg_count 		NUMBER;
13664    x_msg_data           VARCHAR2(2000);
13665    l_osr_mapped		VARCHAR2(1);
13666 
13667 L_MESG_TEXT             varchar2(2000);
13668 
13669    cursor c_import_type is
13670    select import_type, dedupe_flag, nvl(VALIDATE_FILE,'N'),status_code,EXECUTE_MODE,nvl(RECORD_UPDATE_FLAG,'N')
13671    ,nvl(NUMBER_OF_INSTANCES,1) from ams_imp_list_headers_all
13672    where import_list_header_id = p_import_list_header_id;
13673 
13674    cursor c_dup_recs is
13675           select count(*) from ams_imp_source_lines
13676           where import_list_header_id = p_import_list_header_id
13677             and duplicate_flag = 'Y';
13678 
13679    cursor c_event_status is
13680    select nvl(PROCESSED_ROWS,0), nvl(NUMBER_OF_FAILED_RECORDS,0)
13681    from ams_imp_list_headers_all
13682    where import_list_header_id = p_import_list_header_id;
13683 
13684   cursor c_conc_name is
13685    SELECT concurrent_program FROM ams_imp_list_import_types
13686    where  import_type = 'LEAD';
13687 
13688  cursor c_error_exist is
13689    select 'Y' from ams_list_import_errors
13690    where import_list_header_id = p_import_list_header_id
13691      and error_type = 'E'
13692      and rownum < 2;
13693 
13694   cursor c_rec_in_stag_tab is
13695   select 'Y' from ams_imp_source_lines
13696   where import_list_header_id = p_import_list_header_id
13697     and load_status in ('ACTIVE','RELOAD')
13698     and rownum < 2;
13699 
13700   cursor c_rec_in_xml_stag_tab is
13701   select 'Y' from ams_imp_xml_elements e, ams_imp_documents d
13702   where d.import_list_header_id = p_import_list_header_id
13703     and d.imp_document_id = e.imp_xml_document_id
13704     and e.load_status in ('ACTIVE','RELOAD')
13705     and rownum < 2;
13706 
13707  cursor c_loaded_records is
13708    select count(*) from ams_imp_source_lines
13709    where import_list_header_id = p_import_list_header_id
13710      and load_status = G_STATUS_SUCCESS;
13711 
13712  cursor c_failed_records is
13713    select count(*) from ams_imp_source_lines
13714    where import_list_header_id = p_import_list_header_id
13715      and load_status = G_STATUS_ERROR;
13716 
13717   cursor c_prog_name (x_imp_type varchar2) is
13718    SELECT concurrent_program FROM ams_imp_list_import_types
13719    where  import_type = x_imp_type;
13720 
13721 cursor c_file_type is
13722  select file_type from ams_imp_documents where import_list_header_id = p_import_list_header_id;
13723 
13724  cursor c_total_records is
13725    select count(*) from ams_imp_source_lines
13726    where import_list_header_id = p_import_list_header_id
13727      and load_status in ('ACTIVE','RELOAD');
13728 
13729 -- For Mapped osr
13730 cursor osr_mapped is
13731 SELECT 'Y'  FROM ams_list_src_fields sf,
13732 ams_imp_list_headers_all hd
13733 WHERE sf.field_column_name = 'ORIG_SYSTEM_REFERENCE'
13734   AND sf.enabled_flag = 'Y'
13735   AND sf.list_source_type_id = hd.list_source_type_id
13736   and hd.import_type in ('B2B','B2C')
13737   AND hd.import_list_header_id = p_import_list_header_id;
13738 
13739 begin
13740    x_import_list_header_id := p_import_list_header_id;
13741    x_hz_dup_check          := fnd_profile.value('AMS_HZ_DEDUPE_RULE');
13742    if x_hz_dup_check <> 'Y' then
13743     x_hz_dup_check := 'N';
13744    end if;
13745 
13746    open  c_import_type;
13747    fetch c_import_type into l_import_type, l_dedupe_flag,l_validate_file,l_status_code,l_execute_mode,
13748                             l_rec_update_flag,l_numb_of_inst;
13749    close c_import_type;
13750    open  c_conc_name;
13751    fetch c_conc_name into l_conc_prog_name;
13752    close c_conc_name;
13753    open osr_mapped;
13754    fetch osr_mapped into l_osr_mapped;
13755    close osr_mapped;
13756 
13757    open c_file_type;
13758    fetch c_file_type into l_file_type;
13759    close c_file_type;
13760    if l_file_type = 'CSV' then
13761    	open c_rec_in_stag_tab;
13762    	fetch c_rec_in_stag_tab into l_rec_in_stag_tab;
13763    	close c_rec_in_stag_tab;
13764    end if;
13765    if l_file_type = 'XML' then
13766    	open c_rec_in_xml_stag_tab;
13767    	fetch c_rec_in_xml_stag_tab into l_rec_in_stag_tab;
13768    	close c_rec_in_xml_stag_tab;
13769    end if;
13770    if l_rec_in_stag_tab is NULL then
13771      AMS_Utility_PVT.Create_Log (
13772          x_return_status   => l_return_status,
13773          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13774          p_log_used_by_id  => p_import_list_header_id,
13775          p_msg_data        => 'Aborting import process, Staging table not populated.',
13776          p_msg_type        => 'DEBUG'
13777        );
13778        l_lookup_code := 'ERROR';
13779                 l_user_status_id := null;
13780                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
13781                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
13782                 system_status_code = 'ERROR' and default_flag = 'Y';
13783 
13784                 UPDATE ams_imp_list_headers_all
13785                 set status_code       =  l_lookup_code,
13786                 user_status_id    =  l_user_status_id,
13787                 status_date       =  sysdate
13788                 where import_list_header_id = p_import_list_header_id;
13789       return;
13790    end if;
13791 -- ------------------------------------------------------
13792 -- ------------RAISE PRE BUSINESS EVENT START ---------------------
13793 
13794               Raise_Business_event(p_import_list_header_id,
13795                                         'oracle.apps.ams.list.ListImportPreEvent');
13796 
13797 -- ------------RAISE PRE BUSINESS EVENT END ---------------------
13798 -- ------------------------------------------------------
13799     if l_execute_mode = 'R' then
13800          l_lookup_code := 'STAGED';
13801          l_status_code := 'STAGED';
13802          l_user_status_id := null;
13803          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
13804          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
13805          system_status_code = 'STAGED' and default_flag = 'Y';
13806 
13807          select as_import_interface_s.nextval into l_batch_id from dual;
13808 
13809          UPDATE ams_imp_list_headers_all
13810          set status_code      =  l_lookup_code,
13811             user_status_id    =  l_user_status_id,
13812             batch_id          =  l_batch_id,
13813             status_date       =  sysdate
13814          where import_list_header_id = p_import_list_header_id;
13815 
13816          UPDATE ams_imp_source_lines
13817             set batch_id          =  l_batch_id,
13818                 request_id        =  NULL
13819          where import_list_header_id = p_import_list_header_id
13820            and load_status in ('RELOAD','ACTIVE');
13821 
13822               AMS_Utility_PVT.Create_Log (
13823               x_return_status   => l_return_status,
13824               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13825               p_log_used_by_id  => p_import_list_header_id,
13826               p_msg_data        => 'Starting List Import in RELOAD Mode.',
13827               p_msg_type        => 'DEBUG'
13828               );
13829     end if;
13830 
13831       AMS_Utility_PVT.Create_Log (
13832          x_return_status   => l_return_status,
13833          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13834          p_log_used_by_id  => p_import_list_header_id,
13835          p_msg_data        => 'Starting Import process.',
13836          p_msg_type        => 'DEBUG'
13837        );
13838 
13839    if (l_import_type = 'B2B' or l_import_type = 'B2C') then
13840     if l_status_code = 'STAGED' then
13841       if l_file_type = 'XML' and l_execute_mode  <> 'R' then
13842  	Process_customers_xml (
13843     	1, -- p_api_version_number
13844     	FND_API.G_FALSE , -- p_init_msg_list
13845     	FND_API.G_FALSE , -- p_commit
13846     	FND_API.G_VALID_LEVEL_FULL, -- p_validation_level
13847     	x_rstatus          ,
13848     	x_mcount              ,
13849     	x_mdata               ,
13850     	p_import_list_header_id ,
13851     	l_rec_update_flag   -- p_update_flag
13852         );
13853         if x_mcount > 1 then
13854           FOR i IN 1..x_mcount  LOOP
13855          	x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
13856                 x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
13857     	  END LOOP;
13858     	x_mdata := x_tmp_var1;
13859   	END IF;
13860     	if x_rstatus <> 'S' then
13861         	AMS_Utility_PVT.Create_Log (
13862          	x_return_status   => l_return_status,
13863          	p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13864          	p_log_used_by_id  => p_import_list_header_id,
13865          	p_msg_data        => 'Error while executing Process_customers_xml process.',
13866          	p_msg_type        => 'DEBUG'
13867         	);
13868       		AMS_List_Import_PUB.error_capture (
13869         	1,
13870         	'T',
13871         	'F',
13872         	null,
13873         	x_rstatus,
13874         	x_mcount,
13875         	x_mdata,
13876         	p_import_list_header_id,
13877         	null, -- i_import_source_line_id,
13878         	null,
13879         	null,
13880                 null,
13881         	null,
13882         	substr(x_mdata,1,2000));
13883     	end if;
13884       end if;
13885       UPDATE ams_imp_list_headers_all
13886         set status_code       =  'SCHEDULED',
13887             loaded_date       =  sysdate,
13888             status_date       =  sysdate
13889       where import_list_header_id = p_import_list_header_id;
13890            open c_total_records;
13891            fetch c_total_records into l_total_records;
13892            close c_total_records;
13893              AMS_Utility_PVT.Create_Log (
13894                   x_return_status   => l_return_status,
13895                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13896                   p_log_used_by_id  => p_import_list_header_id,
13897               p_msg_data  => 'Total Number of records available for processing: '||to_char(l_total_records),
13898                   p_msg_type        => 'DEBUG'
13899                 );
13900 
13901 -- ****************************************************8
13902     if l_dedupe_flag = 'Y' then
13903               AMS_Utility_PVT.Create_Log (
13904               x_return_status   => l_return_status,
13905               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13906               p_log_used_by_id  => p_import_list_header_id,
13907               p_msg_data        => 'Starting De-Duplicate check in the Marketing tables .',
13908               p_msg_type        => 'DEBUG'
13909               );
13910 
13911               dedup_check( p_import_list_header_id);
13912 
13913               open c_dup_recs;
13914               fetch c_dup_recs into l_duplicate_records;
13915               close c_dup_recs;
13916               update ams_imp_list_headers_all
13917               set number_of_duplicate_records = l_duplicate_records
13918               where import_list_header_id = p_import_list_header_id;
13919 
13920               AMS_Utility_PVT.Create_Log (
13921               x_return_status   => l_return_status,
13922               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13923               p_log_used_by_id  => p_import_list_header_id,
13924               p_msg_data        => 'END De-Duplicate check in the Marketing tables .',
13925               p_msg_type        => 'DEBUG'
13926               );
13927     end if;
13928 -- ****************************************************8
13929               AMS_Utility_PVT.Create_Log (
13930               x_return_status   => l_return_status,
13931               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13932               p_log_used_by_id  => p_import_list_header_id,
13933               p_msg_data        => 'Start gen_transposed_phone_number.',
13934               p_msg_type        => 'DEBUG'
13935               );
13936 
13937         gen_transposed_phone_number( x_import_list_header_id, x_return_status,
13938                                      x_msg_count, x_msg_data );
13939               AMS_Utility_PVT.Create_Log (
13940               x_return_status   => l_return_status,
13941               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
13942               p_log_used_by_id  => p_import_list_header_id,
13943               p_msg_data        => 'End gen_transposed_phone_number.',
13944               p_msg_type        => 'DEBUG'
13945               );
13946 
13947 if l_import_type = 'B2B' then
13948   --if party_id is provided and if its of type relationship
13949   --update org_party_id and ocont_party_id
13950   update ams_hz_b2b_mapping_v b2b
13951   set (org_party_id, ocont_party_id) = (select object_id, subject_id from hz_relationships
13952   where party_id = b2b.party_id and object_type = 'ORGANIZATION'
13953   and subject_type = 'PERSON' and relationship_type = 'CONTACT'
13954   and nvl(status,'A') = 'A')
13955   where import_list_header_id = p_import_list_header_id
13956   and party_id is not null
13957   and org_party_id is null;
13958 
13959   --if party_id is of type organization then update org_party_id with party_id
13960   update ams_hz_b2b_mapping_v b2b
13961   set org_party_id = (select party_id from hz_parties where party_type = 'ORGANIZATION' and party_id = b2b.party_id and nvl(status,'A') = 'A') -- bug 5100612
13962   where import_list_header_id = p_import_list_header_id
13963   and party_id is not null
13964   and org_party_id is null;
13965 
13966   update ams_hz_b2b_mapping_v
13967   set org_exist = 'Y'
13968   where import_list_header_id = p_import_list_header_id
13969   and org_party_id is not null;
13970 
13971   update ams_hz_b2b_mapping_v
13972   set ocont_exist = 'Y'
13973   where import_list_header_id = p_import_list_header_id
13974   and ocont_party_id is not null;
13975 
13976 elsif l_import_type = 'B2C' then
13977 
13978     --aanjaria: bug 4913239: copy party_id to person_party_id so that existence check is by passed
13979     -- mayjain bug 5100612 this update should be done only if the party_id is a valid one.
13980        UPDATE ams_hz_b2c_mapping_v b2c
13981        SET person_party_id = (select party_id from hz_parties where party_type = 'PERSON' and party_id = b2c.party_id and nvl(status,'A') = 'A') -- bug 5100612,
13982        WHERE import_list_header_id = p_import_list_header_id
13983        AND party_id is not null
13984        AND person_party_id is null;
13985 
13986       -- bug 5100612
13987       UPDATE ams_hz_b2c_mapping_v b2c
13988       SET person_exist = 'Y'
13989       WHERE import_list_header_id = p_import_list_header_id
13990       and person_party_id is not null;
13991 end if;
13992 
13993 commit;
13994 
13995  if x_hz_dup_check = 'Y' then
13996    if l_import_type = 'B2B' then
13997      if l_osr_mapped = 'Y' then
13998               AMS_Utility_PVT.Create_Log (
13999               x_return_status   => l_return_status,
14000               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14001               p_log_used_by_id  => p_import_list_header_id,
14002               p_msg_data        => 'Start org_existence_checking_osr.',
14003               p_msg_type        => 'DEBUG'
14004               );
14005        org_existence_checking_osr(x_import_list_header_id,
14006                           x_return_status,x_msg_count,x_msg_data);
14007               AMS_Utility_PVT.Create_Log (
14008               x_return_status   => l_return_status,
14009               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14010               p_log_used_by_id  => p_import_list_header_id,
14011               p_msg_data        => 'End org_existence_checking_osr.',
14012               p_msg_type        => 'DEBUG'
14013               );
14014      end if;
14015               AMS_Utility_PVT.Create_Log (
14016               x_return_status   => l_return_status,
14017               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14018               p_log_used_by_id  => p_import_list_header_id,
14019               p_msg_data        => 'Start org_existence_checking.',
14020               p_msg_type        => 'DEBUG'
14021               );
14022       org_existence_checking(x_import_list_header_id,
14023                           x_return_status,x_msg_count,x_msg_data);
14024               AMS_Utility_PVT.Create_Log (
14025               x_return_status   => l_return_status,
14026               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14027               p_log_used_by_id  => p_import_list_header_id,
14028               p_msg_data        => 'End org_existence_checking.',
14029               p_msg_type        => 'DEBUG'
14030               );
14031       if x_return_status <> 'S' then
14032 	AMS_Utility_PVT.Create_Log (
14033          x_return_status   => l_return_status,
14034          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14035          p_log_used_by_id  => p_import_list_header_id,
14036          p_msg_data        => 'Aborting org_existence_checking.',
14037          p_msg_type        => 'DEBUG');
14038          l_lookup_code := 'ERROR';
14039                 l_user_status_id := null;
14040                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14041                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14042                 system_status_code = 'ERROR'  and default_flag = 'Y';
14043 
14044                 UPDATE ams_imp_list_headers_all
14045                 set status_code       =  l_lookup_code,
14046                 user_status_id    =  l_user_status_id,
14047                 status_date       =  sysdate
14048                 where import_list_header_id = p_import_list_header_id;
14049          return;
14050       end if;
14051      if l_osr_mapped = 'Y' then
14052               AMS_Utility_PVT.Create_Log (
14053               x_return_status   => l_return_status,
14054               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14055               p_log_used_by_id  => p_import_list_header_id,
14056               p_msg_data        => 'Start org_cont_existence_chk_osr.',
14057               p_msg_type        => 'DEBUG'
14058               );
14059       org_cont_existence_chk_osr(x_import_list_header_id,
14060                           x_return_status,x_msg_count,x_msg_data);
14061               AMS_Utility_PVT.Create_Log (
14062               x_return_status   => l_return_status,
14063               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14064               p_log_used_by_id  => p_import_list_header_id,
14065               p_msg_data        => 'End org_cont_existence_chk_osr.',
14066               p_msg_type        => 'DEBUG'
14067               );
14068      end if;
14069               AMS_Utility_PVT.Create_Log (
14070               x_return_status   => l_return_status,
14071               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14072               p_log_used_by_id  => p_import_list_header_id,
14073               p_msg_data        => 'Start org_cont_existence_checking.',
14074               p_msg_type        => 'DEBUG'
14075               );
14076       org_cont_existence_checking(x_import_list_header_id,
14077                           x_return_status,x_msg_count,x_msg_data);
14078               AMS_Utility_PVT.Create_Log (
14079               x_return_status   => l_return_status,
14080               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14081               p_log_used_by_id  => p_import_list_header_id,
14082               p_msg_data        => 'End org_cont_existence_checking.',
14083               p_msg_type        => 'DEBUG'
14084               );
14085       if x_return_status <> 'S' then
14086 	AMS_Utility_PVT.Create_Log (
14087          x_return_status   => l_return_status,
14088          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14089          p_log_used_by_id  => p_import_list_header_id,
14090          p_msg_data        => 'Aborting org_cont_existence_checking.',
14091          p_msg_type        => 'DEBUG');
14092          l_lookup_code := 'ERROR';
14093                 l_user_status_id := null;
14094                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14095                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14096                 system_status_code = 'ERROR' and default_flag = 'Y';
14097 
14098                 UPDATE ams_imp_list_headers_all
14099                 set status_code       =  l_lookup_code,
14100                 user_status_id    =  l_user_status_id,
14101                 status_date       =  sysdate
14102                 where import_list_header_id = p_import_list_header_id;
14103          return;
14104       end if;
14105               AMS_Utility_PVT.Create_Log (
14106               x_return_status   => l_return_status,
14107               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14108               p_log_used_by_id  => p_import_list_header_id,
14109               p_msg_data        => 'Start org_address_existence_checking.',
14110               p_msg_type        => 'DEBUG'
14111               );
14112       org_address_existence_checking(x_import_list_header_id,
14113                           x_return_status,x_msg_count,x_msg_data);
14114               AMS_Utility_PVT.Create_Log (
14115               x_return_status   => l_return_status,
14116               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14117               p_log_used_by_id  => p_import_list_header_id,
14118               p_msg_data        => 'End org_address_existence_checking.',
14119               p_msg_type        => 'DEBUG'
14120               );
14121       if x_return_status <> 'S' then
14122 	AMS_Utility_PVT.Create_Log (
14123          x_return_status   => l_return_status,
14124          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14125          p_log_used_by_id  => p_import_list_header_id,
14126          p_msg_data        => 'Aborting org_address_existence_checking.',
14127          p_msg_type        => 'DEBUG');
14128          l_lookup_code := 'ERROR';
14129                 l_user_status_id := null;
14130                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14131                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14132                 system_status_code = 'ERROR' and default_flag = 'Y';
14133 
14134                 UPDATE ams_imp_list_headers_all
14135                 set status_code       =  l_lookup_code,
14136                 user_status_id    =  l_user_status_id,
14137                 status_date       =  sysdate
14138                 where import_list_header_id = p_import_list_header_id;
14139          return;
14140       end if;
14141               AMS_Utility_PVT.Create_Log (
14142               x_return_status   => l_return_status,
14143               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14144               p_log_used_by_id  => p_import_list_header_id,
14145               p_msg_data        => 'Start org_address1_exist_checking.',
14146               p_msg_type        => 'DEBUG'
14147               );
14148       org_address1_exist_checking(x_import_list_header_id,
14149                           x_return_status,x_msg_count,x_msg_data);
14150               AMS_Utility_PVT.Create_Log (
14151               x_return_status   => l_return_status,
14152               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14153               p_log_used_by_id  => p_import_list_header_id,
14154               p_msg_data        => 'End org_address1_exist_checking.',
14155               p_msg_type        => 'DEBUG'
14156               );
14157       if x_return_status <> 'S' then
14158         AMS_Utility_PVT.Create_Log (
14159          x_return_status   => l_return_status,
14160          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14161          p_log_used_by_id  => p_import_list_header_id,
14162          p_msg_data        => 'Aborting org_address1_exist_checking.',
14163          p_msg_type        => 'DEBUG');
14164          l_lookup_code := 'ERROR';
14165                 l_user_status_id := null;
14166                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14167                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14168                 system_status_code = 'ERROR' and default_flag = 'Y';
14169                 UPDATE ams_imp_list_headers_all
14170                 set status_code       =  l_lookup_code,
14171                 user_status_id    =  l_user_status_id,
14172                 status_date       =  sysdate
14173                 where import_list_header_id = p_import_list_header_id;
14174          return;
14175       end if;
14176 
14177     ELSE
14178 
14179      if l_osr_mapped = 'Y' then
14180               AMS_Utility_PVT.Create_Log (
14181               x_return_status   => l_return_status,
14182               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14183               p_log_used_by_id  => p_import_list_header_id,
14184               p_msg_data        => 'Start per_existence_checking.',
14185               p_msg_type        => 'DEBUG'
14186               );
14187       per_existence_checking_osr(x_import_list_header_id,
14188                           x_return_status,x_msg_count,x_msg_data);
14189               AMS_Utility_PVT.Create_Log (
14190               x_return_status   => l_return_status,
14191               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14192               p_log_used_by_id  => p_import_list_header_id,
14193               p_msg_data        => 'End per_existence_checking.',
14194               p_msg_type        => 'DEBUG'
14195               );
14196      end if;
14197               AMS_Utility_PVT.Create_Log (
14198               x_return_status   => l_return_status,
14199               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14200               p_log_used_by_id  => p_import_list_header_id,
14201               p_msg_data        => 'Start per_existence_checking.',
14202               p_msg_type        => 'DEBUG'
14203               );
14204       per_existence_checking(x_import_list_header_id,
14205                           x_return_status,x_msg_count,x_msg_data);
14206               AMS_Utility_PVT.Create_Log (
14207               x_return_status   => l_return_status,
14208               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14209               p_log_used_by_id  => p_import_list_header_id,
14210               p_msg_data        => 'End  per_existence_checking.',
14211               p_msg_type        => 'DEBUG'
14212               );
14213       if x_return_status <> 'S' then
14214 	AMS_Utility_PVT.Create_Log (
14215          x_return_status   => l_return_status,
14216          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14217          p_log_used_by_id  => p_import_list_header_id,
14218          p_msg_data        => 'Aborting per_existence_checking.',
14219          p_msg_type        => 'DEBUG');
14220          l_lookup_code := 'ERROR';
14221                 l_user_status_id := null;
14222                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14223                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14224                 system_status_code = 'ERROR' and default_flag = 'Y';
14225 
14226                 UPDATE ams_imp_list_headers_all
14227                 set status_code       =  l_lookup_code,
14228                 user_status_id    =  l_user_status_id,
14229                 status_date       =  sysdate
14230                 where import_list_header_id = p_import_list_header_id;
14231          return;
14232       end if;
14233               AMS_Utility_PVT.Create_Log (
14234               x_return_status   => l_return_status,
14235               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14236               p_log_used_by_id  => p_import_list_header_id,
14237               p_msg_data        => 'Start per_address_existence_checking.',
14238               p_msg_type        => 'DEBUG'
14239               );
14240       per_address_existence_checking(x_import_list_header_id,
14241                           x_return_status,x_msg_count,x_msg_data);
14242               AMS_Utility_PVT.Create_Log (
14243               x_return_status   => l_return_status,
14244               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14245               p_log_used_by_id  => p_import_list_header_id,
14246               p_msg_data        => 'End per_address_existence_checking.',
14247               p_msg_type        => 'DEBUG'
14248               );
14249       if x_return_status <> 'S' then
14250 	AMS_Utility_PVT.Create_Log (
14251          x_return_status   => l_return_status,
14252          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14253          p_log_used_by_id  => p_import_list_header_id,
14254          p_msg_data        => 'Aborting per_address_existence_checking.',
14255          p_msg_type        => 'DEBUG');
14256          l_lookup_code := 'ERROR';
14257                 l_user_status_id := null;
14258                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14259                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14260                 system_status_code = 'ERROR' and default_flag = 'Y';
14261 
14262                 UPDATE ams_imp_list_headers_all
14263                 set status_code       =  l_lookup_code,
14264                 user_status_id    =  l_user_status_id,
14265                 status_date       =  sysdate
14266                 where import_list_header_id = p_import_list_header_id;
14267          return;
14268       end if;
14269 
14270    end if;
14271 end if ; --  if x_hz_dup_check = 'Y' then
14272 -- >>>>>>>>>>>>>>>
14273 
14274 -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14275         -- Call the Validate Process
14276         if l_validate_file = 'Y' then
14277              AMS_Utility_PVT.Create_Log (
14278                   x_return_status   => l_return_status,
14279                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14280                   p_log_used_by_id  => p_import_list_header_id,
14281                   p_msg_data        => 'Starting Validation for CUSTOMER data.',
14282                   p_msg_type        => 'DEBUG'
14283                 );
14284        -- Delete all the errors from the errors table which are reloaded.
14285                  delete from ams_list_import_errors where import_list_header_id
14286                 = p_import_list_header_id and import_source_line_id = 0;
14287                 delete from ams_list_import_errors where import_list_header_id
14288                 = p_import_list_header_id and import_source_line_id in
14289                 (select import_source_line_id from ams_imp_source_lines where
14290                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_RELOAD);
14291                 if l_file_type = 'XML' then
14292                      update_xml_error_text (
14293                                         p_import_list_header_id,
14294                                         l_import_type);
14295                 end if;
14296                 l_return_status := null;
14297                 execute_cust_data_validation ( p_import_list_header_id, l_return_status);
14298              if l_return_status <> 'S' then
14299               AMS_Utility_PVT.Create_Log (
14300                   x_return_status   => l_return_status,
14301                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14302                   p_log_used_by_id  => p_import_list_header_id,
14303                   p_msg_data        => 'Customer import terminated because of error in Data validation process.',
14304                   p_msg_type        => 'DEBUG'
14305                 );
14306 
14307                 l_lookup_code := 'ERROR';
14308                 l_user_status_id := null;
14309                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14310                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14311                 system_status_code = 'ERROR' and default_flag = 'Y';
14312 
14313                 UPDATE ams_imp_list_headers_all
14314                 set status_code       =  l_lookup_code,
14315                 user_status_id    =  l_user_status_id,
14316                 status_date       =  sysdate
14317                 where import_list_header_id = p_import_list_header_id;
14318                 return;
14319              end if;
14320 -- ((((((((((((((((((((((((((((((((((((((((((((((
14321    	    if l_file_type = 'XML' then
14322                 l_return_status := null;
14323                 exe_custxml_data_validation ( p_import_list_header_id, l_return_status);
14324              if l_return_status <> 'S' then
14325               AMS_Utility_PVT.Create_Log (
14326                   x_return_status   => l_return_status,
14327                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14328                   p_log_used_by_id  => p_import_list_header_id,
14329                   p_msg_data        => 'Customer import terminated because of error in XML Data validation process.',
14330                   p_msg_type        => 'DEBUG'
14331                 );
14332                 l_lookup_code := 'ERROR';
14333                 l_user_status_id := null;
14334                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14335                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14336                 system_status_code = 'ERROR' and default_flag = 'Y';
14337 
14338                 UPDATE ams_imp_list_headers_all
14339                 set status_code       =  l_lookup_code,
14340                 user_status_id    =  l_user_status_id,
14341                 status_date       =  sysdate
14342                 where import_list_header_id = p_import_list_header_id;
14343                 return;
14344              end if;
14345 	    end if;
14346 -- ((((((((((((((((((((((((((((((((((((((((((((((
14347 
14348              AMS_Utility_PVT.Create_Log (
14349                   x_return_status   => l_return_status,
14350                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14351                   p_log_used_by_id  => p_import_list_header_id,
14352                   p_msg_data        => 'End Validation for CUSTOMER data.',
14353                   p_msg_type        => 'DEBUG'
14354                 );
14355         end if;
14356 
14357       AMS_Utility_PVT.Create_Log (
14358          x_return_status   => l_return_status,
14359          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14360          p_log_used_by_id  => p_import_list_header_id,
14361          p_msg_data        => 'Starting client load for TCA.',
14362          p_msg_type        => 'DEBUG'
14363        );
14364 
14365 -- sranka 3/21/2003
14366 -- made changes for "EMPLOYEE_OF" support
14367        execute_reltnship_validation( p_import_list_header_id, l_return_status);
14368            l_total_records := 0;
14369            open c_total_records;
14370            fetch c_total_records into l_total_records;
14371            close c_total_records;
14372            if l_total_records = 0 then
14373                 update_cust_import_status(p_import_list_header_id);
14374                 return;
14375            end if;
14376 
14377        -- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..
14378       l_request_id := FND_REQUEST.SUBMIT_REQUEST (
14379                       application       => 'AMS',
14380                       program           => 'AMSILHZC',
14381                       argument1         => p_import_list_header_id,
14382                       argument2         => l_numb_of_inst
14383                    );
14384 
14385            AMS_Utility_PVT.Create_Log (
14386            x_return_status   => l_return_status,
14387            p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14388            p_log_used_by_id  => p_import_list_header_id,
14389            p_msg_data        => 'Starting TCA program (AMSILHZC) -- concurrent program_id is '||to_char(l_request_id),
14390            p_msg_type        => 'DEBUG');
14391 
14392      IF l_request_id = 0 THEN
14393            AMS_Utility_PVT.Create_Log (
14394            x_return_status   => l_return_status,
14395            p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14396            p_log_used_by_id  => p_import_list_header_id,
14397            p_msg_data        => 'Error in (AMSILHZC) -- concurrent program_id is '||to_char(l_request_id),
14398            p_msg_type        => 'DEBUG');
14399 	                  l_mesg_text := fnd_message.get;
14400                AMS_Utility_PVT.Create_Log (
14401                 x_return_status   => l_return_status,
14402                 p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14403                 p_log_used_by_id  => p_import_list_header_id,
14404                 p_msg_data        => l_mesg_text,
14405                 p_msg_type        => 'DEBUG' );
14406 
14407                 l_user_status_id := null;
14408                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14409                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14410                 system_status_code = 'ERROR' and default_flag = 'Y';
14411                 UPDATE ams_imp_list_headers_all
14412                 set status_code       =  l_lookup_code,
14413                 user_status_id    =  l_user_status_id,
14414                 status_date       =  sysdate
14415                 where import_list_header_id = p_import_list_header_id;
14416                 commit;
14417 
14418           RAISE FND_API.g_exc_unexpected_error;
14419      end if;
14420 
14421 -- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..
14422 /*
14423        list_import_to_hz (
14424                             l_msg_buf,
14425                             l_msg_code,
14426                             p_import_list_header_id
14427                          );
14428 */
14429       AMS_Utility_PVT.Create_Log (
14430          x_return_status   => l_return_status,
14431          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14432          p_log_used_by_id  => p_import_list_header_id,
14433          p_msg_data        => 'End client load for TCA.',
14434          p_msg_type        => 'DEBUG'
14435        );
14436 
14437  /*
14438        if l_msg_code = 2 then
14439          l_lookup_code := 'ERROR';
14440          l_user_status_id := null;
14441          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14442          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14443          system_status_code = 'ERROR' and default_flag = 'Y';
14444 
14445          UPDATE ams_imp_list_headers_all
14446          set status_code       =  l_lookup_code,
14447             user_status_id    =  l_user_status_id,
14448             status_date       =  sysdate
14449          where import_list_header_id = p_import_list_header_id;
14450        end if;
14451  */
14452      end if; -- STAGED
14453  /*
14454       open c_error_exist;
14455       fetch c_error_exist into l_error_exist;
14456       close c_error_exist;
14457       if l_error_exist = 'Y' then
14458          l_lookup_code := 'ERROR';
14459          l_user_status_id := null;
14460          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14461          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14462          system_status_code = 'ERROR' and default_flag = 'Y';
14463 
14464          UPDATE ams_imp_list_headers_all
14465          set status_code       =  l_lookup_code,
14466             user_status_id    =  l_user_status_id,
14467             status_date       =  sysdate
14468          where import_list_header_id = p_import_list_header_id;
14469       end if;
14470       if l_error_exist is NULL then
14471        l_lookup_code := 'COMPLETED';
14472          l_user_status_id := null;
14473          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14474          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14475          system_status_code = 'COMPLETED' and default_flag = 'Y';
14476 
14477          UPDATE ams_imp_list_headers_all
14478          set status_code       =  l_lookup_code,
14479             user_status_id    =  l_user_status_id,
14480             status_date       =  sysdate
14481          where import_list_header_id = p_import_list_header_id;
14482       end if;
14483 
14484         -- Delete all the errors from the errors table which are sucessful.
14485                 delete from ams_list_import_errors where import_list_header_id
14486                 = p_import_list_header_id and import_source_line_id in
14487                 (select import_source_line_id from ams_imp_source_lines where
14488                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_SUCCESS);
14489      open c_loaded_records;
14490      fetch c_loaded_records into l_loaded_records;
14491      close c_loaded_records;
14492      open c_failed_records;
14493      fetch c_failed_records into l_failed_records;
14494      close c_failed_records;
14495      UPDATE ams_imp_list_headers_all
14496         SET loaded_no_of_rows = l_loaded_records,
14497             number_of_failed_records = l_failed_records,
14498             loaded_date = sysdate
14499       WHERE import_list_header_id = p_import_list_header_id;
14500  */
14501    end if; -- CUSTOMER
14502 /*
14503    if p_generate_list = 'Y' then
14504             AMS_Utility_PVT.Create_Log (
14505               x_return_status   => l_return_status,
14506               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14507               p_log_used_by_id  => p_import_list_header_id,
14508               p_msg_data        => 'Starting List Generation for List Import.',
14509               p_msg_type        => 'DEBUG'
14510               );
14511 
14512               l_loaded_rows := 0;
14513               select LOADED_NO_OF_ROWS into l_loaded_rows from ams_imp_list_headers_all
14514               where import_list_header_id = p_import_list_header_id;
14515 
14516              if l_loaded_rows > 0 then
14517 
14518              AMS_ListGeneration_PKG.create_import_list
14519                 ( 1,
14520                   'T',
14521                   'T',
14522                   FND_API.G_VALID_LEVEL_FULL,
14523                   p_owner_user_id,
14524                   p_import_list_header_id,
14525                   i_return_status,
14526                   i_msg_count,
14527                   i_msg_data,
14528                   l_list_header_id,
14529                   p_list_name) ;
14530 
14531              If i_return_status <> 'S' then
14532               AMS_Utility_PVT.Create_Log (
14533               x_return_status   => l_return_status,
14534               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14535               p_log_used_by_id  => p_import_list_header_id,
14536               p_msg_data        => 'Error in List Generation --'||i_msg_data,
14537               p_msg_type        => 'DEBUG'
14538               );
14539              End if;
14540              end if;
14541              AMS_Utility_PVT.Create_Log (
14542               x_return_status   => l_return_status,
14543               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14544               p_log_used_by_id  => p_import_list_header_id,
14545               p_msg_data        => 'End List Generation for List Import.',
14546               p_msg_type        => 'DEBUG'
14547               );
14548   end if;  -- p_generate_list
14549 
14550 */
14551 --  STARTING CLIENT SIDE LEAD IMPORT --------------
14552 --
14553 --
14554 
14555     if l_import_type = 'LEAD' then
14556      if l_status_code = 'STAGED' then
14557       UPDATE ams_imp_list_headers_all
14558         set status_code       =  'SCHEDULED',
14559             loaded_date       =  sysdate,
14560             status_date       =  sysdate
14561       where import_list_header_id = p_import_list_header_id;
14562         execute_lead_import ( p_import_list_header_id);
14563 /*
14564         l_request_id := FND_REQUEST.SUBMIT_REQUEST (
14565                       application       => 'AMS',
14566                       program           => 'AMSILLDC',
14567                       argument1         => p_import_list_header_id
14568                    );
14569              AMS_Utility_PVT.Create_Log (
14570               x_return_status   => l_return_status,
14571               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14572               p_log_used_by_id  => p_import_list_header_id,
14573              p_msg_data        => 'Starting LEAD data upload program (AMSILLDC) -- concurrent program_id is '||to_char(l_request_id),
14574               p_msg_type        => 'DEBUG'
14575               );
14576          commit;
14577       IF l_request_id = 0 THEN
14578           RAISE FND_API.g_exc_unexpected_error;
14579      end if;
14580 */
14581     end if;
14582    end if;
14583 
14584 --  STARTING CLIENT SIDE EVENT IMPORT --------------
14585 --
14586 --
14587 
14588     if l_import_type = 'EVENT' then
14589      if l_status_code = 'STAGED' then
14590       UPDATE ams_imp_list_headers_all
14591         set status_code       =  'SCHEDULED',
14592             loaded_date       =  sysdate,
14593             status_date       =  sysdate
14594       where import_list_header_id = p_import_list_header_id;
14595 
14596         -- Call the Validate Process
14597         if l_validate_file = 'Y' then
14598              AMS_Utility_PVT.Create_Log (
14599                   x_return_status   => l_return_status,
14600                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14601                   p_log_used_by_id  => p_import_list_header_id,
14602                   p_msg_data        => 'Starting Validation for EVENT data.',
14603                   p_msg_type        => 'DEBUG'
14604                 );
14605        -- Delete all the errors from the errors table which are reloaded.
14606                  delete from ams_list_import_errors where import_list_header_id
14607                 = p_import_list_header_id and import_source_line_id = 0;
14608                 delete from ams_list_import_errors where import_list_header_id
14609                 = p_import_list_header_id and import_source_line_id in
14610                 (select import_source_line_id from ams_imp_source_lines where
14611                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_RELOAD);
14612 
14613                 l_return_status := null;
14614                 execute_event_data_validation ( p_import_list_header_id, l_return_status);
14615              if l_return_status <> 'S' then
14616               AMS_Utility_PVT.Create_Log (
14617                   x_return_status   => l_return_status,
14618                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14619                   p_log_used_by_id  => p_import_list_header_id,
14620                   p_msg_data        => 'EVENT import terminated because of error in Data validation process.',
14621                   p_msg_type        => 'DEBUG'
14622                 );
14623 
14624                 l_lookup_code := 'ERROR';
14625                 l_user_status_id := null;
14626                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14627                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14628                 system_status_code = 'ERROR' and default_flag = 'Y';
14629 
14630                 UPDATE ams_imp_list_headers_all
14631                 set status_code       =  l_lookup_code,
14632                 user_status_id    =  l_user_status_id,
14633                 status_date       =  sysdate
14634                 where import_list_header_id = p_import_list_header_id;
14635                 return;
14636              end if;
14637 
14638              AMS_Utility_PVT.Create_Log (
14639                   x_return_status   => l_return_status,
14640                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14641                   p_log_used_by_id  => p_import_list_header_id,
14642                   p_msg_data        => 'End Validation for Event data.',
14643                   p_msg_type        => 'DEBUG'
14644                 );
14645         end if;
14646 
14647       AMS_Utility_PVT.Create_Log (
14648          x_return_status   => l_return_status,
14649          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14650          p_log_used_by_id  => p_import_list_header_id,
14651          p_msg_data        => 'Starting client load for EVENT.',
14652          p_msg_type        => 'DEBUG'
14653        );
14654        ams_imp_reg_detail_pvt.LoadProcess(
14655                             l_msg_buf,
14656                             l_msg_code,
14657 			    p_import_list_header_id
14658                          );
14659       AMS_Utility_PVT.Create_Log (
14660          x_return_status   => l_return_status,
14661          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14662          p_log_used_by_id  => p_import_list_header_id,
14663          p_msg_data        => 'End client load for EVENT.',
14664          p_msg_type        => 'DEBUG'
14665        );
14666 
14667       open c_error_exist;
14668       fetch c_error_exist into l_error_exist;
14669       close c_error_exist;
14670       if l_error_exist = 'Y' then
14671          l_lookup_code := 'ERROR';
14672          l_user_status_id := null;
14673          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14674          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14675          system_status_code = 'ERROR' and default_flag = 'Y';
14676 
14677          UPDATE ams_imp_list_headers_all
14678          set status_code       =  l_lookup_code,
14679             user_status_id    =  l_user_status_id,
14680             status_date       =  sysdate
14681          where import_list_header_id = p_import_list_header_id;
14682       end if;
14683       if l_error_exist is NULL then
14684        l_lookup_code := 'COMPLETED';
14685          l_user_status_id := null;
14686          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
14687          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
14688          system_status_code = 'COMPLETED' and default_flag = 'Y';
14689 
14690          UPDATE ams_imp_list_headers_all
14691          set status_code       =  l_lookup_code,
14692             user_status_id    =  l_user_status_id,
14693             status_date       =  sysdate
14694          where import_list_header_id = p_import_list_header_id;
14695       end if;
14696     -- Delete all the errors from the errors table which are sucessful.
14697                 delete from ams_list_import_errors where import_list_header_id
14698                 = p_import_list_header_id and import_source_line_id in
14699                 (select import_source_line_id from ams_imp_source_lines where
14700                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_SUCCESS);
14701      open c_loaded_records;
14702      fetch c_loaded_records into l_loaded_records;
14703      close c_loaded_records;
14704      open c_failed_records;
14705      fetch c_failed_records into l_failed_records;
14706      close c_failed_records;
14707 
14708          UPDATE ams_imp_list_headers_all
14709           SET loaded_no_of_rows = l_loaded_records,
14710             number_of_failed_records = l_failed_records,
14711             loaded_date = sysdate
14712          where import_list_header_id = p_import_list_header_id;
14713        -- end if;
14714       end if;
14715     end if;
14716 
14717 
14718 
14719 if (l_import_type = 'EVENT' or l_import_type = 'LEAD')then
14720 
14721            l_total_records := 0;
14722            open c_total_records;
14723            fetch c_total_records into l_total_records;
14724            close c_total_records;
14725              AMS_Utility_PVT.Create_Log (
14726                   x_return_status   => l_return_status,
14727                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14728                   p_log_used_by_id  => p_import_list_header_id,
14729                   p_msg_data  => 'Total Number of records not processed: '||to_char(l_total_records),
14730                   p_msg_type        => 'DEBUG'
14731                 );
14732 END IF;
14733 
14734 -- **********************************************************
14735 
14736 EXCEPTION
14737        WHEN  others THEN
14738         AMS_Utility_PVT.Create_Log (
14739          x_return_status   => l_return_status,
14740          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14741          p_log_used_by_id  => p_import_list_header_id,
14742          p_msg_data        => sqlerrm ,
14743          p_msg_type        => 'DEBUG'
14744         );
14745           raise;
14746 end client_load_direct ;
14747 
14748 
14749 -- -------------------------------------------
14750 PROCEDURE client_load_cm (
14751                       Errbuf          OUT NOCOPY     VARCHAR2,
14752                       Retcode         OUT NOCOPY     VARCHAR2,
14753                       p_import_list_header_id IN    NUMBER,
14754                       p_owner_user_id         IN    NUMBER,
14755                       p_generate_list         IN    VARCHAR2 , -- Used for staged table import.
14756                       p_list_name             IN    VARCHAR2   -- For list generation name.
14757                      ) IS
14758 l_return_status		varchar2(1);
14759 BEGIN
14760                  client_load_direct (
14761                       p_import_list_header_id ,
14762                       p_owner_user_id,
14763                       p_generate_list,
14764                       p_list_name  );
14765 EXCEPTION
14766        WHEN  others THEN
14767         AMS_Utility_PVT.Create_Log (
14768          x_return_status   => l_return_status,
14769          p_arc_log_used_by => G_ARC_IMPORT_HEADER,
14770          p_log_used_by_id  => p_import_list_header_id,
14771          p_msg_data        => sqlerrm ,
14772          p_msg_type        => 'DEBUG'
14773         );
14774           raise;
14775 
14776 end client_load_cm;
14777 
14778 
14779 -- -------------------------------------------------------------
14780 
14781 -- This program performs error checks errors for event import.
14782 
14783 PROCEDURE execute_event_data_validation (
14784                             p_import_list_header_id NUMBER,
14785                             p_return_status OUT NOCOPY     VARCHAR2
14786                             ) IS
14787 
14788 TYPE num_data_set_type_w IS
14789   TABLE OF NUMBER INDEX BY BINARY_INTEGER;
14790 
14791 TYPE varchar2_250_set_type IS
14792         TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
14793 
14794 L_MAX_ROW_COUNT                                 CONSTANT NUMBER := 1000;
14795 l_batch_id						 NUMBER;
14796 x_import_list_header_id				number;
14797 x_import_source_line_id 			number;
14798 l_message					varchar2(100);
14799 l_invalid_number varchar2(4000) ;
14800 l_invalid_size   varchar2(4000) ;
14801 l_null_value     varchar2(4000) ;
14802 l_invalid_src_system     varchar2(4000) ;
14803 l_return_status           			varchar2(1);
14804 l_total_rec	number;
14805 l_source_system	varchar2(60);
14806 l_error_exists  varchar2(1);
14807 
14808 
14809 
14810        l_import_source_line_id                 num_data_set_type_w;
14811        l_import_list_header_id                 num_data_set_type_w;
14812 
14813        l_col1	                               varchar2_250_set_type;
14814        l_col2 	                               varchar2_250_set_type;
14815        l_col3 	                               varchar2_250_set_type;
14816        l_col4 	                               varchar2_250_set_type;
14817        l_col5 	                               varchar2_250_set_type;
14818        l_col6 	                               varchar2_250_set_type;
14819        l_col7 	                               varchar2_250_set_type;
14820        l_col8 	                               varchar2_250_set_type;
14821        l_col9 	                               varchar2_250_set_type;
14822        l_col10 	                               varchar2_250_set_type;
14823        l_col11 	                               varchar2_250_set_type;
14824        l_col12 	                               varchar2_250_set_type;
14825        l_col13 	                               varchar2_250_set_type;
14826        l_col14 	                               varchar2_250_set_type;
14827        l_col15 	                               varchar2_250_set_type;
14828        l_col16 	                               varchar2_250_set_type;
14829        l_col17 	                               varchar2_250_set_type;
14830        l_col18 	                               varchar2_250_set_type;
14831        l_col19 	                               varchar2_250_set_type;
14832        l_col20 	                               varchar2_250_set_type;
14833        l_col21 	                               varchar2_250_set_type;
14834        l_col22 	                               varchar2_250_set_type;
14835        l_col23 	                               varchar2_250_set_type;
14836        l_col24 	                               varchar2_250_set_type;
14837        l_col25 	                               varchar2_250_set_type;
14838        l_col26 	                               varchar2_250_set_type;
14839        l_col27 	                               varchar2_250_set_type;
14840        l_col28 	                               varchar2_250_set_type;
14841        l_col29 	                               varchar2_250_set_type;
14842        l_col30 	                               varchar2_250_set_type;
14843        l_col31 	                               varchar2_250_set_type;
14844        l_col32 	                               varchar2_250_set_type;
14845        l_col33 	                               varchar2_250_set_type;
14846        l_col34 	                               varchar2_250_set_type;
14847        l_col35 	                               varchar2_250_set_type;
14848        l_col36 	                               varchar2_250_set_type;
14849        l_col37 	                               varchar2_250_set_type;
14850        l_col38 	                               varchar2_250_set_type;
14851        l_col39 	                               varchar2_250_set_type;
14852        l_col40 	                               varchar2_250_set_type;
14853        l_col41 	                               varchar2_250_set_type;
14854        l_col42 	                               varchar2_250_set_type;
14855        l_col43 	                               varchar2_250_set_type;
14856        l_col44 	                               varchar2_250_set_type;
14857        l_col45 	                               varchar2_250_set_type;
14858        l_col46 	                               varchar2_250_set_type;
14859        l_col47 	                               varchar2_250_set_type;
14860        l_col48 	                               varchar2_250_set_type;
14861        l_col49 	                               varchar2_250_set_type;
14862        l_col50 	                               varchar2_250_set_type;
14863        l_col51 	                               varchar2_250_set_type;
14864        l_col52 	                               varchar2_250_set_type;
14865        l_col53 	                               varchar2_250_set_type;
14866        l_col54 	                               varchar2_250_set_type;
14867        l_col55 	                               varchar2_250_set_type;
14868        l_col56 	                               varchar2_250_set_type;
14869        l_col57 	                               varchar2_250_set_type;
14870        l_col58 	                               varchar2_250_set_type;
14871        l_col59 	                               varchar2_250_set_type;
14872        l_col60 	                               varchar2_250_set_type;
14873        l_col61 	                               varchar2_250_set_type;
14874        l_col62 	                               varchar2_250_set_type;
14875        l_col63 	                               varchar2_250_set_type;
14876        l_col64 	                               varchar2_250_set_type;
14877        l_col65 	                               varchar2_250_set_type;
14878        l_col66 	                               varchar2_250_set_type;
14879        l_col67 	                               varchar2_250_set_type;
14880        l_col68 	                               varchar2_250_set_type;
14881        l_col69 	                               varchar2_250_set_type;
14882        l_col70 	                               varchar2_250_set_type;
14883        l_col71 	                               varchar2_250_set_type;
14884        l_col72 	                               varchar2_250_set_type;
14885        l_col73 	                               varchar2_250_set_type;
14886        l_col74 	                               varchar2_250_set_type;
14887        l_col75 	                               varchar2_250_set_type;
14888        l_col76 	                               varchar2_250_set_type;
14889        l_col77 	                               varchar2_250_set_type;
14890        l_col78 	                               varchar2_250_set_type;
14891        l_col79 	                               varchar2_250_set_type;
14892        l_col80 	                               varchar2_250_set_type;
14893        l_col81 	                               varchar2_250_set_type;
14894        l_col82 	                               varchar2_250_set_type;
14895        l_col83 	                               varchar2_250_set_type;
14896        l_col84 	                               varchar2_250_set_type;
14897        l_col85 	                               varchar2_250_set_type;
14898        l_col86 	                               varchar2_250_set_type;
14899        l_col87 	                               varchar2_250_set_type;
14900        l_col88 	                               varchar2_250_set_type;
14901        l_col89 	                               varchar2_250_set_type;
14902        l_col90 	                               varchar2_250_set_type;
14903        l_col91 	                               varchar2_250_set_type;
14904        l_col92 	                               varchar2_250_set_type;
14905        l_col93 	                               varchar2_250_set_type;
14906        l_col94 	                               varchar2_250_set_type;
14907        l_col95 	                               varchar2_250_set_type;
14908        l_col96 	                               varchar2_250_set_type;
14909        l_col97 	                               varchar2_250_set_type;
14910        l_col98 	                               varchar2_250_set_type;
14911        l_col99 	                               varchar2_250_set_type;
14912        l_col100                                varchar2_250_set_type;
14913        l_col101                                  varchar2_250_set_type;
14914        l_col102                                  varchar2_250_set_type;
14915        l_col103                                  varchar2_250_set_type;
14916        l_col104                                  varchar2_250_set_type;
14917        l_col105                                  varchar2_250_set_type;
14918        l_col106                                  varchar2_250_set_type;
14919        l_col107                                  varchar2_250_set_type;
14920        l_col108                                  varchar2_250_set_type;
14921        l_col109                                  varchar2_250_set_type;
14922        l_col110                                 varchar2_250_set_type;
14923        l_col111                                 varchar2_250_set_type;
14924        l_col112                                 varchar2_250_set_type;
14925        l_col113                                 varchar2_250_set_type;
14926        l_col114                                 varchar2_250_set_type;
14927        l_col115                                 varchar2_250_set_type;
14928        l_col116                                 varchar2_250_set_type;
14929        l_col117                                 varchar2_250_set_type;
14930        l_col118                                 varchar2_250_set_type;
14931        l_col119                                 varchar2_250_set_type;
14932        l_col120                                 varchar2_250_set_type;
14933        l_col121                                 varchar2_250_set_type;
14934        l_col122                                 varchar2_250_set_type;
14935        l_col123                                 varchar2_250_set_type;
14936        l_col124                                 varchar2_250_set_type;
14937        l_col125                                 varchar2_250_set_type;
14938        l_col126                                 varchar2_250_set_type;
14939        l_col127                                 varchar2_250_set_type;
14940        l_col128                                 varchar2_250_set_type;
14941        l_col129                                 varchar2_250_set_type;
14942        l_col130                                 varchar2_250_set_type;
14943        l_col131                                 varchar2_250_set_type;
14944        l_col132                                 varchar2_250_set_type;
14945        l_col133                                 varchar2_250_set_type;
14946        l_col134                                 varchar2_250_set_type;
14947        l_col135                                 varchar2_250_set_type;
14948 
14949 CURSOR c_event_fields is
14950 SELECT
14951 import_source_line_id,
14952 import_list_header_id,
14953 DECODE(GREATEST(lengthb(LTRIM(RTRIM(EVENT_SOURCE_CODE))),100) - 100,0,' ','EVENT_SOURCE_CODE:'||decode(nvl(EVENT_SOURCE_CODE,'x'),'x',l_null_value,l_invalid_size)||'(100)') EVENT_SOURCE_CODE,
14954 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REGISTRATION_SOURCE_TYPE)),'x')),30) - 30,0,' ','REGISTRATION_SOURCE_TYPE:'||l_invalid_size||'(30)') REGISTRATION_SOURCE_TYPE,
14955 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PARTY_NAME)),'x')),360) - 360,0,' ','REG_PARTY_NAME:'||l_invalid_size||'(360)') REG_PARTY_NAME,
14956 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SIC_CODE)),'x')),30) - 30,0,' ','REG_SIC_CODE:'||l_invalid_size||'(30)') REG_SIC_CODE,
14957 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SIC_CODE)),'x')),30) - 30,0,' ','ATT_SIC_CODE:'||l_invalid_size||'(30)') ATT_SIC_CODE,
14958 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ANALYSIS_FY)),'x')),5) - 5,0,' ','REG_ANALYSIS_FY:'||l_invalid_size||'(5)') REG_ANALYSIS_FY,
14959 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ANALYSIS_FY)),'x')),5) - 5,0,' ','ATT_ANALYSIS_FY:'||l_invalid_size||'(5)') ATT_ANALYSIS_FY,
14960 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CATEGORY_CODE)),'x')),30) -30,0,' ','REG_CATEGORY_CODE:'||l_invalid_size||'(30)') REG_CATEGORY_CODE,
14961 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CATEGORY_CODE)),'x')),30) -30,0,' ','ATT_CATEGORY_CODE:'||l_invalid_size||'(30)') ATT_CATEGORY_CODE,
14962 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_TAX_REFERENCE)),'x')),50) - 50,0,' ','REG_TAX_REFERENCE:'||l_invalid_size||'(50)') REG_TAX_REFERENCE,
14963 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_TAX_REFERENCE)),'x')),50) - 50,0,' ','ATT_TAX_REFERENCE:'||l_invalid_size||'(50)') ATT_TAX_REFERENCE,
14964 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_YEAR_ESTABLISED,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_YEAR_ESTABLISED:'||l_invalid_number) ATT_YEAR_ESTABLISED,
14965 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_URL)),'x')),2000) - 2000,0,' ','REG_URL:'||l_invalid_size) REG_URL,
14966 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_URL)),'x')),2000) - 2000,0,' ','ATT_URL:'||l_invalid_size) ATT_URL,
14967 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_COUNTRY)),'x')),60) - 60,0,' ','REG_COUNTRY:'||l_invalid_size||'(60)') REG_COUNTRY,
14968 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_COUNTRY)),'x')),60) - 60,0,' ','ATT_COUNTRY:'||l_invalid_size||'(60)') ATT_COUNTRY,
14969 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS1)),'x')),240) - 240,0,' ','REG_ADDRESS1:'||l_invalid_size||'(240)') REG_ADDRESS1,
14970 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS2)),'x')),240) - 240,0,' ','REG_ADDRESS2:'||l_invalid_size||'(240)') REG_ADDRESS2,
14971 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS3)),'x')),240) - 240,0,' ','REG_ADDRESS3:'||l_invalid_size||'(240)') REG_ADDRESS3,
14972 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS4)),'x')),240) - 240,0,' ','REG_ADDRESS4:'||l_invalid_size||'(240)') REG_ADDRESS4,
14973 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CITY)),'x')),60) - 60,0,' ','REG_CITY:'||l_invalid_size||'(60)') REG_CITY,
14974 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_POSTAL_CODE)),'x')),60) - 60,0,' ','REG_POSTAL_CODE:'||l_invalid_size||'(60)') REG_POSTAL_CODE,
14975 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STATE)),'x')),60) - 60,0,' ','REG_STATE:'||l_invalid_size||'(60)') REG_STATE,
14976 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PROVINCE)),'x')),60) - 60,0,' ','REG_PROVINCE:'||l_invalid_size||'(60)') REG_PROVINCE,
14977 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_COUNTY)),'x')),60) - 60,0,' ','REG_COUNTY:'||l_invalid_size||'(60)') REG_COUNTY,
14978 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS1)),'x')),240) - 240,0,' ','ATT_ADDRESS1:'||l_invalid_size||'(240)') ATT_ADDRESS1,
14979 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS2)),'x')),240) - 240,0,' ','ATT_ADDRESS2:'||l_invalid_size||'(240)') ATT_ADDRESS2,
14980 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS3)),'x')),240) - 240,0,' ','ATT_ADDRESS3:'||l_invalid_size||'(240)') ATT_ADDRESS3,
14981 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS4)),'x')),240) - 240,0,' ','ATT_ADDRESS4:'||l_invalid_size||'(240)') ATT_ADDRESS4,
14982 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CITY)),'x')),60) - 60,0,' ','ATT_CITY:'||l_invalid_size||'(60)') ATT_CITY,
14983 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_POSTAL_CODE)),'x')),60) - 60,0,' ','ATT_POSTAL_CODE:'||l_invalid_size||'(60)') ATT_POSTAL_CODE,
14984 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STATE)),'x')),60) - 60,0,' ','ATT_STATE:'||l_invalid_size||'(60)') ATT_STATE,
14985 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PROVINCE)),'x')),60) - 60,0,' ','ATT_PROVINCE:'||l_invalid_size||'(60)') ATT_PROVINCE,
14986 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_COUNTY)),'x')),60) - 60,0,' ','ATT_COUNTY:'||l_invalid_size||'(60)') ATT_COUNTY,
14987 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_EMAIL_ADDRESS)),'x')),240) - 240,0,' ','REG_EMAIL_ADDRESS:'||l_invalid_size||'(240)') REG_EMAIL_ADDRESS,
14988 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_EMAIL_ADDRESS)),'x')),240) - 240,0,' ','ATT_EMAIL_ADDRESS:'||l_invalid_size||'(240)') ATT_EMAIL_ADDRESS,
14989 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_GENDER)),'x')),30) - 30,0,' ','REG_GENDER:'||l_invalid_size||'(30)') REG_GENDER,
14990 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_GENDER)),'x')),30) - 30,0,' ','ATT_GENDER:'||l_invalid_size||'(30)') ATT_GENDER,
14991 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_LAST_NAME)),'x')),50) - 50,0,' ','REG_LAST_NAME:'||l_invalid_size||'(50)') REG_LAST_NAME,
14992 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_FIRST_NAME)),'x')),40) - 40,0,' ','REG_FIRST_NAME:'||l_invalid_size||'(40)') REG_FIRST_NAME,
14993 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_LAST_NAME)),'x')),50) - 50,0,' ','ATT_LAST_NAME:'||l_invalid_size||'(50)') ATT_LAST_NAME,
14994 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_FIRST_NAME)),'x')),40) - 40,0,' ','ATT_FIRST_NAME:'||l_invalid_size||'(40)') ATT_FIRST_NAME,
14995 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_TITLE)),'x')),30) - 30,0,' ','REG_TITLE:'||l_invalid_size||'(30)') REG_TITLE,
14996 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_TITLE)),'x')),30) - 30,0,' ','ATT_TITLE:'||l_invalid_size||'(30)') ATT_TITLE,
14997 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_JOB_TITLE)),'x')),100) - 100,0,' ','REG_JOB_TITLE:'||l_invalid_size||'(100)') REG_JOB_TITLE,
14998 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_JOB_TITLE)),'x')),100) - 100,0,' ','ATT_JOB_TITLE:'||l_invalid_size||'(100)') ATT_JOB_TITLE,
14999 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_NUMBER)),'x')),25) - 25,0,' ','REG_PHONE_NUMBER:'||l_invalid_size||'(25)') REG_PHONE_NUMBER,
15000 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_AREA_CODE)),'x')),10) - 10,0,' ','REG_PHONE_AREA_CODE:'||l_invalid_size||'(10)') REG_PHONE_AREA_CODE,
15001 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_COUNTRY_CODE)),'x')),10) - 10,0,' ','REG_PHONE_COUNTRY_CODE:'||l_invalid_size||'(10)') REG_PHONE_COUNTRY_CODE,
15002 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_EXTENSION)),'x')),20) - 20,0,' ','REG_PHONE_EXTENSION:'||l_invalid_size||'(20)') REG_PHONE_EXTENSION,
15003 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_NUMBER)),'x')),25) - 25,0,' ','ATT_PHONE_NUMBER:'||l_invalid_size||'(25)') ATT_PHONE_NUMBER,
15004 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_AREA_CODE)),'x')),10) - 10,0,' ','ATT_PHONE_AREA_CODE:'||l_invalid_size||'(10)') ATT_PHONE_AREA_CODE,
15005 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_COUNTRY_CODE)),'x')),10) - 10,0,' ','ATT_PHONE_COUNTRY_CODE:'||l_invalid_size||'(10)') ATT_PHONE_COUNTRY_CODE,
15006 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_EXTENSION)),'x')),20) - 20,0,' ','ATT_PHONE_EXTENSION:'||l_invalid_size||'(20)') ATT_PHONE_EXTENSION,
15007 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_MIDDLE_NAME)),'x')),60) - 60,0,' ','REG_MIDDLE_NAME:'||l_invalid_size||'(10)') REG_MIDDLE_NAME,
15008 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_MIDDLE_NAME)),'x')),60) - 60,0,' ','ATT_MIDDLE_NAME:'||l_invalid_size||'(10)') ATT_MIDDLE_NAME,
15009 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATTENDANCE_FLAG)),'x')),1) - 1,0,' ','ATTENDANCE_FLAG:'||l_invalid_size||'(1)') ATTENDANCE_FLAG,
15010 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CANCELLATION_FLAG)),'x')),1) - 1,0,' ','CANCELLATION_FLAG:'||l_invalid_size||'(1)') CANCELLATION_FLAG,
15011 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_DECISION_MAKER_FLAG)),'x')),1) - 1,0,' ','REG_DECISION_MAKER_FLAG:'||l_invalid_size||'(1)') REG_DECISION_MAKER_FLAG,
15012 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_GSA_INDICATOR_FLAG)),'x')),30) - 30,0,' ','REG_GSA_INDICATOR_FLAG:'||l_invalid_size||'(30)') REG_GSA_INDICATOR_FLAG,
15013 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_GSA_INDICATOR_FLAG)),'x')),30) - 30,0,' ','ATT_GSA_INDICATOR_FLAG:'||l_invalid_size||'(30)') ATT_GSA_INDICATOR_FLAG,
15014 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_IDENTIFYING_ADDRESS_FLAG)),'x')),1) - 1,0,' ','REG_IDENTIFYING_ADDRESS_FLAG:'||l_invalid_size||'(1)') REG_IDENTIFYING_ADDRESS_FLAG,
15015 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_IDENTIFYING_ADDRESS_FLAG)),'x')),1) - 1,0,' ','ATT_IDENTIFYING_ADDRESS_FLAG:'||l_invalid_size||'(1)') ATT_IDENTIFYING_ADDRESS_FLAG,
15016 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CONTACT_ME_FLAG)),'x')),1) - 1,0,' ','REG_CONTACT_ME_FLAG:'||l_invalid_size||'(1)') REG_CONTACT_ME_FLAG,
15017 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_EMAIL_OK_FLAG)),'x')),1) - 1,0,' ','REG_EMAIL_OK_FLAG:'||l_invalid_size||'(1)') REG_EMAIL_OK_FLAG,
15018 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_APT_FLAG)),'x')),1) - 1,0,' ','ATT_APT_FLAG:'||l_invalid_size||'(1)') ATT_APT_FLAG,
15019 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_DECISION_MAKER_FLAG)),'x')),1) - 1,0,' ','ATT_DECISION_MAKER_FLAG:'||l_invalid_size||'(1)') ATT_DECISION_MAKER_FLAG,
15020 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CONTACT_ME_FLAG)),'x')),1) - 1,0,' ','ATT_CONTACT_ME_FLAG:'||l_invalid_size||'(1)') ATT_CONTACT_ME_FLAG,
15021 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_EMAIL_OK_FLAG)),'x')),1) - 1,0,' ','ATT_EMAIL_OK_FLAG:'||l_invalid_size||'(1)') ATT_EMAIL_OK_FLAG,
15022 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CANCELLATION_REASON_CODE)),'x')),30) - 30,0,' ','CANCELLATION_REASON_CODE:'||l_invalid_size||'(30)') CANCELLATION_REASON_CODE,
15023 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONFIRMATION_CODE)),'x')),30) - 30,0,' ','CONFIRMATION_CODE:'||l_invalid_size||'(30)') CONFIRMATION_CODE,
15024 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PARTY_TYPE)),'x')),30) - 30,0,' ','REG_PARTY_TYPE:'||l_invalid_size||'(30)') REG_PARTY_TYPE,
15025 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PARTY_TYPE)),'x')),30) - 30,0,' ','ATT_PARTY_TYPE:'||l_invalid_size||'(30)') ATT_PARTY_TYPE,
15026 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIGINAL_SYSTEM_REFERENCE)),'x')),240) - 240,0,' ','ORIGINAL_SYSTEM_REFERENCE:'||l_invalid_size||'(3)') ORIGINAL_SYSTEM_REFERENCE,
15027 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PARTY_NAME)),'x')),360) - 360,0,' ','ATT_PARTY_NAME:'||l_invalid_size||'(360)') ATT_PARTY_NAME,
15028 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_PARTY_ID:'||l_invalid_number) REG_PARTY_ID,
15029 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_PARTY_ID:'||l_invalid_number) ATT_PARTY_ID,
15030 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_CONTACT_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_CONTACT_ID:'||l_invalid_number) REG_CONTACT_ID,
15031 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_CONTACT_ID,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_CONTACT_ID:'||l_invalid_number) ATT_CONTACT_ID,
15032 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_CURRENT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_CURRENT_FY_POTENTIAL_REV:'||l_invalid_number) REG_CURRENT_FY_POTENTIAL_REV,
15033 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_CURRENT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_CURRENT_FY_POTENTIAL_REV:'||l_invalid_number) ATT_CURRENT_FY_POTENTIAL_REV,
15034 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_NEXT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_NEXT_FY_POTENTIAL_REV:'||l_invalid_number) REG_NEXT_FY_POTENTIAL_REV,
15035 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_NEXT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_NEXT_FY_POTENTIAL_REV:'||l_invalid_number) ATT_NEXT_FY_POTENTIAL_REV,
15036 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_HOUSEHOLD_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_HOUSEHOLD_INCOME:'||l_invalid_number) REG_HOUSEHOLD_INCOME,
15037 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_HOUSEHOLD_INCOME,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_HOUSEHOLD_INCOME:'||l_invalid_number) ATT_HOUSEHOLD_INCOME,
15038 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_EMPLOYEE_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_EMPLOYEE_TOTAL:'||l_invalid_number) REG_EMPLOYEE_TOTAL,
15039 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_HOUSE_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_HOUSE_NUMBER:'||l_invalid_number) REG_HOUSE_NUMBER,
15040 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_YEAR_ESTABLISED,' ','x'))),'0123456789.','           x'))),0),0,' ','REG_YEAR_ESTABLISED:'||l_invalid_number) REG_YEAR_ESTABLISED,
15041 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_EMPLOYEE_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_EMPLOYEE_TOTAL:'||l_invalid_number) ATT_EMPLOYEE_TOTAL,
15042 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_FLOOR,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_FLOOR:'||l_invalid_number) ATT_FLOOR,
15043 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_HOUSE_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_HOUSE_NUMBER:'||l_invalid_number) ATT_HOUSE_NUMBER,
15044 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_PO_BOX_NO,' ','x'))),'0123456789.','           x'))),0),0,' ','ATT_PO_BOX_NO:'||l_invalid_number) ATT_PO_BOX_NO,
15045 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_FLOOR)),'x')),50) - 50,0,' ','REG_FLOOR:'||l_invalid_size||'(50)') REG_FLOOR,
15046 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PO_BOX_NO)),'x')),50) - 50,0,' ','REG_PO_BOX_NO:'||l_invalid_size||'(50)') REG_PO_BOX_NO,
15047 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_POSTAL_PLUS4_CODE)),'x')),4) - 4,0,' ','REG_POSTAL_PLUS4_CODE:'||l_invalid_size||'(4)') REG_POSTAL_PLUS4_CODE,
15048 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_POSTAL_PLUS4_CODE)),'x')),4) - 4,0,' ','ATT_POSTAL_PLUS4_CODE:'||l_invalid_size||'(4)') ATT_POSTAL_PLUS4_CODE,
15049 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STREET)),'x')),50) - 50,0,' ','REG_STREET:'||l_invalid_size||'(50)') REG_STREET,
15050 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STREET_NUMBER)),'x')),50) - 50,0,' ','REG_STREET_NUMBER:'||l_invalid_size||'(50)') REG_STREET_NUMBER,
15051 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STREET_SUFFIX)),'x')),50) - 50,0,' ','REG_STREET_SUFFIX:'||l_invalid_size||'(50)') REG_STREET_SUFFIX,
15052 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SUITE)),'x')),50) - 50,0,' ','REG_SUITE:'||l_invalid_size||'(50)') REG_SUITE,
15053 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS_LINE_PHOENETIC)),'x')),360) -360,0,' ','REG_ADDRESS_LINE_PHOENETIC:'||l_invalid_size||'(360)') REG_ADDRESS_LINE_PHOENETIC,
15054 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS_LINE_PHOENETIC)),'x')),360) -360,0,' ','ATT_ADDRESS_LINE_PHOENETIC:'||l_invalid_size||'(360)') ATT_ADDRESS_LINE_PHOENETIC,
15055 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CEO_NAME)),'x')),360) -360,0,' ','REG_CEO_NAME:'||l_invalid_size||'(360)') REG_CEO_NAME,
15056 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CEO_NAME)),'x')),360) -360,0,' ','ATT_CEO_NAME:'||l_invalid_size||'(360)') ATT_CEO_NAME,
15057 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_DEPARTMENT)),'x')),360) -360,0,' ','REG_DEPARTMENT:'||l_invalid_size||'(360)') REG_DEPARTMENT,
15058 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_DEPARTMENT)),'x')),360) -360,0,' ','ATT_DEPARTMENT:'||l_invalid_size||'(360)') ATT_DEPARTMENT,
15059 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_DUN_NO_C)),'x')),30) - 30,0,' ','REG_DUN_NO_C:'||l_invalid_size||'(30)') REG_DUN_NO_C,
15060 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_DUN_NO)),'x')),30) - 30,0,' ','ATT_DUN_NO:'||l_invalid_size||'(30)') ATT_DUN_NO,
15061 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_FY_END_MONTH)),'x')),30) - 30,0,' ','ATT_FY_END_MONTH:'||l_invalid_size||'(30)') ATT_FY_END_MONTH,
15062 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_FY_END_MONTH)),'x')),30) - 30,0,' ','REG_FY_END_MONTH:'||l_invalid_size||'(30)') REG_FY_END_MONTH,
15063 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SIC_CODE)),'x')),30) - 30,0,' ','ATT_SIC_CODE:'||l_invalid_size||'(30)') ATT_SIC_CODE,
15064 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SIC_CODE_TYPE)),'x')),30) - 30,0,' ','ATT_SIC_CODE_TYPE:'||l_invalid_size||'(30)') ATT_SIC_CODE_TYPE,
15065 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ORG_LEGAL_STATUS)),'x')),30) - 30,0,' ','REG_ORG_LEGAL_STATUS:'||l_invalid_size||'(30)') REG_ORG_LEGAL_STATUS,
15066 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SITE_USE_CODE)),'x')),30) - 30,0,' ','ATT_SITE_USE_CODE:'||l_invalid_size||'(30)') ATT_SITE_USE_CODE,
15067 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STREET)),'x')),30) - 30,0,' ','ATT_STREET:'||l_invalid_size||'(30)') ATT_STREET,
15068 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STREET_NUMBER)),'x')),30) - 30,0,' ','ATT_STREET_NUMBER:'||l_invalid_size||'(30)') ATT_STREET_NUMBER,
15069 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STREET_SUFFIX)),'x')),30) - 30,0,' ','ATT_STREET_SUFFIX:'||l_invalid_size||'(30)') ATT_STREET_SUFFIX,
15070 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SUITE)),'x')),30) - 30,0,' ','ATT_SUITE:'||l_invalid_size||'(30)') ATT_SUITE,
15071 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_LEGAL_STATUS)),'x')),30) - 30,0,' ','ATT_LEGAL_STATUS:'||l_invalid_size||'(30)') ATT_LEGAL_STATUS,
15072 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_NAME_SUFFIX)),'x')),30) - 30,0,' ','REG_NAME_SUFFIX:'||l_invalid_size||'(30)') REG_NAME_SUFFIX,
15073 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_NAME_SUFFIX)),'x')),30) - 30,0,' ','ATT_NAME_SUFFIX:'||l_invalid_size||'(30)') ATT_NAME_SUFFIX,
15074 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SIC_CODE_TYPE)),'x')),30) - 30,0,' ','REG_SIC_CODE_TYPE:'||l_invalid_size||'(30)') REG_SIC_CODE_TYPE,
15075 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SITE_USE_CODE)),'x')),30) - 30,0,' ','REG_SITE_USE_CODE:'||l_invalid_size||'(30)') REG_SITE_USE_CODE,
15076 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_TAX_NAME)),'x')),30) - 30,0,' ','REG_TAX_NAME:'||l_invalid_size||'(30)') REG_TAX_NAME,
15077 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_TAX_NAME)),'x')),30) - 30,0,' ','ATT_TAX_NAME:'||l_invalid_size||'(30)') ATT_TAX_NAME,
15078 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_JGZZ_FISCAL_CODE)),'x')),20) - 20,0,' ','REG_JGZZ_FISCAL_CODE:'||l_invalid_size||'(20)') REG_JGZZ_FISCAL_CODE,
15079 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_JGZZ_FISCAL_CODE)),'x')),20) - 20,0,' ','ATT_JGZZ_FISCAL_CODE:'||l_invalid_size||'(20)') ATT_JGZZ_FISCAL_CODE,
15080 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_MISSION_STATEMENT)),'x')),2000) - 2000,0,' ','ATT_MISSION_STATEMENT:'||l_invalid_size||'(2000)') ATT_MISSION_STATEMENT,
15081 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ORG_NAME_PHOENETIC)),'x')),320) - 320,0,' ','REG_ORG_NAME_PHOENETIC:'||l_invalid_size||'(320)') REG_ORG_NAME_PHOENETIC,
15082 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ORG_NAME_PHOENETIC)),'x')),320) - 320,0,' ','ATT_ORG_NAME_PHOENETIC:'||l_invalid_size||'(320)') ATT_ORG_NAME_PHOENETIC,
15083 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_MISSION_STATEMENT)),'x')),2000) - 2000,0,' ','REG_MISSION_STATEMENT:'||l_invalid_size||'(2000)') REG_MISSION_STATEMENT,
15084 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_LINE_OF_BUSINESS)),'x')),240) - 240,0,' ','REG_LINE_OF_BUSINESS:'||l_invalid_size||'(240)') REG_LINE_OF_BUSINESS,
15085 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SERVEY_NOTES)),'x')),240) - 240,0,' ','ATT_SERVEY_NOTES:'||l_invalid_size||'(240)') ATT_SERVEY_NOTES,
15086 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_LINE_OF_BUSINESS)),'x')),240) - 240,0,' ','ATT_LINE_OF_BUSINESS:'||l_invalid_size||'(240)') ATT_LINE_OF_BUSINESS,
15087 DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SERVEY_NOTES)),'x')),240) - 240,0,' ','REG_SERVEY_NOTES:'||l_invalid_size||'(240)') REG_SERVEY_NOTES
15088 FROM ams_event_mapping_v
15089 WHERE import_list_header_id = p_import_list_header_id
15090   and load_status in ('ACTIVE','RELOAD')
15091   and
15092 (
15093   DECODE(GREATEST(lengthb(LTRIM(RTRIM(EVENT_SOURCE_CODE))),100) - 100,0,'OK','NO') = 'NO'
15094 or
15095   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REGISTRATION_SOURCE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15096 or
15097   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PARTY_NAME)),'x')),360) - 360,0,'OK','NO') = 'NO'
15098 or
15099   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SIC_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15100 or
15101   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SIC_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15102 or
15103   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ANALYSIS_FY)),'x')),5) - 5,0,'OK','NO') = 'NO'
15104 or
15105   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ANALYSIS_FY)),'x')),5) - 5,0,'OK','NO') = 'NO'
15106 or
15107   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CATEGORY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15108 or
15109   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CATEGORY_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15110 or
15111 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_CURRENT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15112 or
15113 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_CURRENT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15114 or
15115 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_NEXT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15116 or
15117 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_NEXT_FY_POTENTIAL_REV,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15118 or
15119   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_TAX_REFERENCE)),'x')),50) - 50,0,'OK','NO') = 'NO'
15120 or
15121   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_TAX_REFERENCE)),'x')),50) - 50,0,'OK','NO') = 'NO'
15122 or
15123 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_YEAR_ESTABLISED,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15124 or
15125   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
15126 or
15127   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_URL)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
15128 or
15129   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
15130 or
15131   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_COUNTRY)),'x')),60) - 60,0,'OK','NO') = 'NO'
15132 or
15133   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
15134 or
15135   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
15136 or
15137   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
15138 or
15139   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
15140 or
15141   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
15142 or
15143   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
15144 or
15145   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
15146 or
15147   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
15148 or
15149   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
15150 or
15151   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS1)),'x')),240) - 240,0,'OK','NO') = 'NO'
15152 or
15153   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS2)),'x')),240) - 240,0,'OK','NO') = 'NO'
15154 or
15155   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS3)),'x')),240) - 240,0,'OK','NO') = 'NO'
15156 or
15157   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS4)),'x')),240) - 240,0,'OK','NO') = 'NO'
15158 or
15159   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CITY)),'x')),60) - 60,0,'OK','NO') = 'NO'
15160 or
15161   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_POSTAL_CODE)),'x')),60) - 60,0,'OK','NO') = 'NO'
15162 or
15163   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STATE)),'x')),60) - 60,0,'OK','NO') = 'NO'
15164 or
15165   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PROVINCE)),'x')),60) - 60,0,'OK','NO') = 'NO'
15166 or
15167   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_COUNTY)),'x')),60) - 60,0,'OK','NO') = 'NO'
15168 or
15169   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
15170 or
15171   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_EMAIL_ADDRESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
15172 or
15173   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_GENDER)),'x')),30) - 30,0,'OK','NO') = 'NO'
15174 or
15175   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_GENDER)),'x')),30) - 30,0,'OK','NO') = 'NO'
15176 or
15177   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_LAST_NAME)),'x')),50) - 50,0,'OK','NO') = 'NO'
15178 or
15179   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_FIRST_NAME)),'x')),40) - 40,0,'OK','NO') = 'NO'
15180 or
15181   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_LAST_NAME)),'x')),50) - 50,0,'OK','NO') = 'NO'
15182 or
15183   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_FIRST_NAME)),'x')),40) - 40,0,'OK','NO') = 'NO'
15184 or
15185   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15186 or
15187   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_TITLE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15188 or
15189   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_JOB_TITLE)),'x')),100) - 100,0,'OK','NO') = 'NO'
15190 or
15191   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_JOB_TITLE)),'x')),100) - 100,0,'OK','NO') = 'NO'
15192 or
15193   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
15194 or
15195   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
15196 or
15197   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_COUNTRY_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
15198 or
15199   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PHONE_EXTENSION)),'x')),20) - 20,0,'OK','NO') = 'NO'
15200 or
15201   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_NUMBER)),'x')),25) - 25,0,'OK','NO') = 'NO'
15202 or
15203   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_AREA_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
15204 or
15205   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_COUNTRY_CODE)),'x')),10) - 10,0,'OK','NO') = 'NO'
15206 or
15207   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PHONE_EXTENSION)),'x')),20) - 20,0,'OK','NO') = 'NO'
15208 or
15209   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_MIDDLE_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
15210 or
15211   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_MIDDLE_NAME)),'x')),60) - 60,0,'OK','NO') = 'NO'
15212 or
15213   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATTENDANCE_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15214 or
15215   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CANCELLATION_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15216 or
15217   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_DECISION_MAKER_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15218 or
15219   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_GSA_INDICATOR_FLAG)),'x')),30) - 30,0,'OK','NO') = 'NO'
15220 or
15221   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_IDENTIFYING_ADDRESS_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15222 or
15223   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_IDENTIFYING_ADDRESS_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15224 or
15225   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CONTACT_ME_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15226 or
15227   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_EMAIL_OK_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15228 or
15229   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_APT_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15230 or
15231   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_DECISION_MAKER_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15232 or
15233   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CONTACT_ME_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15234 or
15235   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_EMAIL_OK_FLAG)),'x')),1) - 1,0,'OK','NO') = 'NO'
15236 or
15237   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CANCELLATION_REASON_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15238 or
15239   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(CONFIRMATION_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15240 or
15241   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PARTY_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15242 or
15243   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PARTY_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15244 or
15245   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ORIGINAL_SYSTEM_REFERENCE)),'x')),240) - 240,0,'OK','NO') = 'NO'
15246 or
15247   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_PARTY_NAME)),'x')),360) - 360,0,'OK','NO') = 'NO'
15248 or
15249 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15250 or
15251 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_PARTY_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15252 or
15253 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_CONTACT_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15254 or
15255 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_CONTACT_ID,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15256 or
15257 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_HOUSEHOLD_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15258 or
15259 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_HOUSEHOLD_INCOME,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15260 or
15261 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_EMPLOYEE_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15262 or
15263 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_HOUSE_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15264 or
15265 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(REG_YEAR_ESTABLISED,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15266 or
15267 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_EMPLOYEE_TOTAL,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15268 or
15269 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_FLOOR,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15270 or
15271 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_HOUSE_NUMBER,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15272 or
15273 DECODE(NVL(lengthb(trim(TRANSLATE(LTRIM(RTRIM(REPLACE(ATT_PO_BOX_NO,' ','x'))),'0123456789.','           x'))),0),0,'OK','NO') = 'NO'
15274 or
15275   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_FLOOR)),'x')),50) - 50,0,'OK','NO') = 'NO'
15276 or
15277   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_PO_BOX_NO)),'x')),50) - 50,0,'OK','NO') = 'NO'
15278 or
15279   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_POSTAL_PLUS4_CODE)),'x')),4) - 4,0,'OK','NO') = 'NO'
15280 or
15281   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_POSTAL_PLUS4_CODE)),'x')),4) - 4,0,'OK','NO') = 'NO'
15282 or
15283   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STREET)),'x')),50) - 50,0,'OK','NO') = 'NO'
15284 or
15285   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STREET_NUMBER)),'x')),50) - 50,0,'OK','NO') = 'NO'
15286 or
15287   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_STREET_SUFFIX)),'x')),50) - 50,0,'OK','NO') = 'NO'
15288 or
15289   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SUITE)),'x')),50) - 50,0,'OK','NO') = 'NO'
15290 or
15291   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ADDRESS_LINE_PHOENETIC)),'x')),360) - 360,0,'OK','NO') = 'NO'
15292 or
15293   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ADDRESS_LINE_PHOENETIC)),'x')),360) - 360,0,'OK','NO') = 'NO'
15294 or
15295   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_CEO_NAME)),'x')),360) - 360,0,'OK','NO') = 'NO'
15296 or
15297   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_CEO_NAME)),'x')),360) - 360,0,'OK','NO') = 'NO'
15298 or
15299   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_DEPARTMENT)),'x')),360) - 360,0,'OK','NO') = 'NO'
15300 or
15301   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_DEPARTMENT)),'x')),360) - 360,0,'OK','NO') = 'NO'
15302 or
15303   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_DUN_NO_C)),'x')),30) - 30,0,'OK','NO') = 'NO'
15304 or
15305   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_DUN_NO)),'x')),30) - 30,0,'OK','NO') = 'NO'
15306 or
15307   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_FY_END_MONTH)),'x')),30) - 30,0,'OK','NO') = 'NO'
15308 or
15309   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_FY_END_MONTH)),'x')),30) - 30,0,'OK','NO') = 'NO'
15310 or
15311   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SIC_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15312 or
15313   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SIC_CODE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15314 or
15315   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ORG_LEGAL_STATUS)),'x')),30) - 30,0,'OK','NO') = 'NO'
15316 or
15317   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SITE_USE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15318 or
15319   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STREET)),'x')),30) - 30,0,'OK','NO') = 'NO'
15320 or
15321   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STREET_NUMBER)),'x')),30) - 30,0,'OK','NO') = 'NO'
15322 or
15323   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_STREET_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
15324 or
15325   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SUITE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15326 or
15327   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_LEGAL_STATUS)),'x')),30) - 30,0,'OK','NO') = 'NO'
15328 or
15329   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
15330 or
15331   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_NAME_SUFFIX)),'x')),30) - 30,0,'OK','NO') = 'NO'
15332 or
15333   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SIC_CODE_TYPE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15334 or
15335   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_TAX_NAME)),'x')),30) - 30,0,'OK','NO') = 'NO'
15336 or
15337   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_TAX_NAME)),'x')),30) - 30,0,'OK','NO') = 'NO'
15338 or
15339   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SITE_USE_CODE)),'x')),30) - 30,0,'OK','NO') = 'NO'
15340 or
15341   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_JGZZ_FISCAL_CODE)),'x')),20) - 20,0,'OK','NO') = 'NO'
15342 or
15343   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_JGZZ_FISCAL_CODE)),'x')),20) - 20,0,'OK','NO') = 'NO'
15344 or
15345   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_MISSION_STATEMENT)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
15346 or
15347   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_ORG_NAME_PHOENETIC)),'x')),320) - 320,0,'OK','NO') = 'NO'
15348 or
15349   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_ORG_NAME_PHOENETIC)),'x')),320) - 320,0,'OK','NO') = 'NO'
15350 or
15351   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_MISSION_STATEMENT)),'x')),2000) - 2000,0,'OK','NO') = 'NO'
15352 or
15353   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_LINE_OF_BUSINESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
15354 or
15355   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_SERVEY_NOTES)),'x')),240) - 240,0,'OK','NO') = 'NO'
15356 or
15357   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(ATT_LINE_OF_BUSINESS)),'x')),240) - 240,0,'OK','NO') = 'NO'
15358 or
15359   DECODE(GREATEST(lengthb(nvl(LTRIM(RTRIM(REG_SERVEY_NOTES)),'x')),240) - 240,0,'OK','NO') = 'NO'
15360 )
15361 ;
15362 
15363 CURSOR c_lead_batch_id is
15364 SELECT
15365 batch_id
15366 FROM ams_imp_list_headers_all
15367 WHERE import_list_header_id = p_import_list_header_id;
15368 
15369 begin
15370 
15371         IF p_import_list_header_id IS NULL THEN
15372                 RAISE FND_API.G_EXC_ERROR;
15373         END IF;
15374     p_return_status := FND_API.G_RET_STS_SUCCESS;
15375 
15376     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_DATATYPE_ERROR_CHK');
15377     l_invalid_number := FND_MESSAGE.get;
15378     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_SIZE_ERROR_CHK');
15379     l_invalid_size := FND_MESSAGE.get;
15380     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_COL_NULL_ERROR_CHK');
15381     l_null_value := FND_MESSAGE.get;
15382     FND_MESSAGE.set_name('AMS', 'AMS_IMP_FLD_SOUR_SYS_ERROR_CHK');
15383     l_invalid_src_system := FND_MESSAGE.get;
15384 
15385     OPEN c_lead_batch_id;
15386     FETCH c_lead_batch_id into l_batch_id;
15387     CLOSE c_lead_batch_id;
15388 
15389     OPEN c_event_fields;
15390      LOOP
15391       FETCH c_event_fields BULK COLLECT INTO
15392        l_import_source_line_id,
15393        l_import_list_header_id,
15394        l_col1                                  ,
15395        l_col2                                  ,
15396        l_col3                                  ,
15397        l_col4                                  ,
15398        l_col5                                  ,
15399        l_col6                                  ,
15400        l_col7                                  ,
15401        l_col8                                  ,
15402        l_col9                                  ,
15403        l_col10                                 ,
15404        l_col11                                 ,
15405        l_col12                                 ,
15406        l_col13                                 ,
15407        l_col14                                 ,
15408        l_col15                                 ,
15409        l_col16                                 ,
15410        l_col17                                 ,
15411        l_col18                                 ,
15412        l_col19                                 ,
15413        l_col20                                 ,
15414        l_col21                                 ,
15415        l_col22                                 ,
15416        l_col23                                 ,
15417        l_col24                                 ,
15418        l_col25                                 ,
15419        l_col26                                 ,
15420        l_col27                                 ,
15421        l_col28                                 ,
15422        l_col29                                 ,
15423        l_col30                                 ,
15424        l_col31                                 ,
15425        l_col32                                 ,
15426        l_col33                                 ,
15427        l_col34                                 ,
15428        l_col35                                 ,
15429        l_col36                                 ,
15430        l_col37                                 ,
15431        l_col38                                 ,
15432        l_col39                                 ,
15433        l_col40                                 ,
15434        l_col41                                 ,
15435        l_col42                                 ,
15436        l_col43                                 ,
15437        l_col44                                 ,
15438        l_col45                                 ,
15439        l_col46                                 ,
15440        l_col47                                 ,
15441        l_col48                                 ,
15442        l_col49                                 ,
15443        l_col50                                 ,
15444        l_col51                                 ,
15445        l_col52                                 ,
15446        l_col53                                 ,
15447        l_col54                                 ,
15448        l_col55                                 ,
15449        l_col56                                 ,
15450        l_col57                                 ,
15451        l_col58                                 ,
15452        l_col59                                 ,
15453        l_col60                                 ,
15454        l_col61                                 ,
15455        l_col62                                 ,
15456        l_col63                                 ,
15457        l_col64                                 ,
15458        l_col65                                 ,
15459        l_col66                                 ,
15460        l_col67                                 ,
15461        l_col68                                 ,
15462        l_col69                                 ,
15463        l_col70                                 ,
15464        l_col71                                 ,
15465        l_col72                                 ,
15466        l_col73                                 ,
15467        l_col74                                 ,
15468        l_col75                                 ,
15469        l_col76                                 ,
15470        l_col77                                 ,
15471        l_col78                                 ,
15472        l_col79                                 ,
15473        l_col80                                 ,
15474        l_col81                                 ,
15475        l_col82                                 ,
15476        l_col83                                 ,
15477        l_col84                                 ,
15478        l_col85                                 ,
15479        l_col86                                 ,
15480        l_col87                                 ,
15481        l_col88                                 ,
15482        l_col89                                 ,
15483        l_col90                                 ,
15484        l_col91                                 ,
15485        l_col92                                 ,
15486        l_col93                                 ,
15487        l_col94                                 ,
15488        l_col95                                 ,
15489        l_col96                                 ,
15490        l_col97                                 ,
15491        l_col98                                 ,
15492        l_col99                                 ,
15493        l_col100                                ,
15494        l_col101                                  ,
15495        l_col102                                  ,
15496        l_col103                                  ,
15497        l_col104                                  ,
15498        l_col105                                  ,
15499        l_col106                                  ,
15500        l_col107                                  ,
15501        l_col108                                  ,
15502        l_col109                                  ,
15503        l_col110                                 ,
15504        l_col111                                 ,
15505        l_col112                                 ,
15506        l_col113                                 ,
15507        l_col114                                 ,
15508        l_col115                                 ,
15509        l_col116                                 ,
15510        l_col117                                 ,
15511        l_col118                                 ,
15512        l_col119                                 ,
15513        l_col120                                 ,
15514        l_col121                                 ,
15515        l_col122                                 ,
15516        l_col123                                 ,
15517        l_col124                                 ,
15518        l_col125                                 ,
15519        l_col126                                 ,
15520        l_col127                                 ,
15521        l_col128                                 ,
15522        l_col129                                 ,
15523        l_col130                                 ,
15524        l_col131                                 ,
15525        l_col132                                 ,
15526        l_col133                                 ,
15527        l_col134                                 ,
15528        l_col135
15529       LIMIT L_MAX_ROW_COUNT;
15530 
15531 
15532       FORALL i IN 1 .. l_import_source_line_id.count
15533        INSERT INTO ams_list_import_errors
15534        (
15535 	LIST_IMPORT_ERROR_ID,
15536 	LAST_UPDATED_BY,
15537 	LAST_UPDATE_DATE,
15538 	CREATION_DATE,
15539 	CREATED_BY,
15540 	LAST_UPDATE_LOGIN,
15541 	IMPORT_SOURCE_LINE_ID,
15542 	IMPORT_LIST_HEADER_ID,
15543 	IMPORT_TYPE,
15544 	ERROR_TYPE,
15545         BATCH_ID,
15546         ERROR_FLAG,
15547         col1                                  ,
15548         col2                                  ,
15549         col3                                  ,
15550         col4                                  ,
15551         col5                                  ,
15552         col6                                  ,
15553         col7                                  ,
15554         col8                                  ,
15555         col9                                  ,
15556         col10                                 ,
15557         col11                                 ,
15558         col12                                 ,
15559         col13                                 ,
15560         col14                                 ,
15561         col15                                 ,
15562         col16                                 ,
15563         col17                                 ,
15564         col18                                 ,
15565         col19                                 ,
15566         col20                                 ,
15567         col21                                 ,
15568         col22                                 ,
15569         col23                                 ,
15570         col24                                 ,
15571         col25                                 ,
15572         col26                                 ,
15573         col27                                 ,
15574         col28                                 ,
15575         col29                                 ,
15576         col30                                 ,
15577         col31                                 ,
15578         col32                                 ,
15579         col33                                 ,
15580         col34                                 ,
15581         col35                                 ,
15582         col36                                 ,
15583         col37                                 ,
15584         col38                                 ,
15585         col39                                 ,
15586         col40                                 ,
15587         col41                                 ,
15588         col42                                 ,
15589         col43                                 ,
15590         col44                                 ,
15591         col45                                 ,
15592         col46                                 ,
15593         col47                                 ,
15594         col48                                 ,
15595         col49                                 ,
15596         col50                                 ,
15597         col51                                 ,
15598         col52                                 ,
15599         col53                                 ,
15600         col54                                 ,
15601         col55                                 ,
15602         col56                                 ,
15603         col57                                 ,
15604         col58                                 ,
15605         col59                                 ,
15606         col60                                 ,
15607         col61                                 ,
15608         col62                                 ,
15609         col63                                 ,
15610         col64                                 ,
15611         col65                                 ,
15612         col66                                 ,
15613         col67                                 ,
15614         col68                                 ,
15615         col69                                 ,
15616         col70                                 ,
15617         col71                                 ,
15618         col72                                 ,
15619         col73                                 ,
15620         col74                                 ,
15621         col75                                 ,
15622         col76                                 ,
15623         col77                                 ,
15624         col78                                 ,
15625         col79                                 ,
15626         col80                                 ,
15627         col81                                 ,
15628         col82                                 ,
15629         col83                                 ,
15630         col84                                 ,
15631         col85                                 ,
15632         col86                                 ,
15633         col87                                 ,
15634         col88                                 ,
15635         col89                                 ,
15636         col90                                 ,
15637         col91                                 ,
15638         col92                                 ,
15639         col93                                 ,
15640         col94                                 ,
15641         col95                                 ,
15642         col96                                 ,
15643         col97                                 ,
15644         col98                                 ,
15645         col99                                 ,
15646         col100                                ,
15647         col101                                  ,
15648         col102                                  ,
15649         col103                                  ,
15650         col104                                  ,
15651         col105                                  ,
15652         col106                                  ,
15653         col107                                  ,
15654         col108                                  ,
15655         col109                                  ,
15656         col110                                 ,
15657         col111                                 ,
15658         col112                                 ,
15659         col113                                 ,
15660         col114                                 ,
15661         col115                                 ,
15662         col116                                 ,
15663         col117                                 ,
15664         col118                                 ,
15665         col119                                 ,
15666         col120                                 ,
15667         col121                                 ,
15668         col122                                 ,
15669         col123                                 ,
15670         col124                                 ,
15671         col125                                 ,
15672         col126                                 ,
15673         col127                                 ,
15674         col128                                 ,
15675         col129                                 ,
15676         col130                                 ,
15677         col131                                 ,
15678         col132                                 ,
15679         col133                                 ,
15680         col134                                 ,
15681         col135
15682         )
15683        VALUES
15684        (
15685 	ams_list_import_errors_s.nextval,      -- LIST_IMPORT_ERROR_ID,
15686 	FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
15687 	SYSDATE,                              -- LAST_UPDATE_DATE,
15688 	SYSDATE,                              -- CREATION_DATE,
15689 	FND_GLOBAL.User_ID,                   -- CREATED_BY,
15690 	FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
15691         l_import_source_line_id(i),
15692         l_import_list_header_id(i),
15693 	'EVENT',                                -- IMPORT_TYPE,
15694 	'E',                                  -- ERROR_TYPE,
15695         l_batch_id,
15696        'Y',
15697        l_col1(i),
15698        l_col2(i),
15699        l_col3(i),
15700        l_col4(i),
15701        l_col5(i),
15702        l_col6(i),
15703        l_col7(i),
15704        l_col8(i),
15705        l_col9(i),
15706        l_col10(i),
15707        l_col11(i),
15708        l_col12(i),
15709        l_col13(i),
15710        l_col14(i),
15711        l_col15(i),
15712        l_col16(i),
15713        l_col17(i),
15714        l_col18(i),
15715        l_col19(i),
15716        l_col20(i),
15717        l_col21(i),
15718        l_col22(i),
15719        l_col23(i),
15720        l_col24(i),
15721        l_col25(i),
15722        l_col26(i),
15723        l_col27(i),
15724        l_col28(i),
15725        l_col29(i),
15726        l_col30(i),
15727        l_col31(i),
15728        l_col32(i),
15729        l_col33(i),
15730        l_col34(i),
15731        l_col35(i),
15732        l_col36(i),
15733        l_col37(i),
15734        l_col38(i),
15735        l_col39(i),
15736        l_col40(i),
15737        l_col41(i),
15738        l_col42(i),
15739        l_col43(i),
15740        l_col44(i),
15741        l_col45(i),
15742        l_col46(i),
15743        l_col47(i),
15744        l_col48(i),
15745        l_col49(i),
15746        l_col50(i),
15747        l_col51(i),
15748        l_col52(i),
15749        l_col53(i),
15750        l_col54(i),
15751        l_col55(i),
15752        l_col56(i),
15753        l_col57(i),
15754        l_col58(i),
15755        l_col59(i),
15756        l_col60(i),
15757        l_col61(i),
15758        l_col62(i),
15759        l_col63(i),
15760        l_col64(i),
15761        l_col65(i),
15762        l_col66(i),
15763        l_col67(i),
15764        l_col68(i),
15765        l_col69(i),
15766        l_col70(i),
15767        l_col71(i),
15768        l_col72(i),
15769        l_col73(i),
15770        l_col74(i),
15771        l_col75(i),
15772        l_col76(i),
15773        l_col77(i),
15774        l_col78(i),
15775        l_col79(i),
15776        l_col80(i),
15777        l_col81(i),
15778        l_col82(i),
15779        l_col83(i),
15780        l_col84(i),
15781        l_col85(i),
15782        l_col86(i),
15783        l_col87(i),
15784        l_col88(i),
15785        l_col89(i),
15786        l_col90(i),
15787        l_col91(i),
15788        l_col92(i),
15789        l_col93(i),
15790        l_col94(i),
15791        l_col95(i),
15792        l_col96(i),
15793        l_col97(i),
15794        l_col98(i),
15795        l_col99(i),
15796        l_col100(i),
15797        l_col101(i),
15798        l_col102(i),
15799        l_col103(i),
15800        l_col104(i),
15801        l_col105(i),
15802        l_col106(i),
15803        l_col107(i),
15804        l_col108(i),
15805        l_col109(i),
15806        l_col110(i),
15807        l_col111(i),
15808        l_col112(i),
15809        l_col113(i),
15810        l_col114(i),
15811        l_col115(i),
15812        l_col116(i),
15813        l_col117(i),
15814        l_col118(i),
15815        l_col119(i),
15816        l_col120(i),
15817        l_col121(i),
15818        l_col122(i),
15819        l_col123(i),
15820        l_col124(i),
15821        l_col125(i),
15822        l_col126(i),
15823        l_col127(i),
15824        l_col128(i),
15825        l_col129(i),
15826        l_col130(i),
15827        l_col131(i),
15828        l_col132(i),
15829        l_col133(i),
15830        l_col134(i),
15831        l_col135(i)
15832        );
15833       EXIT WHEN c_event_fields%NOTFOUND;
15834     END LOOP;
15835       CLOSE c_event_fields;
15836 
15837       UPDATE ams_imp_source_lines
15838          SET load_status = 'ERROR'
15839        WHERE import_list_header_id = p_import_list_header_id
15840          and import_source_line_id in
15841        (select import_source_line_id from ams_list_import_errors
15842         where import_list_header_id = p_import_list_header_id
15843           and error_type = 'E');
15844 
15845 
15846 EXCEPTION
15847  WHEN OTHERS THEN
15848     p_return_status := FND_API.G_RET_STS_ERROR;
15849     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
15850     FND_MESSAGE.Set_Token('ROW','Error in execute_event_data_validation:' || SQLERRM||' '||SQLCODE);
15851     AMS_Utility_PVT.Create_Log (
15852       x_return_status   => l_return_status,
15853       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
15854       p_log_used_by_id  => p_import_list_header_id,
15855       p_msg_data        => FND_MESSAGE.get,
15856       p_msg_type        => 'DEBUG'
15857    );
15858 
15859 end execute_event_data_validation;
15860 
15861 --
15862 -- This procedure generates the status of import
15863 --
15864 --
15865 PROCEDURE process_status_code (
15866    p_import_list_header_id    IN    NUMBER
15867                             ) is
15868 
15869 
15870 l_tot_numb_records            NUMBER;
15871 l_tot_numb_error_records           NUMBER;
15872 l_tot_numb_dup_records             NUMBER;
15873 l_tot_numb_success_records         NUMBER;
15874 l_tot_numb_active_records          NUMBER;
15875 l_status_code                 VARCHAR2(30);
15876 l_user_status_id              NUMBER;
15877 L_RETURN_STATUS                    VARCHAR2(1);
15878 
15879 
15880 
15881 cursor c_tot_numb_records is
15882      select count(*) from ams_imp_source_lines
15883      where import_list_header_id = p_import_list_header_id;
15884 
15885 cursor c_tot_numb_error_records is
15886      select count(*) from ams_imp_source_lines
15887      where import_list_header_id = p_import_list_header_id
15888      and   load_status = G_STATUS_ERROR;
15889 
15890 cursor c_tot_numb_dup_records is
15891      select count(*) from ams_imp_source_lines
15892      where import_list_header_id = p_import_list_header_id
15893      and   load_status = G_STATUS_DUPLICATE;
15894 
15895 cursor c_tot_numb_success_records is
15896      select count(*) from ams_imp_source_lines
15897      where import_list_header_id = p_import_list_header_id
15898      and   load_status = G_STATUS_SUCCESS;
15899 
15900 cursor c_tot_numb_active_records is
15901      select count(*) from ams_imp_source_lines
15902      where import_list_header_id = p_import_list_header_id
15903      and   load_status in ('ACTIVE','RELOAD');
15904 
15905 
15906 
15907 
15908 begin
15909      open c_tot_numb_records;
15910      fetch c_tot_numb_records into l_tot_numb_records;
15911      close c_tot_numb_records;
15912 
15913      open c_tot_numb_error_records;
15914      fetch c_tot_numb_error_records into l_tot_numb_error_records;
15915      close c_tot_numb_error_records;
15916 
15917      open c_tot_numb_dup_records;
15918      fetch c_tot_numb_dup_records into l_tot_numb_dup_records;
15919      close c_tot_numb_dup_records;
15920 
15921         open c_tot_numb_success_records;
15922      fetch c_tot_numb_success_records into l_tot_numb_success_records;
15923      close c_tot_numb_success_records;
15924 
15925      open c_tot_numb_active_records;
15926      fetch c_tot_numb_active_records into l_tot_numb_active_records;
15927      close c_tot_numb_active_records;
15928 
15929      -- ALL SUCCESSFUL
15930         if (((l_tot_numb_records = l_tot_numb_success_records) and l_tot_numb_records > 0)
15931            and l_tot_numb_error_records = 0 and l_tot_numb_dup_records = 0) then
15932            l_status_code := 'COMPLETED';
15933      end if;
15934 
15935      -- ALL ERROR
15936         if (((l_tot_numb_records = l_tot_numb_error_records) and l_tot_numb_records > 0)
15937            and l_tot_numb_success_records = 0 and l_tot_numb_dup_records = 0) then
15938            l_status_code := 'ERROR';
15939      end if;
15940 
15941      -- ALL DUPLICATE
15942         if (((l_tot_numb_records = l_tot_numb_dup_records) and l_tot_numb_records > 0)
15943            and l_tot_numb_success_records = 0 and l_tot_numb_error_records = 0) then
15944            l_status_code := 'DUPLICATE';
15945      end if;
15946 
15947      -- INCOMPLETE WITH ERRORS
15948      if (l_tot_numb_success_records > 0 and l_tot_numb_error_records > 0
15949         and l_tot_numb_dup_records = 0) then
15950            l_status_code := 'INCOMPERR';
15951      end if;
15952 
15953      -- INCOMPLETE WITH DUPLICATES
15954      if (l_tot_numb_success_records > 0 and l_tot_numb_dup_records > 0
15955         and l_tot_numb_error_records = 0) then
15956            l_status_code := 'INCOMPDUP';
15957      end if;
15958 
15959      -- INCOMPLETE WITH DUPLICATES AND ERRORS
15960      if (l_tot_numb_success_records > 0 and l_tot_numb_dup_records > 0
15961         and l_tot_numb_error_records > 0) then
15962            l_status_code := 'INCOMPDUPERR';
15963      end if;
15964 
15965         -- CHECK ACTIVE/RELOAD STATUS RECORD
15966      if l_tot_numb_active_records > 0 then
15967               AMS_Utility_PVT.Create_Log (
15968                   x_return_status   => l_return_status,
15969                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
15970                   p_log_used_by_id  => p_import_list_header_id,
15971                   p_msg_data        => 'Some of the records are not processed .' ,
15972                   p_msg_type        => 'DEBUG'
15973                 );
15974      end if;
15975 
15976      if l_status_code is NULL then
15977             l_status_code := 'ERROR';
15978         end if;
15979         l_user_status_id := null;
15980         SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
15981         WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
15982         system_status_code = l_status_code and default_flag = 'Y';
15983 
15984         UPDATE ams_imp_list_headers_all
15985         set status_code                 =  l_status_code,
15986         user_status_id             =  l_user_status_id,
15987         loaded_no_of_rows          =  l_tot_numb_success_records,
15988      number_of_duplicate_records   =  l_tot_numb_dup_records,
15989      number_of_failed_records =  l_tot_numb_error_records,
15990         status_date                =  sysdate
15991         where import_list_header_id = p_import_list_header_id;
15992 
15993  exception
15994  WHEN OTHERS THEN
15995     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
15996     FND_MESSAGE.Set_Token('ROW','Error in process_status_code :' || SQLERRM||' '||SQLCODE);
15997     AMS_Utility_PVT.Create_Log (
15998       x_return_status   => l_return_status,
15999       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
16000       p_log_used_by_id  => p_import_list_header_id,
16001       p_msg_data        => FND_MESSAGE.get,
16002       p_msg_type        => 'DEBUG'
16003    );
16004 
16005 end process_status_code;
16006 
16007 -- 00000000000000000000000000000000000000000000000000000000000000000000000000000000
16008 -- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16009 -- This program is for customer import for XML data.
16010 
16011 PROCEDURE Process_customers_xml (
16012     p_api_version_number        IN    NUMBER,
16013     p_init_msg_list             IN    VARCHAR2   := FND_API.G_FALSE,
16014     p_commit                    IN    VARCHAR2   := FND_API.G_FALSE,
16015     p_validation_level          IN    NUMBER     := FND_API.G_VALID_LEVEL_FULL,
16016     x_return_status             OUT NOCOPY   VARCHAR2,
16017     x_msg_count                 OUT NOCOPY   NUMBER,
16018     x_msg_data                  OUT NOCOPY   VARCHAR2,
16019     p_import_list_header_id     IN    NUMBER,
16020     p_update_flag               IN    VARCHAR2
16021 ) IS
16022 
16023 
16024    root_node_rec_type     AMS_IMP_XML_ELEMENTS%ROWTYPE;
16025    l_child_node_rec       AMS_IMP_XML_ELEMENTS%ROWTYPE;
16026    l_orgid_data_in_tbl    AMS_IMPORT_XML_PVT.xml_element_key_set_type;
16027 
16028    l_perid_data_in_tbl    AMS_IMPORT_XML_PVT.xml_element_key_set_type;
16029 
16030    l_cust_b2b_tbl 		cust_data_in_tbl;
16031    l_cust_b2c_tbl 		cust_b2c_data_in_tbl;
16032    l_cust_b2b_rec		data_in_rec_type;
16033    l_cust_b2c_rec		data_in_rec_b2c_type;
16034 
16035    l_b2b_flag	VARCHAR2(1);
16036 
16037   cursor c_b2b is
16038          select decode(import_type,'B2B','Y','N') from ams_imp_list_headers_all
16039          WHERE import_list_header_id = p_import_list_header_id;
16040 
16041 begin
16042 
16043  open c_b2b;
16044  fetch c_b2b into l_b2b_flag;
16045  close c_b2b;
16046 
16047 
16048 /********* Get the Root Node  *****************************/
16049 
16050   AMS_IMPORT_XML_PVT.Get_Root_Node (
16051     p_import_list_header_id    => p_import_list_header_id,
16052     x_node_rec                 => root_node_rec_type,
16053     x_return_status            => x_return_status,
16054     x_msg_data                 => x_msg_data);
16055 
16056     -- dbms_output.put_line( ' Root Id '||root_node_rec_type.IMP_XML_ELEMENT_ID);
16057 IF l_b2b_flag = 'Y' then
16058 /********* Get all the Organizations for the Root Node  *****************************/
16059 
16060   AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16061     p_imp_xml_element_id => root_node_rec_type.IMP_XML_ELEMENT_ID,
16062     x_child_ids          => l_orgid_data_in_tbl,
16063     x_return_status      => x_return_status,
16064     x_msg_data           => x_msg_data);
16065 
16066     FOR i IN 1..l_orgid_data_in_tbl.COUNT LOOP
16067        -- dbms_output.put_line( ' Organizations Id '||l_orgid_data_in_tbl(i));
16068        -- dbms_output.put_line( ' Organizations count '||l_orgid_data_in_tbl.COUNT);
16069 
16070 	 Process_b2b_xml_data (
16071                 p_import_list_header_id   => p_import_list_header_id,
16072     		p_xml_element_id          => l_orgid_data_in_tbl(i),
16073     		p_cust_tbl                => l_cust_b2b_tbl,
16074     		x_return_status           => x_return_status,
16075     		x_msg_data                => x_msg_data);
16076        -- dbms_output.put_line( ' in Createtotal count '||l_cust_b2b_tbl.COUNT);
16077       Create_b2b_src_lines(
16078                 p_import_list_header_id  => p_import_list_header_id,
16079                 p_cust_b2b_tbl           => l_cust_b2b_tbl,
16080                 x_return_status          => x_return_status,
16081                 x_msg_data               => x_msg_data);
16082     END LOOP;
16083 /*
16084       Create_b2b_src_lines(
16085                 p_import_list_header_id  => p_import_list_header_id,
16086                 p_cust_b2b_tbl           => l_cust_b2b_tbl,
16087                 x_return_status          => x_return_status,
16088                 x_msg_data               => x_msg_data);
16089 */
16090 END if;
16091 
16092 IF l_b2b_flag = 'N' then
16093 /********* Get all the Persons for the Root Node  *****************************/
16094 
16095   AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16096     p_imp_xml_element_id => root_node_rec_type.IMP_XML_ELEMENT_ID,
16097     x_child_ids          => l_perid_data_in_tbl,
16098     x_return_status      => x_return_status,
16099     x_msg_data           => x_msg_data);
16100 
16101     FOR i IN 1..l_perid_data_in_tbl.COUNT LOOP
16102        -- dbms_output.put_line( ' Person Id '||l_perid_data_in_tbl(i));
16103        -- dbms_output.put_line( ' Person count '||l_perid_data_in_tbl.COUNT);
16104 
16105          Process_b2c_xml_data (
16106                 p_import_list_header_id   => p_import_list_header_id,
16107                 p_xml_element_id          => l_perid_data_in_tbl(i),
16108                 p_cust_tbl                => l_cust_b2c_tbl,
16109                 x_return_status           => x_return_status,
16110                 x_msg_data                => x_msg_data);
16111 
16112       Create_b2c_src_lines(
16113                 p_import_list_header_id  => p_import_list_header_id,
16114                 p_cust_b2c_tbl           => l_cust_b2c_tbl,
16115                 x_return_status          => x_return_status,
16116                 x_msg_data               => x_msg_data);
16117        -- dbms_output.put_line( ' total count '||l_cust_b2c_tbl.COUNT);
16118     END LOOP;
16119 /*
16120       Create_b2c_src_lines(
16121                 p_import_list_header_id  => p_import_list_header_id,
16122                 p_cust_b2c_tbl           => l_cust_b2c_tbl,
16123                 x_return_status          => x_return_status,
16124                 x_msg_data               => x_msg_data);
16125 */
16126 END if;
16127 
16128  exception
16129  WHEN OTHERS THEN
16130     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
16131     FND_MESSAGE.Set_Token('ROW','Error in Process_customers_xml :' || SQLERRM||' '||SQLCODE);
16132     AMS_Utility_PVT.Create_Log (
16133       x_return_status   => x_return_status,
16134       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
16135       p_log_used_by_id  => p_import_list_header_id,
16136       p_msg_data        => FND_MESSAGE.get,
16137       p_msg_type        => 'DEBUG'
16138    );
16139 
16140 
16141 
16142 end Process_customers_xml;
16143 -- **********************************************
16144 --
16145 -- This program processes the xml data.
16146 
16147 PROCEDURE Process_b2b_xml_data (
16148     p_import_list_header_id     IN    NUMBER,
16149     p_xml_element_id            IN    NUMBER,
16150     p_cust_tbl                  IN OUT NOCOPY   cust_data_in_tbl,
16151     x_return_status             OUT NOCOPY   VARCHAR2,
16152     x_msg_data                  OUT NOCOPY   VARCHAR2
16153 ) IS
16154    l_loc_element_id	NUMBER;
16155    l_oct_element_id	NUMBER;
16156    l_pho_element_id	NUMBER;
16157    l_ema_element_id	NUMBER;
16158    l_rec	NUMBER := 1;
16159 
16160  party_rec       hz_party_v2pub.party_rec_type;
16161  org_rec         hz_party_v2pub.organization_rec_type;
16162  person_rec      hz_party_v2pub.person_rec_type;
16163  location_rec    hz_location_v2pub.location_rec_type;
16164  psite_rec       hz_party_site_v2pub.party_site_rec_type;
16165  cpoint_rec      hz_contact_point_v2pub.contact_point_rec_type;
16166  email_rec       hz_contact_point_v2pub.email_rec_type;
16167  phone_rec       hz_contact_point_v2pub.phone_rec_type;
16168  ocon_rec        hz_party_contact_v2pub.org_contact_rec_type;
16169  edi_rec         hz_contact_point_v2pub.edi_rec_type;
16170  telex_rec       hz_contact_point_v2pub.telex_rec_type;
16171  web_rec         hz_contact_point_v2pub.web_rec_type;
16172 
16173 
16174    l_orgid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16175    l_locid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16176    l_addid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16177    l_octid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16178    l_conid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16179    l_phoid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16180    l_phiid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16181    l_emaid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16182    l_emlid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
16183    l_customer_tbl 		cust_data_in_tbl;
16184 
16185 begin
16186     /********* Get all the elements for the Organizations *****************************/
16187       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16188         p_imp_xml_element_id => p_xml_element_id,
16189         x_child_set          => l_orgid_record_in_tbl,
16190         x_return_status      => x_return_status,
16191         x_msg_data           => x_msg_data);
16192 
16193        -- dbms_output.put_line( ' Organizations attribute count '||l_orgid_record_in_tbl.COUNT);
16194 /*
16195        FOR i IN 1..l_orgid_record_in_tbl.COUNT LOOP
16196        -- dbms_output.put_line('Org att '||l_orgid_record_in_tbl(i).column_name||'>>>'||l_orgid_record_in_tbl(i).data);
16197        END LOOP;
16198 */
16199        l_customer_tbl(l_rec).cust_data_id := l_rec;
16200        l_customer_tbl(l_rec).org_imp_xml_element_id := p_xml_element_id;
16201        l_customer_tbl(l_rec).PARTY_NAME := Get_Element_VALUE('PARTY_NAME',l_orgid_record_in_tbl);
16202        l_customer_tbl(l_rec).FISCAL_YEAREND_MONTH := Get_Element_VALUE('FISCAL_YEAREND_MONTH',l_orgid_record_in_tbl);
16203        l_customer_tbl(l_rec).DUNS_NUMBER := Get_Element_VALUE('DUNS_NUMBER',l_orgid_record_in_tbl);
16204        l_customer_tbl(l_rec).EMPLOYEES_TOTAL := Get_Element_VALUE('EMPLOYEES_TOTAL',l_orgid_record_in_tbl);
16205        l_customer_tbl(l_rec).LINE_OF_BUSINESS := Get_Element_VALUE('LINE_OF_BUSINESS',l_orgid_record_in_tbl);
16206        l_customer_tbl(l_rec).YEAR_ESTABLISHED := Get_Element_VALUE('YEAR_ESTABLISHED',l_orgid_record_in_tbl);
16207        l_customer_tbl(l_rec).TAX_REFERENCE := Get_Element_VALUE('TAX_REFERENCE',l_orgid_record_in_tbl);
16208        l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := Get_Element_VALUE('ORIG_SYSTEM_REFERENCE',l_orgid_record_in_tbl);
16209        l_customer_tbl(l_rec).CEO_NAME := Get_Element_VALUE('CEO_NAME',l_orgid_record_in_tbl);
16210        l_customer_tbl(l_rec).SIC_CODE := Get_Element_VALUE('SIC_CODE',l_orgid_record_in_tbl);
16211        l_customer_tbl(l_rec).SIC_CODE_TYPE := Get_Element_VALUE('SIC_CODE_TYPE',l_orgid_record_in_tbl);
16212        l_customer_tbl(l_rec).ANALYSIS_FY := Get_Element_VALUE('ANALYSIS_FY',l_orgid_record_in_tbl);
16213        l_customer_tbl(l_rec).CURR_FY_POTENTIAL_REVENUE := Get_Element_VALUE('CURR_FY_POTENTIAL_REVENUE',l_orgid_record_in_tbl);
16214        l_customer_tbl(l_rec).NEXT_FY_POTENTIAL_REVENUE := Get_Element_VALUE('NEXT_FY_POTENTIAL_REVENUE',l_orgid_record_in_tbl);
16215        l_customer_tbl(l_rec).GSA_INDICATOR_FLAG := Get_Element_VALUE('GSA_INDICATOR_FLAG',l_orgid_record_in_tbl);
16216        l_customer_tbl(l_rec).MISSION_STATEMENT := Get_Element_VALUE('MISSION_STATEMENT',l_orgid_record_in_tbl);
16217        l_customer_tbl(l_rec).ORGANIZATION_NAME_PHONETIC := Get_Element_VALUE('ORGANIZATION_NAME_PHONETIC',l_orgid_record_in_tbl);
16218        l_customer_tbl(l_rec).CATEGORY_CODE := Get_Element_VALUE('CATEGORY_CODE',l_orgid_record_in_tbl);
16219        l_customer_tbl(l_rec).JGZZ_FISCAL_CODE := Get_Element_VALUE('JGZZ_FISCAL_CODE',l_orgid_record_in_tbl);
16220        l_customer_tbl(l_rec).PARTY_ID := Get_Element_VALUE('PARTY_ID',l_orgid_record_in_tbl);
16221 
16222 l_customer_tbl(l_rec).BRANCH_FLAG := Get_Element_VALUE('BRANCH_FLAG',l_orgid_record_in_tbl);
16223 l_customer_tbl(l_rec).BUSINESS_LINE := Get_Element_VALUE('BUSINESS_LINE',l_orgid_record_in_tbl);
16224 l_customer_tbl(l_rec).BUSINESS_SCOPE := Get_Element_VALUE('BUSINESS_SCOPE',l_orgid_record_in_tbl);
16225 l_customer_tbl(l_rec).CHIEF_EXECUTIVE_TITLE := Get_Element_VALUE('CHIEF_EXECUTIVE_TITLE',l_orgid_record_in_tbl);
16226 l_customer_tbl(l_rec).CONGRESSIONAL_DISTRICT_CODE := Get_Element_VALUE('CONGRESSIONAL_DISTRICT_CODE',l_orgid_record_in_tbl);
16227 l_customer_tbl(l_rec).CONTROL_YEAR := Get_Element_VALUE('CONTROL_YEAR',l_orgid_record_in_tbl);
16228 l_customer_tbl(l_rec).CORPORATION_CLASS := Get_Element_VALUE('CORPORATION_CLASS',l_orgid_record_in_tbl);
16229 l_customer_tbl(l_rec).CREDIT_SCORE := Get_Element_VALUE('CREDIT_SCORE',l_orgid_record_in_tbl);
16230 l_customer_tbl(l_rec).CREDIT_SCORE_COMMENTARY := Get_Element_VALUE('CREDIT_SCORE_COMMENTARY',l_orgid_record_in_tbl);
16231 l_customer_tbl(l_rec).CUSTOMER_CATEGORY := Get_Element_VALUE('CUSTOMER_CATEGORY',l_orgid_record_in_tbl);
16232 l_customer_tbl(l_rec).DB_RATING := Get_Element_VALUE('DB_RATING',l_orgid_record_in_tbl);
16233 l_customer_tbl(l_rec).DEBARMENTS_COUNT := Get_Element_VALUE('DEBARMENTS_COUNT',l_orgid_record_in_tbl);
16234 l_customer_tbl(l_rec).DEBARTMENTS_DATE := Get_Element_VALUE('DEBARTMENTS_DATE',l_orgid_record_in_tbl);
16235 l_customer_tbl(l_rec).DEPARTMENT_INDICATOR := Get_Element_VALUE('DEPARTMENT_INDICATOR',l_orgid_record_in_tbl);
16236 l_customer_tbl(l_rec).DISADVANTAGED_INDICATOR := Get_Element_VALUE('DISADVANTAGED_INDICATOR',l_orgid_record_in_tbl);
16237 l_customer_tbl(l_rec).ENQUIRY_DUNS := Get_Element_VALUE('ENQUIRY_DUNS',l_orgid_record_in_tbl);
16238 l_customer_tbl(l_rec).EXPORT_INDICATOR := Get_Element_VALUE('EXPORT_INDICATOR',l_orgid_record_in_tbl);
16239 l_customer_tbl(l_rec).FAILURE_SCORE := Get_Element_VALUE('FAILURE_SCORE',l_orgid_record_in_tbl);
16240 l_customer_tbl(l_rec).FAILURE_SCORE_COMMENTARY := Get_Element_VALUE('FAILURE_SCORE_COMMENTARY',l_orgid_record_in_tbl);
16241 l_customer_tbl(l_rec).FAILURE_SCORE_NATL_PERCENTILE := Get_Element_VALUE('FAILURE_SCORE_NATL_PERCENTILE',l_orgid_record_in_tbl);
16242 l_customer_tbl(l_rec).FAILURE_SCORE_OVERRIDE_CODE := Get_Element_VALUE('FAILURE_SCORE_OVERRIDE_CODE',l_orgid_record_in_tbl);
16243 l_customer_tbl(l_rec).GLOBAL_FAILURE_SCORE := Get_Element_VALUE('GLOBAL_FAILURE_SCORE',l_orgid_record_in_tbl);
16244 l_customer_tbl(l_rec).HEADQUARTER_BRANCH_INDICATOR := Get_Element_VALUE('HEADQUARTER_BRANCH_INDICATOR',l_orgid_record_in_tbl);
16245 l_customer_tbl(l_rec).IMPORT_INDICATOR := Get_Element_VALUE('IMPORT_INDICATOR',l_orgid_record_in_tbl);
16246 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS := Get_Element_VALUE('ORGANIZATION_KNOWN_AS',l_orgid_record_in_tbl);
16247 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS2 := Get_Element_VALUE('ORGANIZATION_KNOWN_AS2',l_orgid_record_in_tbl);
16248 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS3 := Get_Element_VALUE('ORGANIZATION_KNOWN_AS3',l_orgid_record_in_tbl);
16249 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS4 := Get_Element_VALUE('ORGANIZATION_KNOWN_AS4',l_orgid_record_in_tbl);
16250 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS5 := Get_Element_VALUE('ORGANIZATION_KNOWN_AS5',l_orgid_record_in_tbl);
16251 l_customer_tbl(l_rec).LABOR_SURPLUS_INDICATOR := Get_Element_VALUE('LABOR_SURPLUS_INDICATOR',l_orgid_record_in_tbl);
16252 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE := Get_Element_VALUE('LOCAL_ACTIVITY_CODE',l_orgid_record_in_tbl);
16253 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE_TYPE := Get_Element_VALUE('LOCAL_ACTIVITY_CODE_TYPE',l_orgid_record_in_tbl);
16254 l_customer_tbl(l_rec).MINORITY_OWNED_INDICATOR := Get_Element_VALUE('MINORITY_OWNED_INDICATOR',l_orgid_record_in_tbl);
16255 l_customer_tbl(l_rec).MINORITY_OWNED_TYPE := Get_Element_VALUE('MINORITY_OWNED_TYPE',l_orgid_record_in_tbl);
16256 l_customer_tbl(l_rec).ORGANIZATION_TYPE := Get_Element_VALUE('ORGANIZATION_TYPE',l_orgid_record_in_tbl);
16257 l_customer_tbl(l_rec).ORGANIZATION_URL := Get_Element_VALUE('ORGANIZATION_URL',l_orgid_record_in_tbl);
16258 l_customer_tbl(l_rec).OUT_OF_BUSINESS_INDICATOR := Get_Element_VALUE('OUT_OF_BUSINESS_INDICATOR',l_orgid_record_in_tbl);
16259 l_customer_tbl(l_rec).PRINCIPAL_NAME := Get_Element_VALUE('PRINCIPAL_NAME',l_orgid_record_in_tbl);
16260 l_customer_tbl(l_rec).PRINCIPAL_TITLE := Get_Element_VALUE('PRINCIPAL_TITLE',l_orgid_record_in_tbl);
16261 l_customer_tbl(l_rec).PUBLIC_PRIVATE_OWNERSHIP_FLAG := Get_Element_VALUE('PUBLIC_PRIVATE_OWNERSHIP_FLAG',l_orgid_record_in_tbl);
16262 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := Get_Element_VALUE('RENT_OWNED_INDICATOR',l_orgid_record_in_tbl);
16263 l_customer_tbl(l_rec).RENT_OWNER_INDICATOR := Get_Element_VALUE('RENT_OWNER_INDICATOR',l_orgid_record_in_tbl);
16264 l_customer_tbl(l_rec).SMALL_BUSINESS_INDICATOR := Get_Element_VALUE('SMALL_BUSINESS_INDICATOR',l_orgid_record_in_tbl);
16265 l_customer_tbl(l_rec).WOMAN_OWNED_INDICATOR := Get_Element_VALUE('WOMAN_OWNED_INDICATOR',l_orgid_record_in_tbl);
16266 l_customer_tbl(l_rec).ORG_ATTRIBUTE_CATEGORY := Get_Element_VALUE('ORG_ATTRIBUTE_CATEGORY',l_orgid_record_in_tbl);
16267 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE1 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE1',l_orgid_record_in_tbl);
16268 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE2 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE2',l_orgid_record_in_tbl);
16269 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE3 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE3',l_orgid_record_in_tbl);
16270 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE4 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE4',l_orgid_record_in_tbl);
16271 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE5 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE5',l_orgid_record_in_tbl);
16272 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE6 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE6',l_orgid_record_in_tbl);
16273 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE7 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE7',l_orgid_record_in_tbl);
16274 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE8 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE8',l_orgid_record_in_tbl);
16275 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE9 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE9',l_orgid_record_in_tbl);
16276 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE10 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE10',l_orgid_record_in_tbl);
16277 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE11 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE11',l_orgid_record_in_tbl);
16278 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE12 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE12',l_orgid_record_in_tbl);
16279 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE13 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE13',l_orgid_record_in_tbl);
16280 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE14 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE14',l_orgid_record_in_tbl);
16281 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE15 := Get_Element_VALUE('ORGANIZATION_ATTRIBUTE15',l_orgid_record_in_tbl);
16282 
16283 
16284 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := Get_Element_VALUE('VEHICLE_RESPONSE_CODE',l_orgid_record_in_tbl);
16285 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := Get_Element_VALUE('SALES_AGENT_EMAIL_ID',l_orgid_record_in_tbl);
16286 l_customer_tbl(l_rec).NOTES := Get_Element_VALUE('NOTES',l_orgid_record_in_tbl);
16287 
16288 
16289 
16290 /*
16291        -- dbms_output.put_line( ' cust_data_id '||l_customer_tbl(l_rec).cust_data_id);
16292        -- dbms_output.put_line( ' org_imp_xml_element_id '||l_customer_tbl(l_rec).org_imp_xml_element_id);
16293        -- dbms_output.put_line( ' Pat-name '||l_customer_tbl(l_rec).PARTY_NAME);
16294 */
16295        -- Process for location data.
16296        l_loc_element_id := Get_Element_ID('LOCATION',l_orgid_record_in_tbl);
16297        -- dbms_output.put_line( ' l_loc_element_id = '||to_char(l_loc_element_id));
16298 
16299     /********* Get all the elements for the location *****************************/
16300       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16301         p_imp_xml_element_id => l_loc_element_id,
16302         x_child_set          => l_locid_record_in_tbl,
16303         x_return_status      => x_return_status,
16304         x_msg_data           => x_msg_data);
16305        -- dbms_output.put_line( ' Location attribute count '||l_locid_record_in_tbl.COUNT);
16306        FOR i IN 1..l_locid_record_in_tbl.COUNT LOOP
16307         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16308         p_imp_xml_element_id => l_locid_record_in_tbl(i).imp_xml_element_id,
16309         x_child_set          => l_addid_record_in_tbl,
16310         x_return_status      => x_return_status,
16311         x_msg_data           => x_msg_data);
16312 
16313         l_rec := l_customer_tbl.count;
16314          if i > 1 then
16315              l_rec := l_customer_tbl.count+1;
16316              l_customer_tbl(l_rec).cust_data_id := l_rec;
16317              l_customer_tbl(l_rec).org_imp_xml_element_id := l_customer_tbl(l_rec - 1).org_imp_xml_element_id;
16318              l_customer_tbl(l_rec).party_name := l_customer_tbl(l_rec - 1).party_name;
16319              l_customer_tbl(l_rec).FISCAL_YEAREND_MONTH := l_customer_tbl(l_rec - 1).FISCAL_YEAREND_MONTH;
16320              l_customer_tbl(l_rec).DUNS_NUMBER := l_customer_tbl(l_rec - 1).DUNS_NUMBER;
16321              l_customer_tbl(l_rec).EMPLOYEES_TOTAL := l_customer_tbl(l_rec - 1).EMPLOYEES_TOTAL;
16322              l_customer_tbl(l_rec).LINE_OF_BUSINESS := l_customer_tbl(l_rec - 1).LINE_OF_BUSINESS;
16323              l_customer_tbl(l_rec).YEAR_ESTABLISHED := l_customer_tbl(l_rec - 1).YEAR_ESTABLISHED;
16324              l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
16325              l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
16326              l_customer_tbl(l_rec).CEO_NAME := l_customer_tbl(l_rec - 1).CEO_NAME;
16327              l_customer_tbl(l_rec).SIC_CODE := l_customer_tbl(l_rec - 1).SIC_CODE;
16328              l_customer_tbl(l_rec).SIC_CODE_TYPE := l_customer_tbl(l_rec - 1).SIC_CODE_TYPE;
16329              l_customer_tbl(l_rec).ANALYSIS_FY := l_customer_tbl(l_rec - 1).ANALYSIS_FY;
16330              l_customer_tbl(l_rec).CURR_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).CURR_FY_POTENTIAL_REVENUE;
16331              l_customer_tbl(l_rec).NEXT_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).NEXT_FY_POTENTIAL_REVENUE;
16332              l_customer_tbl(l_rec).GSA_INDICATOR_FLAG := l_customer_tbl(l_rec - 1).GSA_INDICATOR_FLAG;
16333              l_customer_tbl(l_rec).MISSION_STATEMENT := l_customer_tbl(l_rec - 1).MISSION_STATEMENT;
16334              l_customer_tbl(l_rec).ORGANIZATION_NAME_PHONETIC := l_customer_tbl(l_rec - 1).ORGANIZATION_NAME_PHONETIC;
16335              l_customer_tbl(l_rec).CATEGORY_CODE := l_customer_tbl(l_rec - 1).CATEGORY_CODE;
16336              l_customer_tbl(l_rec).JGZZ_FISCAL_CODE := l_customer_tbl(l_rec - 1).JGZZ_FISCAL_CODE;
16337              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
16338 l_customer_tbl(l_rec).BRANCH_FLAG := l_customer_tbl(l_rec - 1).BRANCH_FLAG;
16339 l_customer_tbl(l_rec).BUSINESS_LINE := l_customer_tbl(l_rec - 1).BUSINESS_LINE;
16340 l_customer_tbl(l_rec).BUSINESS_SCOPE := l_customer_tbl(l_rec - 1).BUSINESS_SCOPE;
16341 l_customer_tbl(l_rec).CHIEF_EXECUTIVE_TITLE := l_customer_tbl(l_rec - 1).CHIEF_EXECUTIVE_TITLE;
16342 l_customer_tbl(l_rec).CONGRESSIONAL_DISTRICT_CODE := l_customer_tbl(l_rec - 1).CONGRESSIONAL_DISTRICT_CODE;
16343 l_customer_tbl(l_rec).CONTROL_YEAR := l_customer_tbl(l_rec - 1).CONTROL_YEAR;
16344 l_customer_tbl(l_rec).CORPORATION_CLASS := l_customer_tbl(l_rec - 1).CORPORATION_CLASS;
16345 l_customer_tbl(l_rec).CREDIT_SCORE := l_customer_tbl(l_rec - 1).CREDIT_SCORE;
16346 l_customer_tbl(l_rec).CREDIT_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).CREDIT_SCORE_COMMENTARY;
16347 l_customer_tbl(l_rec).CUSTOMER_CATEGORY := l_customer_tbl(l_rec - 1).CUSTOMER_CATEGORY;
16348 l_customer_tbl(l_rec).DB_RATING := l_customer_tbl(l_rec - 1).DB_RATING;
16349 l_customer_tbl(l_rec).DEBARMENTS_COUNT := l_customer_tbl(l_rec - 1).DEBARMENTS_COUNT;
16350 l_customer_tbl(l_rec).DEBARTMENTS_DATE := l_customer_tbl(l_rec - 1).DEBARTMENTS_DATE;
16351 l_customer_tbl(l_rec).DEPARTMENT_INDICATOR := l_customer_tbl(l_rec - 1).DEPARTMENT_INDICATOR;
16352 l_customer_tbl(l_rec).DISADVANTAGED_INDICATOR := l_customer_tbl(l_rec - 1).DISADVANTAGED_INDICATOR;
16353 l_customer_tbl(l_rec).ENQUIRY_DUNS := l_customer_tbl(l_rec - 1).ENQUIRY_DUNS;
16354 l_customer_tbl(l_rec).EXPORT_INDICATOR := l_customer_tbl(l_rec - 1).EXPORT_INDICATOR;
16355 l_customer_tbl(l_rec).FAILURE_SCORE := l_customer_tbl(l_rec - 1).FAILURE_SCORE;
16356 l_customer_tbl(l_rec).FAILURE_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).FAILURE_SCORE_COMMENTARY;
16357 l_customer_tbl(l_rec).FAILURE_SCORE_NATL_PERCENTILE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_NATL_PERCENTILE;
16358 l_customer_tbl(l_rec).FAILURE_SCORE_OVERRIDE_CODE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_OVERRIDE_CODE;
16359 l_customer_tbl(l_rec).GLOBAL_FAILURE_SCORE := l_customer_tbl(l_rec - 1).GLOBAL_FAILURE_SCORE;
16360 l_customer_tbl(l_rec).HEADQUARTER_BRANCH_INDICATOR := l_customer_tbl(l_rec - 1).HEADQUARTER_BRANCH_INDICATOR;
16361 l_customer_tbl(l_rec).IMPORT_INDICATOR := l_customer_tbl(l_rec - 1).IMPORT_INDICATOR;
16362 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS;
16363 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS2 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS2;
16364 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS3 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS3;
16365 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS4 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS4;
16366 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS5 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS5;
16367 l_customer_tbl(l_rec).LABOR_SURPLUS_INDICATOR := l_customer_tbl(l_rec - 1).LABOR_SURPLUS_INDICATOR;
16368 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE;
16369 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE_TYPE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE_TYPE;
16370 l_customer_tbl(l_rec).MINORITY_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).MINORITY_OWNED_INDICATOR;
16371 l_customer_tbl(l_rec).MINORITY_OWNED_TYPE := l_customer_tbl(l_rec - 1).MINORITY_OWNED_TYPE;
16372 l_customer_tbl(l_rec).ORGANIZATION_TYPE := l_customer_tbl(l_rec - 1).ORGANIZATION_TYPE;
16373 l_customer_tbl(l_rec).ORGANIZATION_URL := l_customer_tbl(l_rec - 1).ORGANIZATION_URL;
16374 l_customer_tbl(l_rec).OUT_OF_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).OUT_OF_BUSINESS_INDICATOR;
16375 l_customer_tbl(l_rec).PRINCIPAL_NAME := l_customer_tbl(l_rec - 1).PRINCIPAL_NAME;
16376 l_customer_tbl(l_rec).PRINCIPAL_TITLE := l_customer_tbl(l_rec - 1).PRINCIPAL_TITLE;
16377 l_customer_tbl(l_rec).PUBLIC_PRIVATE_OWNERSHIP_FLAG := l_customer_tbl(l_rec - 1).PUBLIC_PRIVATE_OWNERSHIP_FLAG;
16378 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
16379 l_customer_tbl(l_rec).RENT_OWNER_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNER_INDICATOR;
16380 l_customer_tbl(l_rec).SMALL_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).SMALL_BUSINESS_INDICATOR;
16381 l_customer_tbl(l_rec).WOMAN_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).WOMAN_OWNED_INDICATOR;
16382 l_customer_tbl(l_rec).ORG_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ORG_ATTRIBUTE_CATEGORY;
16383 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE1;
16384 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE2;
16385 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE3;
16386 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE4;
16387 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE5;
16388 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE6;
16389 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE7;
16390 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE8;
16391 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE9;
16392 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE10;
16393 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE11;
16394 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE12;
16395 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE13;
16396 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE14;
16397 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE15;
16398 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
16399 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
16400 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
16401          end if;
16402          -- l_customer_tbl(l_rec).add_imp_xml_element_id := l_addid_record_in_tbl(i).imp_xml_element_id;
16403          l_customer_tbl(l_rec).add_imp_xml_element_id := l_locid_record_in_tbl(i).imp_xml_element_id;
16404          l_customer_tbl(l_rec).address1 := Get_Element_VALUE('ADDRESS1',l_addid_record_in_tbl);
16405          l_customer_tbl(l_rec).address2 := Get_Element_VALUE('ADDRESS2',l_addid_record_in_tbl);
16406          l_customer_tbl(l_rec).address3 := Get_Element_VALUE('ADDRESS3',l_addid_record_in_tbl);
16407          l_customer_tbl(l_rec).address4 := Get_Element_VALUE('ADDRESS4',l_addid_record_in_tbl);
16408          l_customer_tbl(l_rec).CITY := Get_Element_VALUE('CITY',l_addid_record_in_tbl);
16409          l_customer_tbl(l_rec).COUNTY := Get_Element_VALUE('COUNTY',l_addid_record_in_tbl);
16410          l_customer_tbl(l_rec).PROVINCE := Get_Element_VALUE('PROVINCE',l_addid_record_in_tbl);
16411          l_customer_tbl(l_rec).STATE := Get_Element_VALUE('STATE',l_addid_record_in_tbl);
16412          l_customer_tbl(l_rec).POSTAL_CODE := Get_Element_VALUE('POSTAL_CODE',l_addid_record_in_tbl);
16413          l_customer_tbl(l_rec).COUNTRY := Get_Element_VALUE('COUNTRY',l_addid_record_in_tbl);
16414          l_customer_tbl(l_rec).ADDRESS_LINES_PHONETIC := Get_Element_VALUE('ADDRESS_LINES_PHONETIC',l_addid_record_in_tbl);
16415 -- bug 4641591: columns obsolete
16416 --	 l_customer_tbl(l_rec).PO_BOX_NUMBER := Get_Element_VALUE('PO_BOX_NUMBER',l_addid_record_in_tbl);
16417 --         l_customer_tbl(l_rec).HOUSE_NUMBER := Get_Element_VALUE('HOUSE_NUMBER',l_addid_record_in_tbl);
16418 --         l_customer_tbl(l_rec).STREET_SUFFIX := Get_Element_VALUE('STREET_SUFFIX',l_addid_record_in_tbl);
16419 --         l_customer_tbl(l_rec).STREET := Get_Element_VALUE('STREET',l_addid_record_in_tbl);
16420 --         l_customer_tbl(l_rec).STREET_NUMBER := Get_Element_VALUE('STREET_NUMBER',l_addid_record_in_tbl);
16421 --         l_customer_tbl(l_rec).FLOOR := Get_Element_VALUE('FLOOR',l_addid_record_in_tbl);
16422 --         l_customer_tbl(l_rec).SUITE := Get_Element_VALUE('SUITE',l_addid_record_in_tbl);
16423          l_customer_tbl(l_rec).POSTAL_PLUS4_CODE := Get_Element_VALUE('POSTAL_PLUS4_CODE',l_addid_record_in_tbl);
16424          l_customer_tbl(l_rec).IDENTIFYING_ADDRESS_FLAG := Get_Element_VALUE('IDENTIFYING_ADDRESS_FLAG',l_addid_record_in_tbl);
16425 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := Get_Element_VALUE('ADDRESS_ATTRIBUTE1',l_addid_record_in_tbl);
16426 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := Get_Element_VALUE('ADDRESS_ATTRIBUTE2',l_addid_record_in_tbl);
16427 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := Get_Element_VALUE('ADDRESS_ATTRIBUTE3',l_addid_record_in_tbl);
16428 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := Get_Element_VALUE('ADDRESS_ATTRIBUTE4',l_addid_record_in_tbl);
16429 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := Get_Element_VALUE('ADDRESS_ATTRIBUTE5',l_addid_record_in_tbl);
16430 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := Get_Element_VALUE('ADDRESS_ATTRIBUTE6',l_addid_record_in_tbl);
16431 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := Get_Element_VALUE('ADDRESS_ATTRIBUTE7',l_addid_record_in_tbl);
16432 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := Get_Element_VALUE('ADDRESS_ATTRIBUTE8',l_addid_record_in_tbl);
16433 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := Get_Element_VALUE('ADDRESS_ATTRIBUTE9',l_addid_record_in_tbl);
16434 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := Get_Element_VALUE('ADDRESS_ATTRIBUTE10',l_addid_record_in_tbl);
16435 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := Get_Element_VALUE('ADDRESS_ATTRIBUTE11',l_addid_record_in_tbl);
16436 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := Get_Element_VALUE('ADDRESS_ATTRIBUTE12',l_addid_record_in_tbl);
16437 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := Get_Element_VALUE('ADDRESS_ATTRIBUTE13',l_addid_record_in_tbl);
16438 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := Get_Element_VALUE('ADDRESS_ATTRIBUTE14',l_addid_record_in_tbl);
16439 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := Get_Element_VALUE('ADDRESS_ATTRIBUTE15',l_addid_record_in_tbl);
16440 l_customer_tbl(l_rec).DESCRIPTION := Get_Element_VALUE('DESCRIPTION',l_addid_record_in_tbl);
16441 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := Get_Element_VALUE('ADDRESS_ATTRIBUTE_CATEGORY',l_addid_record_in_tbl);
16442 l_customer_tbl(l_rec).PARTY_SITE_USE := Get_Element_VALUE('PARTY_SITE_USE',l_addid_record_in_tbl);
16443 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := Get_Element_VALUE('LOCATION_DIRECTIONS',l_addid_record_in_tbl);
16444 l_customer_tbl(l_rec).SHORT_DESCRIPTION := Get_Element_VALUE('SHORT_DESCRIPTION',l_addid_record_in_tbl);
16445 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := Get_Element_VALUE('ADDRESS_EFFECTIVE_DATE',l_addid_record_in_tbl);
16446 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := Get_Element_VALUE('ADDRESS_EXPIRATION_DATE',l_addid_record_in_tbl);
16447 
16448          l_rec := 0;
16449      -- ****************************** End Location process
16450 
16451        -- Process for Org Contact data.
16452        l_oct_element_id := Get_Element_ID('ORG_CONTACT',l_addid_record_in_tbl);
16453        -- dbms_output.put_line( ' l_oct_element_id = '||to_char(l_oct_element_id));
16454 
16455     /********* Get all the elements for Org Contact *****************************/
16456       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16457         p_imp_xml_element_id => l_oct_element_id,
16458         x_child_set          => l_octid_record_in_tbl,
16459         x_return_status      => x_return_status,
16460         x_msg_data           => x_msg_data);
16461        -- dbms_output.put_line( ' Org Con attribute count '||l_octid_record_in_tbl.COUNT);
16462        FOR j IN 1..l_octid_record_in_tbl.COUNT LOOP
16463         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16464         p_imp_xml_element_id => l_octid_record_in_tbl(j).imp_xml_element_id,
16465         x_child_set          => l_conid_record_in_tbl,
16466         x_return_status      => x_return_status,
16467         x_msg_data           => x_msg_data);
16468 
16469         l_rec := l_customer_tbl.count;
16470          if j > 1 then
16471              l_rec := l_customer_tbl.count+1;
16472              l_customer_tbl(l_rec).cust_data_id := l_rec;
16473              l_customer_tbl(l_rec).org_imp_xml_element_id := l_customer_tbl(l_rec - 1).org_imp_xml_element_id;
16474              l_customer_tbl(l_rec).party_name := l_customer_tbl(l_rec - 1).party_name;
16475              l_customer_tbl(l_rec).FISCAL_YEAREND_MONTH := l_customer_tbl(l_rec - 1).FISCAL_YEAREND_MONTH;
16476              l_customer_tbl(l_rec).DUNS_NUMBER := l_customer_tbl(l_rec - 1).DUNS_NUMBER;
16477              l_customer_tbl(l_rec).EMPLOYEES_TOTAL := l_customer_tbl(l_rec - 1).EMPLOYEES_TOTAL;
16478              l_customer_tbl(l_rec).LINE_OF_BUSINESS := l_customer_tbl(l_rec - 1).LINE_OF_BUSINESS;
16479              l_customer_tbl(l_rec).YEAR_ESTABLISHED := l_customer_tbl(l_rec - 1).YEAR_ESTABLISHED;
16480              l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
16481              l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
16482              l_customer_tbl(l_rec).CEO_NAME := l_customer_tbl(l_rec - 1).CEO_NAME;
16483              l_customer_tbl(l_rec).SIC_CODE := l_customer_tbl(l_rec - 1).SIC_CODE;
16484              l_customer_tbl(l_rec).SIC_CODE_TYPE := l_customer_tbl(l_rec - 1).SIC_CODE_TYPE;
16485              l_customer_tbl(l_rec).ANALYSIS_FY := l_customer_tbl(l_rec - 1).ANALYSIS_FY;
16486              l_customer_tbl(l_rec).CURR_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).CURR_FY_POTENTIAL_REVENUE;
16487              l_customer_tbl(l_rec).NEXT_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).NEXT_FY_POTENTIAL_REVENUE;
16488              l_customer_tbl(l_rec).GSA_INDICATOR_FLAG := l_customer_tbl(l_rec - 1).GSA_INDICATOR_FLAG;
16489              l_customer_tbl(l_rec).MISSION_STATEMENT := l_customer_tbl(l_rec - 1).MISSION_STATEMENT;
16490              l_customer_tbl(l_rec).ORGANIZATION_NAME_PHONETIC := l_customer_tbl(l_rec - 1).ORGANIZATION_NAME_PHONETIC;
16491              l_customer_tbl(l_rec).CATEGORY_CODE := l_customer_tbl(l_rec - 1).CATEGORY_CODE;
16492              l_customer_tbl(l_rec).JGZZ_FISCAL_CODE := l_customer_tbl(l_rec - 1).JGZZ_FISCAL_CODE;
16493              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
16494 l_customer_tbl(l_rec).BRANCH_FLAG := l_customer_tbl(l_rec - 1).BRANCH_FLAG;
16495 l_customer_tbl(l_rec).BUSINESS_LINE := l_customer_tbl(l_rec - 1).BUSINESS_LINE;
16496 l_customer_tbl(l_rec).BUSINESS_SCOPE := l_customer_tbl(l_rec - 1).BUSINESS_SCOPE;
16497 l_customer_tbl(l_rec).CHIEF_EXECUTIVE_TITLE := l_customer_tbl(l_rec - 1).CHIEF_EXECUTIVE_TITLE;
16498 l_customer_tbl(l_rec).CONGRESSIONAL_DISTRICT_CODE := l_customer_tbl(l_rec - 1).CONGRESSIONAL_DISTRICT_CODE;
16499 l_customer_tbl(l_rec).CONTROL_YEAR := l_customer_tbl(l_rec - 1).CONTROL_YEAR;
16500 l_customer_tbl(l_rec).CORPORATION_CLASS := l_customer_tbl(l_rec - 1).CORPORATION_CLASS;
16501 l_customer_tbl(l_rec).CREDIT_SCORE := l_customer_tbl(l_rec - 1).CREDIT_SCORE;
16502 l_customer_tbl(l_rec).CREDIT_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).CREDIT_SCORE_COMMENTARY;
16503 l_customer_tbl(l_rec).CUSTOMER_CATEGORY := l_customer_tbl(l_rec - 1).CUSTOMER_CATEGORY;
16504 l_customer_tbl(l_rec).DB_RATING := l_customer_tbl(l_rec - 1).DB_RATING;
16505 l_customer_tbl(l_rec).DEBARMENTS_COUNT := l_customer_tbl(l_rec - 1).DEBARMENTS_COUNT;
16506 l_customer_tbl(l_rec).DEBARTMENTS_DATE := l_customer_tbl(l_rec - 1).DEBARTMENTS_DATE;
16507 l_customer_tbl(l_rec).DEPARTMENT_INDICATOR := l_customer_tbl(l_rec - 1).DEPARTMENT_INDICATOR;
16508 l_customer_tbl(l_rec).DISADVANTAGED_INDICATOR := l_customer_tbl(l_rec - 1).DISADVANTAGED_INDICATOR;
16509 l_customer_tbl(l_rec).ENQUIRY_DUNS := l_customer_tbl(l_rec - 1).ENQUIRY_DUNS;
16510 l_customer_tbl(l_rec).EXPORT_INDICATOR := l_customer_tbl(l_rec - 1).EXPORT_INDICATOR;
16511 l_customer_tbl(l_rec).FAILURE_SCORE := l_customer_tbl(l_rec - 1).FAILURE_SCORE;
16512 l_customer_tbl(l_rec).FAILURE_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).FAILURE_SCORE_COMMENTARY;
16513 l_customer_tbl(l_rec).FAILURE_SCORE_NATL_PERCENTILE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_NATL_PERCENTILE;
16514 l_customer_tbl(l_rec).FAILURE_SCORE_OVERRIDE_CODE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_OVERRIDE_CODE;
16515 l_customer_tbl(l_rec).GLOBAL_FAILURE_SCORE := l_customer_tbl(l_rec - 1).GLOBAL_FAILURE_SCORE;
16516 l_customer_tbl(l_rec).HEADQUARTER_BRANCH_INDICATOR := l_customer_tbl(l_rec - 1).HEADQUARTER_BRANCH_INDICATOR;
16517 l_customer_tbl(l_rec).IMPORT_INDICATOR := l_customer_tbl(l_rec - 1).IMPORT_INDICATOR;
16518 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS;
16519 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS2 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS2;
16520 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS3 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS3;
16521 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS4 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS4;
16522 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS5 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS5;
16523 l_customer_tbl(l_rec).LABOR_SURPLUS_INDICATOR := l_customer_tbl(l_rec - 1).LABOR_SURPLUS_INDICATOR;
16524 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE;
16525 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE_TYPE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE_TYPE;
16526 l_customer_tbl(l_rec).MINORITY_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).MINORITY_OWNED_INDICATOR;
16527 l_customer_tbl(l_rec).MINORITY_OWNED_TYPE := l_customer_tbl(l_rec - 1).MINORITY_OWNED_TYPE;
16528 l_customer_tbl(l_rec).ORGANIZATION_TYPE := l_customer_tbl(l_rec - 1).ORGANIZATION_TYPE;
16529 l_customer_tbl(l_rec).ORGANIZATION_URL := l_customer_tbl(l_rec - 1).ORGANIZATION_URL;
16530 l_customer_tbl(l_rec).OUT_OF_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).OUT_OF_BUSINESS_INDICATOR;
16531 l_customer_tbl(l_rec).PRINCIPAL_NAME := l_customer_tbl(l_rec - 1).PRINCIPAL_NAME;
16532 l_customer_tbl(l_rec).PRINCIPAL_TITLE := l_customer_tbl(l_rec - 1).PRINCIPAL_TITLE;
16533 l_customer_tbl(l_rec).PUBLIC_PRIVATE_OWNERSHIP_FLAG := l_customer_tbl(l_rec - 1).PUBLIC_PRIVATE_OWNERSHIP_FLAG;
16534 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
16535 l_customer_tbl(l_rec).RENT_OWNER_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNER_INDICATOR;
16536 l_customer_tbl(l_rec).SMALL_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).SMALL_BUSINESS_INDICATOR;
16537 l_customer_tbl(l_rec).WOMAN_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).WOMAN_OWNED_INDICATOR;
16538 l_customer_tbl(l_rec).ORG_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ORG_ATTRIBUTE_CATEGORY;
16539 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE1;
16540 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE2;
16541 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE3;
16542 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE4;
16543 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE5;
16544 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE6;
16545 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE7;
16546 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE8;
16547 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE9;
16548 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE10;
16549 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE11;
16550 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE12;
16551 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE13;
16552 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE14;
16553 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE15;
16554 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
16555 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
16556 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
16557 
16558 
16559 
16560              l_customer_tbl(l_rec).add_imp_xml_element_id := l_customer_tbl(l_rec - 1).add_imp_xml_element_id;
16561              l_customer_tbl(l_rec).address1 := l_customer_tbl(l_rec - 1).address1;
16562              l_customer_tbl(l_rec).address2 := l_customer_tbl(l_rec - 1).address2;
16563              l_customer_tbl(l_rec).address3 := l_customer_tbl(l_rec - 1).address3;
16564              l_customer_tbl(l_rec).address4 := l_customer_tbl(l_rec - 1).address4;
16565              l_customer_tbl(l_rec).city := l_customer_tbl(l_rec - 1).city;
16566              l_customer_tbl(l_rec).county := l_customer_tbl(l_rec - 1).county;
16567              l_customer_tbl(l_rec).province := l_customer_tbl(l_rec - 1).province;
16568              l_customer_tbl(l_rec).state := l_customer_tbl(l_rec - 1).state;
16569              l_customer_tbl(l_rec).postal_code := l_customer_tbl(l_rec - 1).postal_code;
16570              l_customer_tbl(l_rec).country  := l_customer_tbl(l_rec - 1).country;
16571              l_customer_tbl(l_rec).address_lines_phonetic := l_customer_tbl(l_rec - 1).address_lines_phonetic;
16572 -- bug 4641591: columns obsolete
16573 --	     l_customer_tbl(l_rec).po_box_number := l_customer_tbl(l_rec - 1).po_box_number;
16574 --             l_customer_tbl(l_rec).house_number := l_customer_tbl(l_rec - 1).house_number;
16575 --             l_customer_tbl(l_rec).street_suffix := l_customer_tbl(l_rec - 1).street_suffix;
16576 --             l_customer_tbl(l_rec).street := l_customer_tbl(l_rec - 1).street;
16577 --             l_customer_tbl(l_rec).street_number := l_customer_tbl(l_rec - 1).street_number;
16578 --             l_customer_tbl(l_rec).floor := l_customer_tbl(l_rec - 1).floor;
16579 --             l_customer_tbl(l_rec).suite := l_customer_tbl(l_rec - 1).suite;
16580              l_customer_tbl(l_rec).postal_plus4_code := l_customer_tbl(l_rec - 1).postal_plus4_code;
16581              l_customer_tbl(l_rec).identifying_address_flag := l_customer_tbl(l_rec - 1).identifying_address_flag;
16582 
16583 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE1;
16584 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE2;
16585 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE3;
16586 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE4;
16587 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE5;
16588 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE6;
16589 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE7;
16590 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE8;
16591 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE9;
16592 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE10;
16593 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE11;
16594 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE12;
16595 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE13;
16596 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE14;
16597 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE15;
16598 l_customer_tbl(l_rec).DESCRIPTION := l_customer_tbl(l_rec - 1).DESCRIPTION;
16599 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE_CATEGORY;
16600 l_customer_tbl(l_rec).PARTY_SITE_USE := l_customer_tbl(l_rec - 1).PARTY_SITE_USE;
16601 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := l_customer_tbl(l_rec - 1).LOCATION_DIRECTIONS;
16602 l_customer_tbl(l_rec).SHORT_DESCRIPTION := l_customer_tbl(l_rec - 1).SHORT_DESCRIPTION;
16603 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EFFECTIVE_DATE;
16604 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EXPIRATION_DATE;
16605 
16606          end if;
16607          -- l_customer_tbl(l_rec).ocont_imp_xml_element_id := l_conid_record_in_tbl(i).imp_xml_element_id;
16608          l_customer_tbl(l_rec).ocont_imp_xml_element_id := l_octid_record_in_tbl(j).imp_xml_element_id;
16609          l_customer_tbl(l_rec).person_first_name := Get_Element_VALUE('PERSON_FIRST_NAME',l_conid_record_in_tbl);
16610          l_customer_tbl(l_rec).person_last_name := Get_Element_VALUE('PERSON_LAST_NAME',l_conid_record_in_tbl);
16611          l_customer_tbl(l_rec).person_middle_name := Get_Element_VALUE('PERSON_MIDDLE_NAME',l_conid_record_in_tbl);
16612          l_customer_tbl(l_rec).person_name_suffix := Get_Element_VALUE('PERSON_NAME_SUFFIX',l_conid_record_in_tbl);
16613          l_customer_tbl(l_rec).PERSON_NAME_PREFIX := Get_Element_VALUE('PERSON_NAME_PREFIX',l_conid_record_in_tbl);
16614          l_customer_tbl(l_rec).department := Get_Element_VALUE('DEPARTMENT',l_conid_record_in_tbl);
16615          l_customer_tbl(l_rec).job_title := Get_Element_VALUE('JOB_TITLE',l_conid_record_in_tbl);
16616          l_customer_tbl(l_rec).decision_maker_flag := Get_Element_VALUE('DECISION_MAKER_FLAG',l_conid_record_in_tbl);
16617 
16618 
16619 
16620 l_customer_tbl(l_rec).PERSONAL_INCOME := Get_Element_VALUE('PERSONAL_INCOME',l_conid_record_in_tbl);
16621 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := Get_Element_VALUE('PERSON_ACADEMIC_TITLE',l_conid_record_in_tbl);
16622 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := Get_Element_VALUE('PERSON_FIRST_NAME_PHONETIC',l_conid_record_in_tbl);
16623 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := Get_Element_VALUE('PERSON_LAST_NAME_PHONETIC',l_conid_record_in_tbl);
16624 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := Get_Element_VALUE('MIDDLE_NAME_PHONETIC',l_conid_record_in_tbl);
16625 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := Get_Element_VALUE('PERSON_NAME_PHONETIC',l_conid_record_in_tbl);
16626 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := Get_Element_VALUE('PERSON_PREVIOUS_TITLE_NAME',l_conid_record_in_tbl);
16627 l_customer_tbl(l_rec).PLACE_OF_BIRTH := Get_Element_VALUE('PLACE_OF_BIRTH',l_conid_record_in_tbl);
16628 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := Get_Element_VALUE('HEAD_OF_HOUSEHOLD_FLAG',l_conid_record_in_tbl);
16629 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := Get_Element_VALUE('HOUSEHOLD_SIZE',l_conid_record_in_tbl);
16630 l_customer_tbl(l_rec).TAX_ID := Get_Element_VALUE('TAX_ID',l_conid_record_in_tbl);
16631 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE_CATEGORY := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE_CATEGORY',l_conid_record_in_tbl);
16632 l_customer_tbl(l_rec).DATE_OF_BIRTH := Get_Element_VALUE('DATE_OF_BIRTH',l_conid_record_in_tbl);
16633 l_customer_tbl(l_rec).DATE_OF_DEATH := Get_Element_VALUE('DATE_OF_DEATH',l_conid_record_in_tbl);
16634 l_customer_tbl(l_rec).DECLARED_ETHNICITY := Get_Element_VALUE('DECLARED_ETHNICITY',l_conid_record_in_tbl);
16635 l_customer_tbl(l_rec).MARITAL_STATUS := Get_Element_VALUE('MARITAL_STATUS',l_conid_record_in_tbl);
16636 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := Get_Element_VALUE('MARITAL_STATUS_EFFECTIVE_DATE',l_conid_record_in_tbl);
16637 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE1 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE1',l_conid_record_in_tbl);
16638 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE2 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE2',l_conid_record_in_tbl);
16639 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE3 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE3',l_conid_record_in_tbl);
16640 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE4 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE4',l_conid_record_in_tbl);
16641 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE5 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE5',l_conid_record_in_tbl);
16642 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE6 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE6',l_conid_record_in_tbl);
16643 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE7 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE7',l_conid_record_in_tbl);
16644 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE8 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE8',l_conid_record_in_tbl);
16645 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE9 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE9',l_conid_record_in_tbl);
16646 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE10 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE10',l_conid_record_in_tbl);
16647 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE11 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE11',l_conid_record_in_tbl);
16648 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE12 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE12',l_conid_record_in_tbl);
16649 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE13 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE13',l_conid_record_in_tbl);
16650 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE14 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE14',l_conid_record_in_tbl);
16651 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE15 := Get_Element_VALUE('ORG_CONTACT_ATTRIBUTE15',l_conid_record_in_tbl);
16652 
16653          l_rec := 0;
16654 
16655 
16656        -- Process  of Phone data.
16657        l_pho_element_id := Get_Element_ID('PHONE',l_conid_record_in_tbl);
16658        -- dbms_output.put_line( ' l_pho_element_id = '||to_char(l_pho_element_id));
16659 
16660     /********* Get all the elements for phone *****************************/
16661       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16662         p_imp_xml_element_id => l_pho_element_id,
16663         x_child_set          => l_phoid_record_in_tbl,
16664         x_return_status      => x_return_status,
16665         x_msg_data           => x_msg_data);
16666  --      dbms_output.put_line( ' Phone attribute count '||l_phoid_record_in_tbl.COUNT);
16667        FOR k IN 1..l_phoid_record_in_tbl.COUNT LOOP
16668         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16669         p_imp_xml_element_id => l_phoid_record_in_tbl(k).imp_xml_element_id,
16670         x_child_set          => l_phiid_record_in_tbl,
16671         x_return_status      => x_return_status,
16672         x_msg_data           => x_msg_data);
16673 
16674         l_rec := l_customer_tbl.count;
16675          if k > 1 then
16676              l_rec := l_customer_tbl.count+1;
16677              l_customer_tbl(l_rec).cust_data_id := l_rec;
16678              l_customer_tbl(l_rec).org_imp_xml_element_id := l_customer_tbl(l_rec - 1).org_imp_xml_element_id;
16679              l_customer_tbl(l_rec).party_name := l_customer_tbl(l_rec - 1).party_name;
16680              l_customer_tbl(l_rec).FISCAL_YEAREND_MONTH := l_customer_tbl(l_rec - 1).FISCAL_YEAREND_MONTH;
16681              l_customer_tbl(l_rec).DUNS_NUMBER := l_customer_tbl(l_rec - 1).DUNS_NUMBER;
16682              l_customer_tbl(l_rec).EMPLOYEES_TOTAL := l_customer_tbl(l_rec - 1).EMPLOYEES_TOTAL;
16683              l_customer_tbl(l_rec).LINE_OF_BUSINESS := l_customer_tbl(l_rec - 1).LINE_OF_BUSINESS;
16684              l_customer_tbl(l_rec).YEAR_ESTABLISHED := l_customer_tbl(l_rec - 1).YEAR_ESTABLISHED;
16685              l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
16686              l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
16687              l_customer_tbl(l_rec).CEO_NAME := l_customer_tbl(l_rec - 1).CEO_NAME;
16688              l_customer_tbl(l_rec).SIC_CODE := l_customer_tbl(l_rec - 1).SIC_CODE;
16689              l_customer_tbl(l_rec).SIC_CODE_TYPE := l_customer_tbl(l_rec - 1).SIC_CODE_TYPE;
16690              l_customer_tbl(l_rec).ANALYSIS_FY := l_customer_tbl(l_rec - 1).ANALYSIS_FY;
16691              l_customer_tbl(l_rec).CURR_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).CURR_FY_POTENTIAL_REVENUE;
16692              l_customer_tbl(l_rec).NEXT_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).NEXT_FY_POTENTIAL_REVENUE;
16693              l_customer_tbl(l_rec).GSA_INDICATOR_FLAG := l_customer_tbl(l_rec - 1).GSA_INDICATOR_FLAG;
16694              l_customer_tbl(l_rec).MISSION_STATEMENT := l_customer_tbl(l_rec - 1).MISSION_STATEMENT;
16695              l_customer_tbl(l_rec).ORGANIZATION_NAME_PHONETIC := l_customer_tbl(l_rec - 1).ORGANIZATION_NAME_PHONETIC;
16696              l_customer_tbl(l_rec).CATEGORY_CODE := l_customer_tbl(l_rec - 1).CATEGORY_CODE;
16697              l_customer_tbl(l_rec).JGZZ_FISCAL_CODE := l_customer_tbl(l_rec - 1).JGZZ_FISCAL_CODE;
16698              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
16699 l_customer_tbl(l_rec).BRANCH_FLAG := l_customer_tbl(l_rec - 1).BRANCH_FLAG;
16700 l_customer_tbl(l_rec).BUSINESS_LINE := l_customer_tbl(l_rec - 1).BUSINESS_LINE;
16701 l_customer_tbl(l_rec).BUSINESS_SCOPE := l_customer_tbl(l_rec - 1).BUSINESS_SCOPE;
16702 l_customer_tbl(l_rec).CHIEF_EXECUTIVE_TITLE := l_customer_tbl(l_rec - 1).CHIEF_EXECUTIVE_TITLE;
16703 l_customer_tbl(l_rec).CONGRESSIONAL_DISTRICT_CODE := l_customer_tbl(l_rec - 1).CONGRESSIONAL_DISTRICT_CODE;
16704 l_customer_tbl(l_rec).CONTROL_YEAR := l_customer_tbl(l_rec - 1).CONTROL_YEAR;
16705 l_customer_tbl(l_rec).CORPORATION_CLASS := l_customer_tbl(l_rec - 1).CORPORATION_CLASS;
16706 l_customer_tbl(l_rec).CREDIT_SCORE := l_customer_tbl(l_rec - 1).CREDIT_SCORE;
16707 l_customer_tbl(l_rec).CREDIT_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).CREDIT_SCORE_COMMENTARY;
16708 l_customer_tbl(l_rec).CUSTOMER_CATEGORY := l_customer_tbl(l_rec - 1).CUSTOMER_CATEGORY;
16709 l_customer_tbl(l_rec).DB_RATING := l_customer_tbl(l_rec - 1).DB_RATING;
16710 l_customer_tbl(l_rec).DEBARMENTS_COUNT := l_customer_tbl(l_rec - 1).DEBARMENTS_COUNT;
16711 l_customer_tbl(l_rec).DEBARTMENTS_DATE := l_customer_tbl(l_rec - 1).DEBARTMENTS_DATE;
16712 l_customer_tbl(l_rec).DEPARTMENT_INDICATOR := l_customer_tbl(l_rec - 1).DEPARTMENT_INDICATOR;
16713 l_customer_tbl(l_rec).DISADVANTAGED_INDICATOR := l_customer_tbl(l_rec - 1).DISADVANTAGED_INDICATOR;
16714 l_customer_tbl(l_rec).ENQUIRY_DUNS := l_customer_tbl(l_rec - 1).ENQUIRY_DUNS;
16715 l_customer_tbl(l_rec).EXPORT_INDICATOR := l_customer_tbl(l_rec - 1).EXPORT_INDICATOR;
16716 l_customer_tbl(l_rec).FAILURE_SCORE := l_customer_tbl(l_rec - 1).FAILURE_SCORE;
16717 l_customer_tbl(l_rec).FAILURE_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).FAILURE_SCORE_COMMENTARY;
16718 l_customer_tbl(l_rec).FAILURE_SCORE_NATL_PERCENTILE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_NATL_PERCENTILE;
16719 l_customer_tbl(l_rec).FAILURE_SCORE_OVERRIDE_CODE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_OVERRIDE_CODE;
16720 l_customer_tbl(l_rec).GLOBAL_FAILURE_SCORE := l_customer_tbl(l_rec - 1).GLOBAL_FAILURE_SCORE;
16721 l_customer_tbl(l_rec).HEADQUARTER_BRANCH_INDICATOR := l_customer_tbl(l_rec - 1).HEADQUARTER_BRANCH_INDICATOR;
16722 l_customer_tbl(l_rec).IMPORT_INDICATOR := l_customer_tbl(l_rec - 1).IMPORT_INDICATOR;
16723 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS;
16724 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS2 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS2;
16725 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS3 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS3;
16726 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS4 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS4;
16727 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS5 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS5;
16728 l_customer_tbl(l_rec).LABOR_SURPLUS_INDICATOR := l_customer_tbl(l_rec - 1).LABOR_SURPLUS_INDICATOR;
16729 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE;
16730 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE_TYPE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE_TYPE;
16731 l_customer_tbl(l_rec).MINORITY_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).MINORITY_OWNED_INDICATOR;
16732 l_customer_tbl(l_rec).MINORITY_OWNED_TYPE := l_customer_tbl(l_rec - 1).MINORITY_OWNED_TYPE;
16733 l_customer_tbl(l_rec).ORGANIZATION_TYPE := l_customer_tbl(l_rec - 1).ORGANIZATION_TYPE;
16734 l_customer_tbl(l_rec).ORGANIZATION_URL := l_customer_tbl(l_rec - 1).ORGANIZATION_URL;
16735 l_customer_tbl(l_rec).OUT_OF_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).OUT_OF_BUSINESS_INDICATOR;
16736 l_customer_tbl(l_rec).PRINCIPAL_NAME := l_customer_tbl(l_rec - 1).PRINCIPAL_NAME;
16737 l_customer_tbl(l_rec).PRINCIPAL_TITLE := l_customer_tbl(l_rec - 1).PRINCIPAL_TITLE;
16738 l_customer_tbl(l_rec).PUBLIC_PRIVATE_OWNERSHIP_FLAG := l_customer_tbl(l_rec - 1).PUBLIC_PRIVATE_OWNERSHIP_FLAG;
16739 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
16740 l_customer_tbl(l_rec).RENT_OWNER_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNER_INDICATOR;
16741 l_customer_tbl(l_rec).SMALL_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).SMALL_BUSINESS_INDICATOR;
16742 l_customer_tbl(l_rec).WOMAN_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).WOMAN_OWNED_INDICATOR;
16743 l_customer_tbl(l_rec).ORG_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ORG_ATTRIBUTE_CATEGORY;
16744 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE1;
16745 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE2;
16746 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE3;
16747 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE4;
16748 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE5;
16749 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE6;
16750 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE7;
16751 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE8;
16752 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE9;
16753 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE10;
16754 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE11;
16755 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE12;
16756 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE13;
16757 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE14;
16758 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE15;
16759 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
16760 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
16761 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
16762 
16763 
16764 
16765              l_customer_tbl(l_rec).add_imp_xml_element_id := l_customer_tbl(l_rec - 1).add_imp_xml_element_id;
16766              l_customer_tbl(l_rec).address1 := l_customer_tbl(l_rec - 1).address1;
16767              l_customer_tbl(l_rec).address2 := l_customer_tbl(l_rec - 1).address2;
16768              l_customer_tbl(l_rec).address3 := l_customer_tbl(l_rec - 1).address3;
16769              l_customer_tbl(l_rec).address4 := l_customer_tbl(l_rec - 1).address4;
16770              l_customer_tbl(l_rec).city := l_customer_tbl(l_rec - 1).city;
16771              l_customer_tbl(l_rec).county := l_customer_tbl(l_rec - 1).county;
16772              l_customer_tbl(l_rec).province := l_customer_tbl(l_rec - 1).province;
16773              l_customer_tbl(l_rec).state := l_customer_tbl(l_rec - 1).state;
16774              l_customer_tbl(l_rec).postal_code := l_customer_tbl(l_rec - 1).postal_code;
16775              l_customer_tbl(l_rec).country  := l_customer_tbl(l_rec - 1).country;
16776              l_customer_tbl(l_rec).address_lines_phonetic := l_customer_tbl(l_rec - 1).address_lines_phonetic;
16777 -- bug 4641591: columns obsolete
16778 --	     l_customer_tbl(l_rec).po_box_number := l_customer_tbl(l_rec - 1).po_box_number;
16779 --             l_customer_tbl(l_rec).house_number := l_customer_tbl(l_rec - 1).house_number;
16780 --             l_customer_tbl(l_rec).street_suffix := l_customer_tbl(l_rec - 1).street_suffix;
16781 --             l_customer_tbl(l_rec).street := l_customer_tbl(l_rec - 1).street;
16782 --             l_customer_tbl(l_rec).street_number := l_customer_tbl(l_rec - 1).street_number;
16783 --             l_customer_tbl(l_rec).floor := l_customer_tbl(l_rec - 1).floor;
16784 --             l_customer_tbl(l_rec).suite := l_customer_tbl(l_rec - 1).suite;
16785              l_customer_tbl(l_rec).postal_plus4_code := l_customer_tbl(l_rec - 1).postal_plus4_code;
16786              l_customer_tbl(l_rec).identifying_address_flag := l_customer_tbl(l_rec - 1).identifying_address_flag;
16787 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE1;
16788 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE2;
16789 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE3;
16790 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE4;
16791 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE5;
16792 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE6;
16793 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE7;
16794 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE8;
16795 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE9;
16796 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE10;
16797 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE11;
16798 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE12;
16799 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE13;
16800 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE14;
16801 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE15;
16802 l_customer_tbl(l_rec).DESCRIPTION := l_customer_tbl(l_rec - 1).DESCRIPTION;
16803 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE_CATEGORY;
16804 l_customer_tbl(l_rec).PARTY_SITE_USE := l_customer_tbl(l_rec - 1).PARTY_SITE_USE;
16805 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := l_customer_tbl(l_rec - 1).LOCATION_DIRECTIONS;
16806 l_customer_tbl(l_rec).SHORT_DESCRIPTION := l_customer_tbl(l_rec - 1).SHORT_DESCRIPTION;
16807 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EFFECTIVE_DATE;
16808 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EXPIRATION_DATE;
16809 
16810 
16811              l_customer_tbl(l_rec).ocont_imp_xml_element_id := l_customer_tbl(l_rec - 1).ocont_imp_xml_element_id;
16812              l_customer_tbl(l_rec).person_first_name := l_customer_tbl(l_rec - 1).person_first_name;
16813              l_customer_tbl(l_rec).person_middle_name := l_customer_tbl(l_rec - 1).person_middle_name;
16814              l_customer_tbl(l_rec).person_name_suffix := l_customer_tbl(l_rec - 1).person_name_suffix;
16815              l_customer_tbl(l_rec).person_last_name := l_customer_tbl(l_rec - 1).person_last_name;
16816              l_customer_tbl(l_rec).PERSON_NAME_PREFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_PREFIX;
16817              l_customer_tbl(l_rec).department := l_customer_tbl(l_rec - 1).department;
16818              l_customer_tbl(l_rec).job_title := l_customer_tbl(l_rec - 1).job_title;
16819              l_customer_tbl(l_rec).decision_maker_flag := l_customer_tbl(l_rec - 1).decision_maker_flag;
16820 
16821 l_customer_tbl(l_rec).PERSONAL_INCOME := l_customer_tbl(l_rec - 1).PERSONAL_INCOME;
16822 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := l_customer_tbl(l_rec - 1).PERSON_ACADEMIC_TITLE;
16823 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME_PHONETIC ;
16824 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME_PHONETIC;
16825 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := l_customer_tbl(l_rec - 1).MIDDLE_NAME_PHONETIC;
16826 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_NAME_PHONETIC;
16827 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := l_customer_tbl(l_rec - 1).PERSON_PREVIOUS_TITLE_NAME ;
16828 l_customer_tbl(l_rec).PLACE_OF_BIRTH := l_customer_tbl(l_rec - 1).PLACE_OF_BIRTH;
16829 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := l_customer_tbl(l_rec - 1).HEAD_OF_HOUSEHOLD_FLAG;
16830 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := l_customer_tbl(l_rec - 1).HOUSEHOLD_SIZE;
16831 l_customer_tbl(l_rec).TAX_ID := l_customer_tbl(l_rec - 1).TAX_ID;
16832 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE_CATEGORY;
16833 l_customer_tbl(l_rec).DATE_OF_BIRTH := l_customer_tbl(l_rec - 1).DATE_OF_BIRTH;
16834 l_customer_tbl(l_rec).DATE_OF_DEATH := l_customer_tbl(l_rec - 1).DATE_OF_DEATH;
16835 l_customer_tbl(l_rec).DECLARED_ETHNICITY := l_customer_tbl(l_rec - 1).DECLARED_ETHNICITY;
16836 l_customer_tbl(l_rec).MARITAL_STATUS := l_customer_tbl(l_rec - 1).MARITAL_STATUS;
16837 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).MARITAL_STATUS_EFFECTIVE_DATE;
16838 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE1;
16839 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE2;
16840 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE3;
16841 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE4;
16842 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE5;
16843 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE6;
16844 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE7;
16845 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE8;
16846 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE9;
16847 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE10;
16848 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE11;
16849 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE12;
16850 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE13;
16851 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE14;
16852 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE15;
16853 
16854          end if;
16855         -- l_customer_tbl(l_rec).cp_imp_xml_element_id := l_phiid_record_in_tbl(i).imp_xml_element_id;
16856          l_customer_tbl(l_rec).cp_imp_xml_element_id := l_phoid_record_in_tbl(k).imp_xml_element_id;
16857          l_customer_tbl(l_rec).phone_number := Get_Element_VALUE('PHONE_NUMBER',l_phiid_record_in_tbl);
16858          l_customer_tbl(l_rec).phone_country_code := Get_Element_VALUE('PHONE_COUNTRY_CODE',l_phiid_record_in_tbl);
16859          l_customer_tbl(l_rec).phone_area_code := Get_Element_VALUE('PHONE_AREA_CODE',l_phiid_record_in_tbl);
16860          l_customer_tbl(l_rec).phone_extension := Get_Element_VALUE('PHONE_EXTENTION',l_phiid_record_in_tbl);
16861          l_rec := 0;
16862        END LOOP; -- Phone
16863 
16864 
16865        -- Process  of Email data.
16866        l_ema_element_id := Get_Element_ID('EMAIL',l_conid_record_in_tbl);
16867        -- dbms_output.put_line( ' l_ema_element_id = '||to_char(l_ema_element_id));
16868 
16869     /********* Get all the elements for email *****************************/
16870       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16871         p_imp_xml_element_id => l_ema_element_id,
16872         x_child_set          => l_emaid_record_in_tbl,
16873         x_return_status      => x_return_status,
16874         x_msg_data           => x_msg_data);
16875        -- dbms_output.put_line( ' attributl email count '||l_emaid_record_in_tbl.COUNT);
16876        FOR l IN 1..l_emaid_record_in_tbl.COUNT LOOP
16877         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
16878         p_imp_xml_element_id => l_emaid_record_in_tbl(l).imp_xml_element_id,
16879         x_child_set          => l_emlid_record_in_tbl,
16880         x_return_status      => x_return_status,
16881         x_msg_data           => x_msg_data);
16882        -- dbms_output.put_line( ' in l_emlid_record_in_tbl count '||l_emlid_record_in_tbl.COUNT);
16883 
16884         l_rec := l_customer_tbl.count;
16885          if l > 1 then
16886              l_rec := l_customer_tbl.count+1;
16887              l_customer_tbl(l_rec).cust_data_id := l_rec;
16888              l_customer_tbl(l_rec).org_imp_xml_element_id := l_customer_tbl(l_rec - 1).org_imp_xml_element_id;
16889              l_customer_tbl(l_rec).party_name := l_customer_tbl(l_rec - 1).party_name;
16890              l_customer_tbl(l_rec).FISCAL_YEAREND_MONTH := l_customer_tbl(l_rec - 1).FISCAL_YEAREND_MONTH;
16891              l_customer_tbl(l_rec).DUNS_NUMBER := l_customer_tbl(l_rec - 1).DUNS_NUMBER;
16892              l_customer_tbl(l_rec).EMPLOYEES_TOTAL := l_customer_tbl(l_rec - 1).EMPLOYEES_TOTAL;
16893              l_customer_tbl(l_rec).LINE_OF_BUSINESS := l_customer_tbl(l_rec - 1).LINE_OF_BUSINESS;
16894              l_customer_tbl(l_rec).YEAR_ESTABLISHED := l_customer_tbl(l_rec - 1).YEAR_ESTABLISHED;
16895              l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
16896              l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
16897              l_customer_tbl(l_rec).CEO_NAME := l_customer_tbl(l_rec - 1).CEO_NAME;
16898              l_customer_tbl(l_rec).SIC_CODE := l_customer_tbl(l_rec - 1).SIC_CODE;
16899              l_customer_tbl(l_rec).SIC_CODE_TYPE := l_customer_tbl(l_rec - 1).SIC_CODE_TYPE;
16900              l_customer_tbl(l_rec).ANALYSIS_FY := l_customer_tbl(l_rec - 1).ANALYSIS_FY;
16901              l_customer_tbl(l_rec).CURR_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).CURR_FY_POTENTIAL_REVENUE;
16902              l_customer_tbl(l_rec).NEXT_FY_POTENTIAL_REVENUE := l_customer_tbl(l_rec - 1).NEXT_FY_POTENTIAL_REVENUE;
16903              l_customer_tbl(l_rec).GSA_INDICATOR_FLAG := l_customer_tbl(l_rec - 1).GSA_INDICATOR_FLAG;
16904              l_customer_tbl(l_rec).MISSION_STATEMENT := l_customer_tbl(l_rec - 1).MISSION_STATEMENT;
16905              l_customer_tbl(l_rec).ORGANIZATION_NAME_PHONETIC := l_customer_tbl(l_rec - 1).ORGANIZATION_NAME_PHONETIC;
16906              l_customer_tbl(l_rec).CATEGORY_CODE := l_customer_tbl(l_rec - 1).CATEGORY_CODE;
16907              l_customer_tbl(l_rec).JGZZ_FISCAL_CODE := l_customer_tbl(l_rec - 1).JGZZ_FISCAL_CODE;
16908              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
16909 l_customer_tbl(l_rec).BRANCH_FLAG := l_customer_tbl(l_rec - 1).BRANCH_FLAG;
16910 l_customer_tbl(l_rec).BUSINESS_LINE := l_customer_tbl(l_rec - 1).BUSINESS_LINE;
16911 l_customer_tbl(l_rec).BUSINESS_SCOPE := l_customer_tbl(l_rec - 1).BUSINESS_SCOPE;
16912 l_customer_tbl(l_rec).CHIEF_EXECUTIVE_TITLE := l_customer_tbl(l_rec - 1).CHIEF_EXECUTIVE_TITLE;
16913 l_customer_tbl(l_rec).CONGRESSIONAL_DISTRICT_CODE := l_customer_tbl(l_rec - 1).CONGRESSIONAL_DISTRICT_CODE;
16914 l_customer_tbl(l_rec).CONTROL_YEAR := l_customer_tbl(l_rec - 1).CONTROL_YEAR;
16915 l_customer_tbl(l_rec).CORPORATION_CLASS := l_customer_tbl(l_rec - 1).CORPORATION_CLASS;
16916 l_customer_tbl(l_rec).CREDIT_SCORE := l_customer_tbl(l_rec - 1).CREDIT_SCORE;
16917 l_customer_tbl(l_rec).CREDIT_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).CREDIT_SCORE_COMMENTARY;
16918 l_customer_tbl(l_rec).CUSTOMER_CATEGORY := l_customer_tbl(l_rec - 1).CUSTOMER_CATEGORY;
16919 l_customer_tbl(l_rec).DB_RATING := l_customer_tbl(l_rec - 1).DB_RATING;
16920 l_customer_tbl(l_rec).DEBARMENTS_COUNT := l_customer_tbl(l_rec - 1).DEBARMENTS_COUNT;
16921 l_customer_tbl(l_rec).DEBARTMENTS_DATE := l_customer_tbl(l_rec - 1).DEBARTMENTS_DATE;
16922 l_customer_tbl(l_rec).DEPARTMENT_INDICATOR := l_customer_tbl(l_rec - 1).DEPARTMENT_INDICATOR;
16923 l_customer_tbl(l_rec).DISADVANTAGED_INDICATOR := l_customer_tbl(l_rec - 1).DISADVANTAGED_INDICATOR;
16924 l_customer_tbl(l_rec).ENQUIRY_DUNS := l_customer_tbl(l_rec - 1).ENQUIRY_DUNS;
16925 l_customer_tbl(l_rec).EXPORT_INDICATOR := l_customer_tbl(l_rec - 1).EXPORT_INDICATOR;
16926 l_customer_tbl(l_rec).FAILURE_SCORE := l_customer_tbl(l_rec - 1).FAILURE_SCORE;
16927 l_customer_tbl(l_rec).FAILURE_SCORE_COMMENTARY := l_customer_tbl(l_rec - 1).FAILURE_SCORE_COMMENTARY;
16928 l_customer_tbl(l_rec).FAILURE_SCORE_NATL_PERCENTILE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_NATL_PERCENTILE;
16929 l_customer_tbl(l_rec).FAILURE_SCORE_OVERRIDE_CODE := l_customer_tbl(l_rec - 1).FAILURE_SCORE_OVERRIDE_CODE;
16930 l_customer_tbl(l_rec).GLOBAL_FAILURE_SCORE := l_customer_tbl(l_rec - 1).GLOBAL_FAILURE_SCORE;
16931 l_customer_tbl(l_rec).HEADQUARTER_BRANCH_INDICATOR := l_customer_tbl(l_rec - 1).HEADQUARTER_BRANCH_INDICATOR;
16932 l_customer_tbl(l_rec).IMPORT_INDICATOR := l_customer_tbl(l_rec - 1).IMPORT_INDICATOR;
16933 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS;
16934 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS2 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS2;
16935 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS3 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS3;
16936 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS4 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS4;
16937 l_customer_tbl(l_rec).ORGANIZATION_KNOWN_AS5 := l_customer_tbl(l_rec - 1).ORGANIZATION_KNOWN_AS5;
16938 l_customer_tbl(l_rec).LABOR_SURPLUS_INDICATOR := l_customer_tbl(l_rec - 1).LABOR_SURPLUS_INDICATOR;
16939 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE;
16940 l_customer_tbl(l_rec).LOCAL_ACTIVITY_CODE_TYPE := l_customer_tbl(l_rec - 1).LOCAL_ACTIVITY_CODE_TYPE;
16941 l_customer_tbl(l_rec).MINORITY_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).MINORITY_OWNED_INDICATOR;
16942 l_customer_tbl(l_rec).MINORITY_OWNED_TYPE := l_customer_tbl(l_rec - 1).MINORITY_OWNED_TYPE;
16943 l_customer_tbl(l_rec).ORGANIZATION_TYPE := l_customer_tbl(l_rec - 1).ORGANIZATION_TYPE;
16944 l_customer_tbl(l_rec).ORGANIZATION_URL := l_customer_tbl(l_rec - 1).ORGANIZATION_URL;
16945 l_customer_tbl(l_rec).OUT_OF_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).OUT_OF_BUSINESS_INDICATOR;
16946 l_customer_tbl(l_rec).PRINCIPAL_NAME := l_customer_tbl(l_rec - 1).PRINCIPAL_NAME;
16947 l_customer_tbl(l_rec).PRINCIPAL_TITLE := l_customer_tbl(l_rec - 1).PRINCIPAL_TITLE;
16948 l_customer_tbl(l_rec).PUBLIC_PRIVATE_OWNERSHIP_FLAG := l_customer_tbl(l_rec - 1).PUBLIC_PRIVATE_OWNERSHIP_FLAG;
16949 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
16950 l_customer_tbl(l_rec).RENT_OWNER_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNER_INDICATOR;
16951 l_customer_tbl(l_rec).SMALL_BUSINESS_INDICATOR := l_customer_tbl(l_rec - 1).SMALL_BUSINESS_INDICATOR;
16952 l_customer_tbl(l_rec).WOMAN_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).WOMAN_OWNED_INDICATOR;
16953 l_customer_tbl(l_rec).ORG_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ORG_ATTRIBUTE_CATEGORY;
16954 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE1;
16955 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE2;
16956 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE3;
16957 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE4;
16958 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE5;
16959 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE6;
16960 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE7;
16961 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE8;
16962 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE9;
16963 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE10;
16964 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE11;
16965 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE12;
16966 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE13;
16967 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE14;
16968 l_customer_tbl(l_rec).ORGANIZATION_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ORGANIZATION_ATTRIBUTE15;
16969 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
16970 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
16971 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
16972 
16973 
16974              l_customer_tbl(l_rec).add_imp_xml_element_id := l_customer_tbl(l_rec - 1).add_imp_xml_element_id;
16975              l_customer_tbl(l_rec).address1 := l_customer_tbl(l_rec - 1).address1;
16976              l_customer_tbl(l_rec).address2 := l_customer_tbl(l_rec - 1).address2;
16977              l_customer_tbl(l_rec).address3 := l_customer_tbl(l_rec - 1).address3;
16978              l_customer_tbl(l_rec).address4 := l_customer_tbl(l_rec - 1).address4;
16979              l_customer_tbl(l_rec).city := l_customer_tbl(l_rec - 1).city;
16980              l_customer_tbl(l_rec).county := l_customer_tbl(l_rec - 1).county;
16981              l_customer_tbl(l_rec).province := l_customer_tbl(l_rec - 1).province;
16982              l_customer_tbl(l_rec).state := l_customer_tbl(l_rec - 1).state;
16983              l_customer_tbl(l_rec).postal_code := l_customer_tbl(l_rec - 1).postal_code;
16984              l_customer_tbl(l_rec).country  := l_customer_tbl(l_rec - 1).country;
16985              l_customer_tbl(l_rec).address_lines_phonetic := l_customer_tbl(l_rec - 1).address_lines_phonetic;
16986 -- bug 4641591: columns obsolete
16987 --	     l_customer_tbl(l_rec).po_box_number := l_customer_tbl(l_rec - 1).po_box_number;
16988 --             l_customer_tbl(l_rec).house_number := l_customer_tbl(l_rec - 1).house_number;
16989 --             l_customer_tbl(l_rec).street_suffix := l_customer_tbl(l_rec - 1).street_suffix;
16990 --             l_customer_tbl(l_rec).street := l_customer_tbl(l_rec - 1).street;
16991 --             l_customer_tbl(l_rec).street_number := l_customer_tbl(l_rec - 1).street_number;
16992 --             l_customer_tbl(l_rec).floor := l_customer_tbl(l_rec - 1).floor;
16993 --             l_customer_tbl(l_rec).suite := l_customer_tbl(l_rec - 1).suite;
16994              l_customer_tbl(l_rec).postal_plus4_code := l_customer_tbl(l_rec - 1).postal_plus4_code;
16995              l_customer_tbl(l_rec).identifying_address_flag := l_customer_tbl(l_rec - 1).identifying_address_flag;
16996 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE1;
16997 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE2;
16998 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE3;
16999 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE4;
17000 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE5;
17001 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE6;
17002 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE7;
17003 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE8;
17004 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE9;
17005 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE10;
17006 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE11;
17007 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE12;
17008 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE13;
17009 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE14;
17010 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE15;
17011 l_customer_tbl(l_rec).DESCRIPTION := l_customer_tbl(l_rec - 1).DESCRIPTION;
17012 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE_CATEGORY;
17013 l_customer_tbl(l_rec).PARTY_SITE_USE := l_customer_tbl(l_rec - 1).PARTY_SITE_USE;
17014 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := l_customer_tbl(l_rec - 1).LOCATION_DIRECTIONS;
17015 l_customer_tbl(l_rec).SHORT_DESCRIPTION := l_customer_tbl(l_rec - 1).SHORT_DESCRIPTION;
17016 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EFFECTIVE_DATE;
17017 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EXPIRATION_DATE;
17018 
17019 
17020              l_customer_tbl(l_rec).ocont_imp_xml_element_id := l_customer_tbl(l_rec - 1).ocont_imp_xml_element_id;
17021              l_customer_tbl(l_rec).person_first_name := l_customer_tbl(l_rec - 1).person_first_name;
17022              l_customer_tbl(l_rec).person_middle_name := l_customer_tbl(l_rec - 1).person_middle_name;
17023              l_customer_tbl(l_rec).person_name_suffix := l_customer_tbl(l_rec - 1).person_name_suffix;
17024              l_customer_tbl(l_rec).person_last_name := l_customer_tbl(l_rec - 1).person_last_name;
17025              l_customer_tbl(l_rec).PERSON_NAME_PREFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_PREFIX;
17026              l_customer_tbl(l_rec).department := l_customer_tbl(l_rec - 1).department;
17027              l_customer_tbl(l_rec).job_title := l_customer_tbl(l_rec - 1).job_title;
17028              l_customer_tbl(l_rec).decision_maker_flag := l_customer_tbl(l_rec - 1).decision_maker_flag;
17029 l_customer_tbl(l_rec).PERSONAL_INCOME := l_customer_tbl(l_rec - 1).PERSONAL_INCOME;
17030 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := l_customer_tbl(l_rec - 1).PERSON_ACADEMIC_TITLE;
17031 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME_PHONETIC ;
17032 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME_PHONETIC;
17033 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := l_customer_tbl(l_rec - 1).MIDDLE_NAME_PHONETIC;
17034 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_NAME_PHONETIC;
17035 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := l_customer_tbl(l_rec - 1).PERSON_PREVIOUS_TITLE_NAME ;
17036 l_customer_tbl(l_rec).PLACE_OF_BIRTH := l_customer_tbl(l_rec - 1).PLACE_OF_BIRTH;
17037 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := l_customer_tbl(l_rec - 1).HEAD_OF_HOUSEHOLD_FLAG;
17038 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := l_customer_tbl(l_rec - 1).HOUSEHOLD_SIZE;
17039 l_customer_tbl(l_rec).TAX_ID := l_customer_tbl(l_rec - 1).TAX_ID;
17040 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE_CATEGORY;
17041 l_customer_tbl(l_rec).DATE_OF_BIRTH := l_customer_tbl(l_rec - 1).DATE_OF_BIRTH;
17042 l_customer_tbl(l_rec).DATE_OF_DEATH := l_customer_tbl(l_rec - 1).DATE_OF_DEATH;
17043 l_customer_tbl(l_rec).DECLARED_ETHNICITY := l_customer_tbl(l_rec - 1).DECLARED_ETHNICITY;
17044 l_customer_tbl(l_rec).MARITAL_STATUS := l_customer_tbl(l_rec - 1).MARITAL_STATUS;
17045 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).MARITAL_STATUS_EFFECTIVE_DATE;
17046 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE1;
17047 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE2;
17048 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE3;
17049 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE4;
17050 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE5;
17051 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE6;
17052 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE7;
17053 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE8;
17054 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE9;
17055 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE10;
17056 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE11;
17057 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE12;
17058 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE13;
17059 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE14;
17060 l_customer_tbl(l_rec).ORG_CONTACT_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ORG_CONTACT_ATTRIBUTE15;
17061 
17062          end if;
17063          l_customer_tbl(l_rec).em_imp_xml_element_id := l_emaid_record_in_tbl(l).imp_xml_element_id;
17064          -- l_customer_tbl(l_rec).em_imp_xml_element_id := l_emlid_record_in_tbl(l).imp_xml_element_id;
17065          l_customer_tbl(l_rec).email_address := Get_Element_VALUE('EMAIL_ADDRESS',l_emlid_record_in_tbl);
17066 /*
17067        -- dbms_output.put_line( ' em_imp_xml_element_id '||l_customer_tbl(l_rec).em_imp_xml_element_id);
17068        -- dbms_output.put_line( ' EMAIL_ADDRESS '||l_customer_tbl(l_rec).EMAIL_ADDRESS);
17069 */
17070          l_rec := 0;
17071        END LOOP; -- Email
17072 
17073        END LOOP; -- Org Contaaaaat  process
17074      -- ******************************Location process
17075 
17076        END LOOP; -- Locarion process
17077        p_cust_tbl := l_customer_tbl;
17078 
17079  exception
17080  WHEN OTHERS THEN
17081     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
17082     FND_MESSAGE.Set_Token('ROW','Error in Process_b2b_xml_data :' || SQLERRM||' '||SQLCODE);
17083     AMS_Utility_PVT.Create_Log (
17084       x_return_status   => x_return_status,
17085       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
17086       p_log_used_by_id  => p_import_list_header_id,
17087       p_msg_data        => FND_MESSAGE.get,
17088       p_msg_type        => 'DEBUG'
17089    );
17090 
17091 
17092 end Process_b2b_xml_data;
17093 -- ********************************************************************
17094 --
17095 -- This program processes the xml data.
17096 --
17097 PROCEDURE Process_b2c_xml_data (
17098     p_import_list_header_id    IN    NUMBER,
17099     p_xml_element_id            IN    NUMBER,
17100     p_cust_tbl                  IN OUT NOCOPY   cust_b2c_data_in_tbl,
17101     x_return_status             OUT NOCOPY   VARCHAR2,
17102     x_msg_data                  OUT NOCOPY   VARCHAR2
17103 ) IS
17104    l_loc_element_id     NUMBER;
17105    l_oct_element_id     NUMBER;
17106    l_pho_element_id     NUMBER;
17107    l_ema_element_id     NUMBER;
17108    l_rec        NUMBER := 1;
17109 
17110  party_rec       hz_party_v2pub.party_rec_type;
17111  org_rec         hz_party_v2pub.organization_rec_type;
17112  person_rec      hz_party_v2pub.person_rec_type;
17113  location_rec    hz_location_v2pub.location_rec_type;
17114  psite_rec       hz_party_site_v2pub.party_site_rec_type;
17115  cpoint_rec      hz_contact_point_v2pub.contact_point_rec_type;
17116  email_rec       hz_contact_point_v2pub.email_rec_type;
17117  phone_rec       hz_contact_point_v2pub.phone_rec_type;
17118  ocon_rec        hz_party_contact_v2pub.org_contact_rec_type;
17119  edi_rec         hz_contact_point_v2pub.edi_rec_type;
17120  telex_rec       hz_contact_point_v2pub.telex_rec_type;
17121  web_rec         hz_contact_point_v2pub.web_rec_type;
17122 
17123    l_perid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17124    l_locid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17125    l_addid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17126    l_octid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17127    l_conid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17128    l_phoid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17129    l_phiid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17130    l_emaid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17131    l_emlid_record_in_tbl  AMS_IMPORT_XML_PVT.xml_element_set_type;
17132    l_customer_tbl               cust_b2c_data_in_tbl;
17133 
17134 begin
17135     /********* Get all the elements for the Person *****************************/
17136       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17137         p_imp_xml_element_id => p_xml_element_id,
17138         x_child_set          => l_perid_record_in_tbl,
17139         x_return_status      => x_return_status,
17140         x_msg_data           => x_msg_data);
17141 
17142        -- dbms_output.put_line( ' Person attribute count '||l_perid_record_in_tbl.COUNT);
17143 /*
17144        FOR i IN 1..l_perid_record_in_tbl.COUNT LOOP
17145        -- dbms_output.put_line('Per att '||l_perid_record_in_tbl(i).column_name||'>>>'||l_perid_record_in_tbl(i).data);
17146        END LOOP;
17147 */
17148        l_customer_tbl(l_rec).cust_data_id := l_rec;
17149        l_customer_tbl(l_rec).per_imp_xml_element_id := p_xml_element_id;
17150 
17151        l_customer_tbl(l_rec).person_first_name := Get_Element_VALUE('PERSON_FIRST_NAME',l_perid_record_in_tbl);
17152        l_customer_tbl(l_rec).person_last_name := Get_Element_VALUE('PERSON_LAST_NAME',l_perid_record_in_tbl);
17153        l_customer_tbl(l_rec).person_middle_name := Get_Element_VALUE('PERSON_MIDDLE_NAME',l_perid_record_in_tbl);
17154        l_customer_tbl(l_rec).person_name_suffix := Get_Element_VALUE('PERSON_NAME_SUFFIX',l_perid_record_in_tbl);
17155        l_customer_tbl(l_rec).PERSON_NAME_PREFIX := Get_Element_VALUE('PERSON_NAME_PREFIX',l_perid_record_in_tbl);
17156        l_customer_tbl(l_rec).SALUTATION := Get_Element_VALUE('SALUTATION',l_perid_record_in_tbl);
17157 
17158        l_customer_tbl(l_rec).PARTY_ID := Get_Element_VALUE('PARTY_ID',l_perid_record_in_tbl);
17159 l_customer_tbl(l_rec).PERSONAL_INCOME := Get_Element_VALUE('PERSONAL_INCOME',l_perid_record_in_tbl);
17160 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := Get_Element_VALUE('PERSON_ACADEMIC_TITLE',l_perid_record_in_tbl);
17161 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := Get_Element_VALUE('PERSON_FIRST_NAME_PHONETIC',l_perid_record_in_tbl);
17162 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := Get_Element_VALUE('PERSON_LAST_NAME_PHONETIC',l_perid_record_in_tbl);
17163 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := Get_Element_VALUE('MIDDLE_NAME_PHONETIC',l_perid_record_in_tbl);
17164 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := Get_Element_VALUE('PERSON_NAME_PHONETIC',l_perid_record_in_tbl);
17165 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := Get_Element_VALUE('PERSON_PREVIOUS_TITLE_NAME',l_perid_record_in_tbl);
17166 l_customer_tbl(l_rec).PLACE_OF_BIRTH := Get_Element_VALUE('PLACE_OF_BIRTH',l_perid_record_in_tbl);
17167 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := Get_Element_VALUE('HEAD_OF_HOUSEHOLD_FLAG',l_perid_record_in_tbl);
17168 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := Get_Element_VALUE('HOUSEHOLD_SIZE',l_perid_record_in_tbl);
17169 l_customer_tbl(l_rec).TAX_REFERENCE := Get_Element_VALUE('TAX_REFERENCE',l_perid_record_in_tbl);
17170 l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := Get_Element_VALUE('ORIG_SYSTEM_REFERENCE',l_perid_record_in_tbl);
17171 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := Get_Element_VALUE('RENT_OWNED_INDICATOR',l_perid_record_in_tbl);
17172 l_customer_tbl(l_rec).PERSON_ATTRIBUTE_CATEGORY := Get_Element_VALUE('PERSON_ATTRIBUTE_CATEGORY',l_perid_record_in_tbl);
17173 l_customer_tbl(l_rec).DATE_OF_BIRTH := Get_Element_VALUE('DATE_OF_BIRTH',l_perid_record_in_tbl);
17174 l_customer_tbl(l_rec).DATE_OF_DEATH := Get_Element_VALUE('DATE_OF_DEATH',l_perid_record_in_tbl);
17175 l_customer_tbl(l_rec).DECLARED_ETHNICITY := Get_Element_VALUE('DECLARED_ETHNICITY',l_perid_record_in_tbl);
17176 l_customer_tbl(l_rec).MARITAL_STATUS := Get_Element_VALUE('MARITAL_STATUS',l_perid_record_in_tbl);
17177 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := Get_Element_VALUE('MARITAL_STATUS_EFFECTIVE_DATE',l_perid_record_in_tbl);
17178 l_customer_tbl(l_rec).PERSON_ATTRIBUTE1 := Get_Element_VALUE('PERSON_ATTRIBUTE1',l_perid_record_in_tbl);
17179 l_customer_tbl(l_rec).PERSON_ATTRIBUTE2 := Get_Element_VALUE('PERSON_ATTRIBUTE2',l_perid_record_in_tbl);
17180 l_customer_tbl(l_rec).PERSON_ATTRIBUTE3 := Get_Element_VALUE('PERSON_ATTRIBUTE3',l_perid_record_in_tbl);
17181 l_customer_tbl(l_rec).PERSON_ATTRIBUTE4 := Get_Element_VALUE('PERSON_ATTRIBUTE4',l_perid_record_in_tbl);
17182 l_customer_tbl(l_rec).PERSON_ATTRIBUTE5 := Get_Element_VALUE('PERSON_ATTRIBUTE5',l_perid_record_in_tbl);
17183 l_customer_tbl(l_rec).PERSON_ATTRIBUTE6 := Get_Element_VALUE('PERSON_ATTRIBUTE6',l_perid_record_in_tbl);
17184 l_customer_tbl(l_rec).PERSON_ATTRIBUTE7 := Get_Element_VALUE('PERSON_ATTRIBUTE7',l_perid_record_in_tbl);
17185 l_customer_tbl(l_rec).PERSON_ATTRIBUTE8 := Get_Element_VALUE('PERSON_ATTRIBUTE8',l_perid_record_in_tbl);
17186 l_customer_tbl(l_rec).PERSON_ATTRIBUTE9 := Get_Element_VALUE('PERSON_ATTRIBUTE9',l_perid_record_in_tbl);
17187 l_customer_tbl(l_rec).PERSON_ATTRIBUTE10 := Get_Element_VALUE('PERSON_ATTRIBUTE10',l_perid_record_in_tbl) ;
17188 l_customer_tbl(l_rec).PERSON_ATTRIBUTE11 := Get_Element_VALUE('PERSON_ATTRIBUTE11',l_perid_record_in_tbl) ;
17189 l_customer_tbl(l_rec).PERSON_ATTRIBUTE12 := Get_Element_VALUE('PERSON_ATTRIBUTE12',l_perid_record_in_tbl) ;
17190 l_customer_tbl(l_rec).PERSON_ATTRIBUTE13 := Get_Element_VALUE('PERSON_ATTRIBUTE13',l_perid_record_in_tbl) ;
17191 l_customer_tbl(l_rec).PERSON_ATTRIBUTE14 := Get_Element_VALUE('PERSON_ATTRIBUTE14',l_perid_record_in_tbl) ;
17192 l_customer_tbl(l_rec).PERSON_ATTRIBUTE15 := Get_Element_VALUE('PERSON_ATTRIBUTE15',l_perid_record_in_tbl) ;
17193 
17194 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := Get_Element_VALUE('VEHICLE_RESPONSE_CODE',l_perid_record_in_tbl) ;
17195 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := Get_Element_VALUE('SALES_AGENT_EMAIL_ID',l_perid_record_in_tbl) ;
17196 l_customer_tbl(l_rec).NOTES := Get_Element_VALUE('NOTES',l_perid_record_in_tbl) ;
17197 
17198 /*
17199        -- dbms_output.put_line( ' cust_data_id '||l_customer_tbl(l_rec).cust_data_id);
17200        -- dbms_output.put_line( ' per_imp_xml_element_id '||l_customer_tbl(l_rec).per_imp_xml_element_id);
17201        -- dbms_output.put_line( ' Pat-name '||l_customer_tbl(l_rec).PERSON_FIRST_NAME);
17202 */
17203        -- Process for location data.
17204        l_loc_element_id := Get_Element_ID('LOCATION',l_perid_record_in_tbl);
17205        -- dbms_output.put_line( ' l_loc_element_id = '||to_char(l_loc_element_id));
17206 
17207     /********* Get all the elements for the location *****************************/
17208       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17209         p_imp_xml_element_id => l_loc_element_id,
17210         x_child_set          => l_locid_record_in_tbl,
17211         x_return_status      => x_return_status,
17212         x_msg_data           => x_msg_data);
17213        -- dbms_output.put_line( ' Location attribute count '||l_locid_record_in_tbl.COUNT);
17214        FOR i IN 1..l_locid_record_in_tbl.COUNT LOOP
17215         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17216         p_imp_xml_element_id => l_locid_record_in_tbl(i).imp_xml_element_id,
17217         x_child_set          => l_addid_record_in_tbl,
17218         x_return_status      => x_return_status,
17219         x_msg_data           => x_msg_data);
17220 
17221         l_rec := l_customer_tbl.count;
17222          if i > 1 then
17223              l_rec := l_customer_tbl.count+1;
17224              l_customer_tbl(l_rec).cust_data_id := l_rec;
17225              l_customer_tbl(l_rec).per_imp_xml_element_id := l_customer_tbl(l_rec - 1).per_imp_xml_element_id;
17226              l_customer_tbl(l_rec).PERSON_FIRST_NAME := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME;
17227              l_customer_tbl(l_rec).PERSON_LAST_NAME := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME;
17228              l_customer_tbl(l_rec).PERSON_MIDDLE_NAME := l_customer_tbl(l_rec - 1).PERSON_MIDDLE_NAME;
17229              l_customer_tbl(l_rec).PERSON_NAME_SUFFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_SUFFIX;
17230              l_customer_tbl(l_rec).PERSON_NAME_PREFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_PREFIX;
17231              l_customer_tbl(l_rec).SALUTATION := l_customer_tbl(l_rec - 1).SALUTATION;
17232              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
17233 
17234 l_customer_tbl(l_rec).PERSONAL_INCOME := l_customer_tbl(l_rec - 1).PERSONAL_INCOME;
17235 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := l_customer_tbl(l_rec - 1).PERSON_ACADEMIC_TITLE;
17236 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME_PHONETIC ;
17237 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME_PHONETIC;
17238 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := l_customer_tbl(l_rec - 1).MIDDLE_NAME_PHONETIC;
17239 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_NAME_PHONETIC;
17240 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := l_customer_tbl(l_rec - 1).PERSON_PREVIOUS_TITLE_NAME ;
17241 l_customer_tbl(l_rec).PLACE_OF_BIRTH := l_customer_tbl(l_rec - 1).PLACE_OF_BIRTH;
17242 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := l_customer_tbl(l_rec - 1).HEAD_OF_HOUSEHOLD_FLAG;
17243 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := l_customer_tbl(l_rec - 1).HOUSEHOLD_SIZE;
17244 l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
17245 l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
17246 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
17247 l_customer_tbl(l_rec).PERSON_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE_CATEGORY;
17248 l_customer_tbl(l_rec).DATE_OF_BIRTH := l_customer_tbl(l_rec - 1).DATE_OF_BIRTH;
17249 l_customer_tbl(l_rec).DATE_OF_DEATH := l_customer_tbl(l_rec - 1).DATE_OF_DEATH;
17250 l_customer_tbl(l_rec).DECLARED_ETHNICITY := l_customer_tbl(l_rec - 1).DECLARED_ETHNICITY;
17251 l_customer_tbl(l_rec).MARITAL_STATUS := l_customer_tbl(l_rec - 1).MARITAL_STATUS;
17252 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).MARITAL_STATUS_EFFECTIVE_DATE;
17253 l_customer_tbl(l_rec).PERSON_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE1;
17254 l_customer_tbl(l_rec).PERSON_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE2;
17255 l_customer_tbl(l_rec).PERSON_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE3;
17256 l_customer_tbl(l_rec).PERSON_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE4;
17257 l_customer_tbl(l_rec).PERSON_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE5;
17258 l_customer_tbl(l_rec).PERSON_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE6;
17259 l_customer_tbl(l_rec).PERSON_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE7;
17260 l_customer_tbl(l_rec).PERSON_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE8;
17261 l_customer_tbl(l_rec).PERSON_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE9;
17262 l_customer_tbl(l_rec).PERSON_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE10;
17263 l_customer_tbl(l_rec).PERSON_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE11;
17264 l_customer_tbl(l_rec).PERSON_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE12;
17265 l_customer_tbl(l_rec).PERSON_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE13;
17266 l_customer_tbl(l_rec).PERSON_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE14;
17267 l_customer_tbl(l_rec).PERSON_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE15;
17268 
17269 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
17270 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
17271 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
17272          end if;
17273          -- l_customer_tbl(l_rec).add_imp_xml_element_id := l_addid_record_in_tbl(i).imp_xml_element_id;
17274          l_customer_tbl(l_rec).add_imp_xml_element_id := l_locid_record_in_tbl(i).imp_xml_element_id;
17275          l_customer_tbl(l_rec).address1 := Get_Element_VALUE('ADDRESS1',l_addid_record_in_tbl);
17276          l_customer_tbl(l_rec).address2 := Get_Element_VALUE('ADDRESS2',l_addid_record_in_tbl);
17277          l_customer_tbl(l_rec).address3 := Get_Element_VALUE('ADDRESS3',l_addid_record_in_tbl);
17278          l_customer_tbl(l_rec).address4 := Get_Element_VALUE('ADDRESS4',l_addid_record_in_tbl);
17279          l_customer_tbl(l_rec).CITY := Get_Element_VALUE('CITY',l_addid_record_in_tbl);
17280          l_customer_tbl(l_rec).COUNTY := Get_Element_VALUE('COUNTY',l_addid_record_in_tbl);
17281          l_customer_tbl(l_rec).PROVINCE := Get_Element_VALUE('PROVINCE',l_addid_record_in_tbl);
17282          l_customer_tbl(l_rec).STATE := Get_Element_VALUE('STATE',l_addid_record_in_tbl);
17283          l_customer_tbl(l_rec).POSTAL_CODE := Get_Element_VALUE('POSTAL_CODE',l_addid_record_in_tbl);
17284          l_customer_tbl(l_rec).COUNTRY := Get_Element_VALUE('COUNTRY',l_addid_record_in_tbl);
17285          l_customer_tbl(l_rec).ADDRESS_LINES_PHONETIC := Get_Element_VALUE('ADDRESS_LINES_PHONETIC',l_addid_record_in_tbl);
17286 -- bug 4641591: columns obsolete
17287 --	 l_customer_tbl(l_rec).PO_BOX_NUMBER := Get_Element_VALUE('PO_BOX_NUMBER',l_addid_record_in_tbl);
17288 --         l_customer_tbl(l_rec).HOUSE_NUMBER := Get_Element_VALUE('HOUSE_NUMBER',l_addid_record_in_tbl);
17289 --         l_customer_tbl(l_rec).STREET_SUFFIX := Get_Element_VALUE('STREET_SUFFIX',l_addid_record_in_tbl);
17290 --         l_customer_tbl(l_rec).STREET := Get_Element_VALUE('STREET',l_addid_record_in_tbl);
17291 --         l_customer_tbl(l_rec).STREET_NUMBER := Get_Element_VALUE('STREET_NUMBER',l_addid_record_in_tbl);
17292 --         l_customer_tbl(l_rec).FLOOR := Get_Element_VALUE('FLOOR',l_addid_record_in_tbl);
17293 --         l_customer_tbl(l_rec).SUITE := Get_Element_VALUE('SUITE',l_addid_record_in_tbl);
17294          l_customer_tbl(l_rec).POSTAL_PLUS4_CODE := Get_Element_VALUE('POSTAL_PLUS4_CODE',l_addid_record_in_tbl);
17295          l_customer_tbl(l_rec).IDENTIFYING_ADDRESS_FLAG := Get_Element_VALUE('IDENTIFYING_ADDRESS_FLAG',l_addid_record_in_tbl);
17296 
17297 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := Get_Element_VALUE('ADDRESS_ATTRIBUTE1',l_addid_record_in_tbl);
17298 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := Get_Element_VALUE('ADDRESS_ATTRIBUTE2',l_addid_record_in_tbl);
17299 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := Get_Element_VALUE('ADDRESS_ATTRIBUTE3',l_addid_record_in_tbl);
17300 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := Get_Element_VALUE('ADDRESS_ATTRIBUTE4',l_addid_record_in_tbl);
17301 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := Get_Element_VALUE('ADDRESS_ATTRIBUTE5',l_addid_record_in_tbl);
17302 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := Get_Element_VALUE('ADDRESS_ATTRIBUTE6',l_addid_record_in_tbl);
17303 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := Get_Element_VALUE('ADDRESS_ATTRIBUTE7',l_addid_record_in_tbl);
17304 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := Get_Element_VALUE('ADDRESS_ATTRIBUTE8',l_addid_record_in_tbl);
17305 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := Get_Element_VALUE('ADDRESS_ATTRIBUTE9',l_addid_record_in_tbl);
17306 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := Get_Element_VALUE('ADDRESS_ATTRIBUTE10',l_addid_record_in_tbl);
17307 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := Get_Element_VALUE('ADDRESS_ATTRIBUTE11',l_addid_record_in_tbl);
17308 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := Get_Element_VALUE('ADDRESS_ATTRIBUTE12',l_addid_record_in_tbl);
17309 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := Get_Element_VALUE('ADDRESS_ATTRIBUTE13',l_addid_record_in_tbl);
17310 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := Get_Element_VALUE('ADDRESS_ATTRIBUTE14',l_addid_record_in_tbl);
17311 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := Get_Element_VALUE('ADDRESS_ATTRIBUTE15',l_addid_record_in_tbl);
17312 l_customer_tbl(l_rec).DESCRIPTION := Get_Element_VALUE('DESCRIPTION',l_addid_record_in_tbl);
17313 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := Get_Element_VALUE('ADDRESS_ATTRIBUTE_CATEGORY',l_addid_record_in_tbl);
17314 l_customer_tbl(l_rec).PARTY_SITE_USE := Get_Element_VALUE('PARTY_SITE_USE',l_addid_record_in_tbl);
17315 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := Get_Element_VALUE('LOCATION_DIRECTIONS',l_addid_record_in_tbl);
17316 l_customer_tbl(l_rec).SHORT_DESCRIPTION := Get_Element_VALUE('SHORT_DESCRIPTION',l_addid_record_in_tbl);
17317 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := Get_Element_VALUE('ADDRESS_EFFECTIVE_DATE',l_addid_record_in_tbl);
17318 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := Get_Element_VALUE('ADDRESS_EXPIRATION_DATE',l_addid_record_in_tbl) ;
17319 
17320 
17321        -- dbms_output.put_line( ' cust_data_id '||l_customer_tbl(l_rec).cust_data_id);
17322        -- dbms_output.put_line( ' add_imp_xml_element_id'||l_customer_tbl(l_rec).add_imp_xml_element_id);
17323        -- dbms_output.put_line( ' address1 '||l_customer_tbl(l_rec).address1);
17324 
17325          l_rec := 0;
17326      -- ****************************** End Location process
17327 
17328        -- Process  of Phone data.
17329        l_pho_element_id := Get_Element_ID('PHONE',l_addid_record_in_tbl);
17330        -- dbms_output.put_line( ' l_pho_element_id = '||to_char(l_pho_element_id));
17331 
17332     /********* Get all the elements for phone *****************************/
17333       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17334         p_imp_xml_element_id => l_pho_element_id,
17335         x_child_set          => l_phoid_record_in_tbl,
17336         x_return_status      => x_return_status,
17337         x_msg_data           => x_msg_data);
17338  --      dbms_output.put_line( ' Phone attribute count '||l_phoid_record_in_tbl.COUNT);
17339        FOR k IN 1..l_phoid_record_in_tbl.COUNT LOOP
17340         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17341         p_imp_xml_element_id => l_phoid_record_in_tbl(k).imp_xml_element_id,
17342         x_child_set          => l_phiid_record_in_tbl,
17343         x_return_status      => x_return_status,
17344         x_msg_data           => x_msg_data);
17345 
17346         l_rec := l_customer_tbl.count;
17347          if k > 1 then
17348              l_rec := l_customer_tbl.count+1;
17349              l_customer_tbl(l_rec).cust_data_id := l_rec;
17350 
17351              l_customer_tbl(l_rec).per_imp_xml_element_id := l_customer_tbl(l_rec - 1).per_imp_xml_element_id;
17352              l_customer_tbl(l_rec).PERSON_FIRST_NAME := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME;
17353              l_customer_tbl(l_rec).PERSON_LAST_NAME := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME;
17354              l_customer_tbl(l_rec).PERSON_MIDDLE_NAME := l_customer_tbl(l_rec - 1).PERSON_MIDDLE_NAME;
17355              l_customer_tbl(l_rec).PERSON_NAME_SUFFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_SUFFIX;
17356              l_customer_tbl(l_rec).PERSON_NAME_PREFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_PREFIX;
17357              l_customer_tbl(l_rec).SALUTATION := l_customer_tbl(l_rec - 1).SALUTATION;
17358              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
17359 
17360 l_customer_tbl(l_rec).PERSONAL_INCOME := l_customer_tbl(l_rec - 1).PERSONAL_INCOME;
17361 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := l_customer_tbl(l_rec - 1).PERSON_ACADEMIC_TITLE;
17362 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME_PHONETIC ;
17363 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME_PHONETIC;
17364 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := l_customer_tbl(l_rec - 1).MIDDLE_NAME_PHONETIC;
17365 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_NAME_PHONETIC;
17366 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := l_customer_tbl(l_rec - 1).PERSON_PREVIOUS_TITLE_NAME ;
17367 l_customer_tbl(l_rec).PLACE_OF_BIRTH := l_customer_tbl(l_rec - 1).PLACE_OF_BIRTH;
17368 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := l_customer_tbl(l_rec - 1).HEAD_OF_HOUSEHOLD_FLAG;
17369 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := l_customer_tbl(l_rec - 1).HOUSEHOLD_SIZE;
17370 l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
17371 l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
17372 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
17373 l_customer_tbl(l_rec).PERSON_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE_CATEGORY;
17374 l_customer_tbl(l_rec).DATE_OF_BIRTH := l_customer_tbl(l_rec - 1).DATE_OF_BIRTH;
17375 l_customer_tbl(l_rec).DATE_OF_DEATH := l_customer_tbl(l_rec - 1).DATE_OF_DEATH;
17376 l_customer_tbl(l_rec).DECLARED_ETHNICITY := l_customer_tbl(l_rec - 1).DECLARED_ETHNICITY;
17377 l_customer_tbl(l_rec).MARITAL_STATUS := l_customer_tbl(l_rec - 1).MARITAL_STATUS;
17378 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).MARITAL_STATUS_EFFECTIVE_DATE;
17379 l_customer_tbl(l_rec).PERSON_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE1;
17380 l_customer_tbl(l_rec).PERSON_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE2;
17381 l_customer_tbl(l_rec).PERSON_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE3;
17382 l_customer_tbl(l_rec).PERSON_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE4;
17383 l_customer_tbl(l_rec).PERSON_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE5;
17384 l_customer_tbl(l_rec).PERSON_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE6;
17385 l_customer_tbl(l_rec).PERSON_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE7;
17386 l_customer_tbl(l_rec).PERSON_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE8;
17387 l_customer_tbl(l_rec).PERSON_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE9;
17388 l_customer_tbl(l_rec).PERSON_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE10;
17389 l_customer_tbl(l_rec).PERSON_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE11;
17390 l_customer_tbl(l_rec).PERSON_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE12;
17391 l_customer_tbl(l_rec).PERSON_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE13;
17392 l_customer_tbl(l_rec).PERSON_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE14;
17393 l_customer_tbl(l_rec).PERSON_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE15;
17394 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
17395 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
17396 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
17397 
17398 
17399              l_customer_tbl(l_rec).add_imp_xml_element_id := l_customer_tbl(l_rec - 1).add_imp_xml_element_id;
17400              l_customer_tbl(l_rec).address1 := l_customer_tbl(l_rec - 1).address1;
17401              l_customer_tbl(l_rec).address2 := l_customer_tbl(l_rec - 1).address2;
17402              l_customer_tbl(l_rec).address3 := l_customer_tbl(l_rec - 1).address3;
17403              l_customer_tbl(l_rec).address4 := l_customer_tbl(l_rec - 1).address4;
17404              l_customer_tbl(l_rec).city := l_customer_tbl(l_rec - 1).city;
17405              l_customer_tbl(l_rec).county := l_customer_tbl(l_rec - 1).county;
17406              l_customer_tbl(l_rec).province := l_customer_tbl(l_rec - 1).province;
17407              l_customer_tbl(l_rec).state := l_customer_tbl(l_rec - 1).state;
17408              l_customer_tbl(l_rec).postal_code := l_customer_tbl(l_rec - 1).postal_code;
17409              l_customer_tbl(l_rec).country  := l_customer_tbl(l_rec - 1).country;
17410              l_customer_tbl(l_rec).address_lines_phonetic := l_customer_tbl(l_rec - 1).address_lines_phonetic;
17411 -- bug 4641591: columns obsolete
17412 --	     l_customer_tbl(l_rec).po_box_number := l_customer_tbl(l_rec - 1).po_box_number;
17413 --             l_customer_tbl(l_rec).house_number := l_customer_tbl(l_rec - 1).house_number;
17414 --             l_customer_tbl(l_rec).street_suffix := l_customer_tbl(l_rec - 1).street_suffix;
17415 --             l_customer_tbl(l_rec).street := l_customer_tbl(l_rec - 1).street;
17416 --             l_customer_tbl(l_rec).street_number := l_customer_tbl(l_rec - 1).street_number;
17417 --             l_customer_tbl(l_rec).floor := l_customer_tbl(l_rec - 1).floor;
17418 --             l_customer_tbl(l_rec).suite := l_customer_tbl(l_rec - 1).suite;
17419              l_customer_tbl(l_rec).postal_plus4_code := l_customer_tbl(l_rec - 1).postal_plus4_code;
17420              l_customer_tbl(l_rec).identifying_address_flag := l_customer_tbl(l_rec - 1).identifying_address_flag;
17421 
17422 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE1;
17423 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE2;
17424 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE3;
17425 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE4;
17426 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE5;
17427 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE6;
17428 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE7;
17429 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE8;
17430 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE9;
17431 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE10;
17432 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE11;
17433 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE12;
17434 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE13;
17435 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE14;
17436 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE15;
17437 l_customer_tbl(l_rec).DESCRIPTION := l_customer_tbl(l_rec - 1).DESCRIPTION;
17438 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE_CATEGORY;
17439 l_customer_tbl(l_rec).PARTY_SITE_USE := l_customer_tbl(l_rec - 1).PARTY_SITE_USE;
17440 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := l_customer_tbl(l_rec - 1).LOCATION_DIRECTIONS;
17441 l_customer_tbl(l_rec).SHORT_DESCRIPTION := l_customer_tbl(l_rec - 1).SHORT_DESCRIPTION;
17442 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EFFECTIVE_DATE;
17443 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EXPIRATION_DATE;
17444 
17445          end if;
17446 
17447          -- l_customer_tbl(l_rec).cp_imp_xml_element_id := l_phiid_record_in_tbl(i).imp_xml_element_id;
17448          l_customer_tbl(l_rec).cp_imp_xml_element_id := l_phoid_record_in_tbl(k).imp_xml_element_id;
17449          l_customer_tbl(l_rec).phone_number := Get_Element_VALUE('PHONE_NUMBER',l_phiid_record_in_tbl);
17450          l_customer_tbl(l_rec).phone_country_code := Get_Element_VALUE('PHONE_COUNTRY_CODE',l_phiid_record_in_tbl);
17451          l_customer_tbl(l_rec).phone_area_code := Get_Element_VALUE('PHONE_AREA_CODE',l_phiid_record_in_tbl);
17452          l_customer_tbl(l_rec).phone_extension := Get_Element_VALUE('PHONE_EXTENTION',l_phiid_record_in_tbl);
17453          l_rec := 0;
17454        END LOOP; -- Phone
17455 
17456 
17457        -- Process  of Email data.
17458        l_ema_element_id := Get_Element_ID('EMAIL',l_addid_record_in_tbl);
17459        -- dbms_output.put_line( ' l_ema_element_id = '||to_char(l_ema_element_id));
17460 
17461     /********* Get all the elements for email *****************************/
17462       AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17463         p_imp_xml_element_id => l_ema_element_id,
17464         x_child_set          => l_emaid_record_in_tbl,
17465         x_return_status      => x_return_status,
17466         x_msg_data           => x_msg_data);
17467        -- dbms_output.put_line( ' attributl email count '||l_emaid_record_in_tbl.COUNT);
17468        FOR l IN 1..l_emaid_record_in_tbl.COUNT LOOP
17469         AMS_IMPORT_XML_PVT.Get_Children_Nodes (
17470         p_imp_xml_element_id => l_emaid_record_in_tbl(l).imp_xml_element_id,
17471         x_child_set          => l_emlid_record_in_tbl,
17472         x_return_status      => x_return_status,
17473         x_msg_data           => x_msg_data);
17474 
17475         l_rec := l_customer_tbl.count;
17476          if l > 1 then
17477              l_rec := l_customer_tbl.count+1;
17478              l_customer_tbl(l_rec).cust_data_id := l_rec;
17479 
17480 
17481              l_customer_tbl(l_rec).per_imp_xml_element_id := l_customer_tbl(l_rec - 1).per_imp_xml_element_id;
17482              l_customer_tbl(l_rec).PERSON_FIRST_NAME := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME;
17483              l_customer_tbl(l_rec).PERSON_LAST_NAME := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME;
17484              l_customer_tbl(l_rec).PERSON_MIDDLE_NAME := l_customer_tbl(l_rec - 1).PERSON_MIDDLE_NAME;
17485              l_customer_tbl(l_rec).PERSON_NAME_SUFFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_SUFFIX;
17486              l_customer_tbl(l_rec).PERSON_NAME_PREFIX := l_customer_tbl(l_rec - 1).PERSON_NAME_PREFIX;
17487              l_customer_tbl(l_rec).SALUTATION := l_customer_tbl(l_rec - 1).SALUTATION;
17488              l_customer_tbl(l_rec).party_id := l_customer_tbl(l_rec - 1).party_id;
17489 
17490 l_customer_tbl(l_rec).PERSONAL_INCOME := l_customer_tbl(l_rec - 1).PERSONAL_INCOME;
17491 l_customer_tbl(l_rec).PERSON_ACADEMIC_TITLE := l_customer_tbl(l_rec - 1).PERSON_ACADEMIC_TITLE;
17492 l_customer_tbl(l_rec).PERSON_FIRST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_FIRST_NAME_PHONETIC ;
17493 l_customer_tbl(l_rec).PERSON_LAST_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_LAST_NAME_PHONETIC;
17494 l_customer_tbl(l_rec).MIDDLE_NAME_PHONETIC := l_customer_tbl(l_rec - 1).MIDDLE_NAME_PHONETIC;
17495 l_customer_tbl(l_rec).PERSON_NAME_PHONETIC := l_customer_tbl(l_rec - 1).PERSON_NAME_PHONETIC;
17496 l_customer_tbl(l_rec).PERSON_PREVIOUS_TITLE_NAME := l_customer_tbl(l_rec - 1).PERSON_PREVIOUS_TITLE_NAME ;
17497 l_customer_tbl(l_rec).PLACE_OF_BIRTH := l_customer_tbl(l_rec - 1).PLACE_OF_BIRTH;
17498 l_customer_tbl(l_rec).HEAD_OF_HOUSEHOLD_FLAG := l_customer_tbl(l_rec - 1).HEAD_OF_HOUSEHOLD_FLAG;
17499 l_customer_tbl(l_rec).HOUSEHOLD_SIZE := l_customer_tbl(l_rec - 1).HOUSEHOLD_SIZE;
17500 l_customer_tbl(l_rec).TAX_REFERENCE := l_customer_tbl(l_rec - 1).TAX_REFERENCE;
17501 l_customer_tbl(l_rec).ORIG_SYSTEM_REFERENCE := l_customer_tbl(l_rec - 1).ORIG_SYSTEM_REFERENCE;
17502 l_customer_tbl(l_rec).RENT_OWNED_INDICATOR := l_customer_tbl(l_rec - 1).RENT_OWNED_INDICATOR;
17503 l_customer_tbl(l_rec).PERSON_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE_CATEGORY;
17504 l_customer_tbl(l_rec).DATE_OF_BIRTH := l_customer_tbl(l_rec - 1).DATE_OF_BIRTH;
17505 l_customer_tbl(l_rec).DATE_OF_DEATH := l_customer_tbl(l_rec - 1).DATE_OF_DEATH;
17506 l_customer_tbl(l_rec).DECLARED_ETHNICITY := l_customer_tbl(l_rec - 1).DECLARED_ETHNICITY;
17507 l_customer_tbl(l_rec).MARITAL_STATUS := l_customer_tbl(l_rec - 1).MARITAL_STATUS;
17508 l_customer_tbl(l_rec).MARITAL_STATUS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).MARITAL_STATUS_EFFECTIVE_DATE;
17509 l_customer_tbl(l_rec).PERSON_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE1;
17510 l_customer_tbl(l_rec).PERSON_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE2;
17511 l_customer_tbl(l_rec).PERSON_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE3;
17512 l_customer_tbl(l_rec).PERSON_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE4;
17513 l_customer_tbl(l_rec).PERSON_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE5;
17514 l_customer_tbl(l_rec).PERSON_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE6;
17515 l_customer_tbl(l_rec).PERSON_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE7;
17516 l_customer_tbl(l_rec).PERSON_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE8;
17517 l_customer_tbl(l_rec).PERSON_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE9;
17518 l_customer_tbl(l_rec).PERSON_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE10;
17519 l_customer_tbl(l_rec).PERSON_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE11;
17520 l_customer_tbl(l_rec).PERSON_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE12;
17521 l_customer_tbl(l_rec).PERSON_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE13;
17522 l_customer_tbl(l_rec).PERSON_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE14;
17523 l_customer_tbl(l_rec).PERSON_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).PERSON_ATTRIBUTE15;
17524 l_customer_tbl(l_rec).VEHICLE_RESPONSE_CODE := l_customer_tbl(l_rec - 1).VEHICLE_RESPONSE_CODE;
17525 l_customer_tbl(l_rec).SALES_AGENT_EMAIL_ID := l_customer_tbl(l_rec - 1).SALES_AGENT_EMAIL_ID;
17526 l_customer_tbl(l_rec).NOTES := l_customer_tbl(l_rec - 1).NOTES;
17527 
17528 
17529              l_customer_tbl(l_rec).add_imp_xml_element_id := l_customer_tbl(l_rec - 1).add_imp_xml_element_id;
17530              l_customer_tbl(l_rec).address1 := l_customer_tbl(l_rec - 1).address1;
17531              l_customer_tbl(l_rec).address2 := l_customer_tbl(l_rec - 1).address2;
17532              l_customer_tbl(l_rec).address3 := l_customer_tbl(l_rec - 1).address3;
17533              l_customer_tbl(l_rec).address4 := l_customer_tbl(l_rec - 1).address4;
17534              l_customer_tbl(l_rec).city := l_customer_tbl(l_rec - 1).city;
17535              l_customer_tbl(l_rec).county := l_customer_tbl(l_rec - 1).county;
17536              l_customer_tbl(l_rec).province := l_customer_tbl(l_rec - 1).province;
17537              l_customer_tbl(l_rec).state := l_customer_tbl(l_rec - 1).state;
17538              l_customer_tbl(l_rec).postal_code := l_customer_tbl(l_rec - 1).postal_code;
17539              l_customer_tbl(l_rec).country  := l_customer_tbl(l_rec - 1).country;
17540              l_customer_tbl(l_rec).address_lines_phonetic := l_customer_tbl(l_rec - 1).address_lines_phonetic;
17541 -- bug 4641591: columns obsolete
17542 --	     l_customer_tbl(l_rec).po_box_number := l_customer_tbl(l_rec - 1).po_box_number;
17543 --             l_customer_tbl(l_rec).house_number := l_customer_tbl(l_rec - 1).house_number;
17544 --             l_customer_tbl(l_rec).street_suffix := l_customer_tbl(l_rec - 1).street_suffix;
17545 --             l_customer_tbl(l_rec).street := l_customer_tbl(l_rec - 1).street;
17546 --             l_customer_tbl(l_rec).street_number := l_customer_tbl(l_rec - 1).street_number;
17547 --             l_customer_tbl(l_rec).floor := l_customer_tbl(l_rec - 1).floor;
17548 --             l_customer_tbl(l_rec).suite := l_customer_tbl(l_rec - 1).suite;
17549              l_customer_tbl(l_rec).postal_plus4_code := l_customer_tbl(l_rec - 1).postal_plus4_code;
17550              l_customer_tbl(l_rec).identifying_address_flag := l_customer_tbl(l_rec - 1).identifying_address_flag;
17551 
17552 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE1 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE1;
17553 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE2 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE2;
17554 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE3 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE3;
17555 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE4 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE4;
17556 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE5 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE5;
17557 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE6 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE6;
17558 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE7 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE7;
17559 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE8 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE8;
17560 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE9 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE9;
17561 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE10 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE10;
17562 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE11 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE11;
17563 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE12 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE12;
17564 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE13 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE13;
17565 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE14 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE14;
17566 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE15 := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE15;
17567 l_customer_tbl(l_rec).DESCRIPTION := l_customer_tbl(l_rec - 1).DESCRIPTION;
17568 l_customer_tbl(l_rec).ADDRESS_ATTRIBUTE_CATEGORY := l_customer_tbl(l_rec - 1).ADDRESS_ATTRIBUTE_CATEGORY;
17569 l_customer_tbl(l_rec).PARTY_SITE_USE := l_customer_tbl(l_rec - 1).PARTY_SITE_USE;
17570 l_customer_tbl(l_rec).LOCATION_DIRECTIONS := l_customer_tbl(l_rec - 1).LOCATION_DIRECTIONS;
17571 l_customer_tbl(l_rec).SHORT_DESCRIPTION := l_customer_tbl(l_rec - 1).SHORT_DESCRIPTION;
17572 l_customer_tbl(l_rec).ADDRESS_EFFECTIVE_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EFFECTIVE_DATE;
17573 l_customer_tbl(l_rec).ADDRESS_EXPIRATION_DATE := l_customer_tbl(l_rec - 1).ADDRESS_EXPIRATION_DATE;
17574 
17575          end if;
17576          l_customer_tbl(l_rec).em_imp_xml_element_id := l_emaid_record_in_tbl(l).imp_xml_element_id;
17577          l_customer_tbl(l_rec).email_address := Get_Element_VALUE('EMAIL_ADDRESS',l_emlid_record_in_tbl);
17578          l_rec := 0;
17579        END LOOP; -- Email
17580 
17581      -- ******************************Location process
17582 
17583        END LOOP; -- Locarion process
17584        p_cust_tbl := l_customer_tbl;
17585 
17586  exception
17587  WHEN OTHERS THEN
17588     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
17589     FND_MESSAGE.Set_Token('ROW','Error in Process_b2c_xml_data :' || SQLERRM||' '||SQLCODE);
17590     AMS_Utility_PVT.Create_Log (
17591       x_return_status   => x_return_status,
17592       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
17593       p_log_used_by_id  => p_import_list_header_id,
17594       p_msg_data        => FND_MESSAGE.get,
17595       p_msg_type        => 'DEBUG'
17596    );
17597 
17598 END Process_b2c_xml_data;
17599 -- -----------------------------------------------------
17600 --
17601 -- This program populates the ams_imp-source_lines table.
17602 --
17603 Procedure      Create_b2b_src_lines(
17604                 p_import_list_header_id   IN number,
17605                 p_cust_b2b_tbl            in cust_data_in_tbl,
17606                 x_return_status           OUT NOCOPY varchar2,
17607                 x_msg_data                OUT NOCOPY varchar2) is
17608 
17609 l_batch_id      number;
17610 cursor c_batchID is select batch_id from ams_imp_list_headers_all
17611 where import_list_header_id = p_import_list_header_id;
17612 
17613 begin
17614  open c_batchID;
17615  fetch c_batchID into l_batch_id;
17616  close c_batchID;
17617  FOR i IN 1..p_cust_b2b_tbl.COUNT LOOP
17618  Insert into AMS_HZ_B2B_MAPPING_V(
17619  IMPORT_SOURCE_LINE_ID,
17620  LAST_UPDATED_BY,
17621  LAST_UPDATE_DATE,
17622  CREATION_DATE,
17623  CREATED_BY,
17624  LAST_UPDATE_LOGIN,
17625  IMPORT_SUCCESSFUL_FLAG,
17626  OBJECT_VERSION_NUMBER,
17627  IMPORT_LIST_HEADER_ID,
17628  LOAD_STATUS,
17629  batch_id,
17630  PARTY_NAME,
17631  FISCAL_YEAREND_MONTH,
17632  DUNS_NUMBER,
17633  EMPLOYEES_TOTAL,
17634  LINE_OF_BUSINESS,
17635  YEAR_ESTABLISHED,
17636  TAX_REFERENCE,
17637  CEO_NAME,
17638  PERSON_FIRST_NAME,
17639  PERSON_MIDDLE_NAME,
17640  PERSON_LAST_NAME,
17641  PERSON_NAME_SUFFIX,
17642  PERSON_NAME_PREFIX,
17643  COUNTRY,
17644  ADDRESS1,
17645  ADDRESS2,
17646  CITY,
17647  COUNTY,
17648  STATE,
17649  PROVINCE,
17650  POSTAL_CODE,
17651  EMAIL_ADDRESS,
17652  PHONE_COUNTRY_CODE,
17653  PHONE_AREA_CODE,
17654  PHONE_NUMBER,
17655  PHONE_EXTENTION,
17656  DEPARTMENT,
17657  JOB_TITLE,
17658  DECISION_MAKER_FLAG,
17659  SIC_CODE,
17660  SIC_CODE_TYPE,
17661  ANALYSIS_FY         ,
17662  CURR_FY_POTENTIAL_REVENUE,
17663  NEXT_FY_POTENTIAL_REVENUE,
17664  GSA_INDICATOR_FLAG       ,
17665  MISSION_STATEMENT        ,
17666  ORGANIZATION_NAME_PHONETIC,
17667  CATEGORY_CODE              ,
17668  JGZZ_FISCAL_CODE           ,
17669  ADDRESS3                   ,
17670  ADDRESS4                   ,
17671  ADDRESS_LINES_PHONETIC     ,
17672 -- bug 4641591: columns obsolete
17673 -- PO_BOX_NUMBER              ,
17674 -- HOUSE_NUMBER               ,
17675 -- STREET_SUFFIX              ,
17676 -- STREET                     ,
17677 -- STREET_NUMBER              ,
17678 -- FLOOR                      ,
17679 -- SUITE                      ,
17680  POSTAL_PLUS4_CODE          ,
17681  identifying_address_flag   ,
17682  party_id,
17683 org_imp_xml_element_id,
17684 add_imp_xml_element_id,
17685 ocont_imp_xml_element_id,
17686 cp_imp_xml_element_id,
17687 em_imp_xml_element_id,
17688 ADDRESS_EFFECTIVE_DATE,
17689 ADDRESS_EXPIRATION_DATE,
17690 -- ANNUAL_REVENUE,
17691 -- ANNUAL_REVENUE_CURRENCY,
17692 BRANCH_FLAG,
17693 BUSINESS_LINE,
17694 BUSINESS_SCOPE,
17695 CHIEF_EXECUTIVE_TITLE,
17696 CONGRESSIONAL_DISTRICT_CODE,
17697 CONTROL_YEAR,
17698 CORPORATION_CLASS,
17699 CREDIT_SCORE,
17700 CREDIT_SCORE_COMMENTARY,
17701 CUSTOMER_CATEGORY,
17702 DB_RATING,
17703 DATE_OF_BIRTH,
17704 DATE_OF_DEATH,
17705 DEBARMENTS_COUNT,
17706 DEBARTMENTS_DATE,
17707 DECLARED_ETHNICITY,
17708 DEPARTMENT_INDICATOR,
17709 DESCRIPTION,
17710 DISADVANTAGED_INDICATOR,
17711 ENQUIRY_DUNS,
17712 EXPORT_INDICATOR,
17713 FAILURE_SCORE,
17714 FAILURE_SCORE_COMMENTARY,
17715 FAILURE_SCORE_NATL_PERCENTILE,
17716 FAILURE_SCORE_OVERRIDE_CODE,
17717 -- FISCAL_CODE,
17718 GLOBAL_FAILURE_SCORE,
17719 HEADQUARTER_BRANCH_INDICATOR,
17720 HEAD_OF_HOUSEHOLD_FLAG,
17721 HOUSEHOLD_SIZE,
17722 IMPORT_INDICATOR,
17723 ORGANIZATION_KNOWN_AS,
17724 ORGANIZATION_KNOWN_AS2,
17725 ORGANIZATION_KNOWN_AS3,
17726 ORGANIZATION_KNOWN_AS4,
17727 ORGANIZATION_KNOWN_AS5,
17728 PERSON_KNOWN_AS,
17729 PERSON_KNOWN_AS2,
17730 PERSON_KNOWN_AS3,
17731 PERSON_KNOWN_AS4,
17732 PERSON_KNOWN_AS5,
17733 LABOR_SURPLUS_INDICATOR,
17734 LOCAL_ACTIVITY_CODE,
17735 LOCAL_ACTIVITY_CODE_TYPE,
17736 LOCATION_DIRECTIONS,
17737 -- LOCATION_STATUS,
17738 MARITAL_STATUS,
17739 MARITAL_STATUS_EFFECTIVE_DATE,
17740 MINORITY_OWNED_INDICATOR,
17741 MINORITY_OWNED_TYPE,
17742 -- ORGANIZATION_ALIAS,
17743 ORGANIZATION_TYPE,
17744 ORGANIZATION_URL,
17745 OUT_OF_BUSINESS_INDICATOR,
17746 PERSONAL_INCOME,
17747 PERSON_ACADEMIC_TITLE,
17748 PERSON_FIRST_NAME_PHONETIC,
17749 PERSON_LAST_NAME_PHONETIC,
17750 MIDDLE_NAME_PHONETIC,
17751 PERSON_NAME_PHONETIC,
17752 PERSON_PREVIOUS_TITLE_NAME,
17753 PLACE_OF_BIRTH,
17754 -- PREFERRED_NAME,
17755 PRINCIPAL_NAME,
17756 PRINCIPAL_TITLE,
17757 PUBLIC_PRIVATE_OWNERSHIP_FLAG,
17758 RENT_OWNED_INDICATOR,
17759 -- RENT_OWNER_INDICATOR,
17760 -- SECOND_TITLE,
17761 SHORT_DESCRIPTION,
17762 SMALL_BUSINESS_INDICATOR,
17763 TAX_ID,
17764 WOMAN_OWNED_INDICATOR,
17765 ORGANIZATION_ATTRIBUTE1,
17766 ORGANIZATION_ATTRIBUTE2,
17767 ORGANIZATION_ATTRIBUTE3,
17768 ORGANIZATION_ATTRIBUTE4,
17769 ORGANIZATION_ATTRIBUTE5,
17770 ORGANIZATION_ATTRIBUTE6,
17771 ORGANIZATION_ATTRIBUTE7,
17772 ORGANIZATION_ATTRIBUTE8,
17773 ORGANIZATION_ATTRIBUTE9,
17774 ORGANIZATION_ATTRIBUTE10,
17775 ORGANIZATION_ATTRIBUTE11,
17776 ORGANIZATION_ATTRIBUTE12,
17777 ORGANIZATION_ATTRIBUTE13,
17778 ORGANIZATION_ATTRIBUTE14,
17779 ORGANIZATION_ATTRIBUTE15,
17780 ORG_CONTACT_ATTRIBUTE1,
17781 ORG_CONTACT_ATTRIBUTE2,
17782 ORG_CONTACT_ATTRIBUTE3,
17783 ORG_CONTACT_ATTRIBUTE4,
17784 ORG_CONTACT_ATTRIBUTE5,
17785 ORG_CONTACT_ATTRIBUTE6,
17786 ORG_CONTACT_ATTRIBUTE7,
17787 ORG_CONTACT_ATTRIBUTE8,
17788 ORG_CONTACT_ATTRIBUTE9,
17789 ORG_CONTACT_ATTRIBUTE10,
17790 ORG_CONTACT_ATTRIBUTE11,
17791 ORG_CONTACT_ATTRIBUTE12,
17792 ORG_CONTACT_ATTRIBUTE13,
17793 ORG_CONTACT_ATTRIBUTE14,
17794 ORG_CONTACT_ATTRIBUTE15,
17795 ADDRESS_ATTRIBUTE1,
17796 ADDRESS_ATTRIBUTE2,
17797 ADDRESS_ATTRIBUTE3,
17798 ADDRESS_ATTRIBUTE4,
17799 ADDRESS_ATTRIBUTE5,
17800 ADDRESS_ATTRIBUTE6,
17801 ADDRESS_ATTRIBUTE7,
17802 ADDRESS_ATTRIBUTE8,
17803 ADDRESS_ATTRIBUTE9,
17804 ADDRESS_ATTRIBUTE10,
17805 ADDRESS_ATTRIBUTE11,
17806 ADDRESS_ATTRIBUTE12,
17807 ADDRESS_ATTRIBUTE13,
17808 ADDRESS_ATTRIBUTE14,
17809 ADDRESS_ATTRIBUTE15,
17810 ORG_ATTRIBUTE_CATEGORY,
17811 ORG_CONTACT_ATTRIBUTE_CATEGORY,
17812 ADDRESS_ATTRIBUTE_CATEGORY,
17813 PARTY_SITE_USE,
17814 VEHICLE_RESPONSE_CODE,
17815 SALES_AGENT_EMAIL_ADDRESS,
17816 NOTES,
17817 orig_system_reference
17818 )
17819  VALUES
17820  (
17821  ams_imp_source_lines_s.nextval,    -- IMPORT_SOURCE_LINE_ID,
17822  FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
17823  SYSDATE,                              -- LAST_UPDATE_DATE,
17824  SYSDATE,                              -- CREATION_DATE,
17825  FND_GLOBAL.User_ID,                   -- CREATED_BY,
17826  FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
17827  'N',
17828  '1',
17829  p_import_list_header_id,
17830  'ACTIVE',
17831  l_batch_id,
17832  p_cust_b2b_tbl(i).PARTY_NAME,
17833  p_cust_b2b_tbl(i).FISCAL_YEAREND_MONTH,
17834  p_cust_b2b_tbl(i).DUNS_NUMBER,
17835  p_cust_b2b_tbl(i).EMPLOYEES_TOTAL,
17836  p_cust_b2b_tbl(i).LINE_OF_BUSINESS,
17837  p_cust_b2b_tbl(i).YEAR_ESTABLISHED,
17838  p_cust_b2b_tbl(i).TAX_REFERENCE,
17839  p_cust_b2b_tbl(i).CEO_NAME,
17840  p_cust_b2b_tbl(i).PERSON_FIRST_NAME,
17841  p_cust_b2b_tbl(i).PERSON_MIDDLE_NAME,
17842  p_cust_b2b_tbl(i).PERSON_LAST_NAME,
17843  p_cust_b2b_tbl(i).PERSON_NAME_SUFFIX,
17844  p_cust_b2b_tbl(i).PERSON_NAME_PREFIX,
17845  p_cust_b2b_tbl(i).COUNTRY,
17846  p_cust_b2b_tbl(i).ADDRESS1,
17847  p_cust_b2b_tbl(i).ADDRESS2,
17848  p_cust_b2b_tbl(i).CITY,
17849  p_cust_b2b_tbl(i).COUNTY,
17850  p_cust_b2b_tbl(i).STATE,
17851  p_cust_b2b_tbl(i).PROVINCE,
17852  p_cust_b2b_tbl(i).POSTAL_CODE,
17853  p_cust_b2b_tbl(i).EMAIL_ADDRESS,
17854  p_cust_b2b_tbl(i).PHONE_COUNTRY_CODE,
17855  p_cust_b2b_tbl(i).PHONE_AREA_CODE,
17856  p_cust_b2b_tbl(i).PHONE_NUMBER,
17857  p_cust_b2b_tbl(i).PHONE_EXTENSION,
17858  p_cust_b2b_tbl(i).DEPARTMENT,
17859  p_cust_b2b_tbl(i).JOB_TITLE,
17860  p_cust_b2b_tbl(i).DECISION_MAKER_FLAG,
17861  p_cust_b2b_tbl(i).SIC_CODE,
17862  p_cust_b2b_tbl(i).SIC_CODE_TYPE,
17863  p_cust_b2b_tbl(i).ANALYSIS_FY         ,
17864  p_cust_b2b_tbl(i).CURR_FY_POTENTIAL_REVENUE,
17865  p_cust_b2b_tbl(i).NEXT_FY_POTENTIAL_REVENUE,
17866  p_cust_b2b_tbl(i).GSA_INDICATOR_FLAG       ,
17867  p_cust_b2b_tbl(i).MISSION_STATEMENT        ,
17868  p_cust_b2b_tbl(i).ORGANIZATION_NAME_PHONETIC,
17869  p_cust_b2b_tbl(i).CATEGORY_CODE              ,
17870  p_cust_b2b_tbl(i).JGZZ_FISCAL_CODE           ,
17871  p_cust_b2b_tbl(i).ADDRESS3                   ,
17872  p_cust_b2b_tbl(i).ADDRESS4                   ,
17873  p_cust_b2b_tbl(i).ADDRESS_LINES_PHONETIC     ,
17874 -- bug 4641591: columns obsolete
17875 -- p_cust_b2b_tbl(i).PO_BOX_NUMBER              ,
17876 -- p_cust_b2b_tbl(i).HOUSE_NUMBER               ,
17877 -- p_cust_b2b_tbl(i).STREET_SUFFIX              ,
17878 -- p_cust_b2b_tbl(i).STREET                     ,
17879 -- p_cust_b2b_tbl(i).STREET_NUMBER              ,
17880 -- p_cust_b2b_tbl(i).FLOOR                      ,
17881 -- p_cust_b2b_tbl(i).SUITE                      ,
17882  p_cust_b2b_tbl(i).POSTAL_PLUS4_CODE          ,
17883  p_cust_b2b_tbl(i).identifying_address_flag   ,
17884  p_cust_b2b_tbl(i).party_id,
17885 p_cust_b2b_tbl(i).org_imp_xml_element_id,
17886 p_cust_b2b_tbl(i).add_imp_xml_element_id,
17887 p_cust_b2b_tbl(i).ocont_imp_xml_element_id,
17888 p_cust_b2b_tbl(i).cp_imp_xml_element_id,
17889 p_cust_b2b_tbl(i).em_imp_xml_element_id,
17890 p_cust_b2b_tbl(i).ADDRESS_EFFECTIVE_DATE,
17891 p_cust_b2b_tbl(i).ADDRESS_EXPIRATION_DATE,
17892 -- p_cust_b2b_tbl(i).ANNUAL_REVENUE,
17893 -- p_cust_b2b_tbl(i).ANNUAL_REVENUE_CURRENCY,
17894 p_cust_b2b_tbl(i).BRANCH_FLAG,
17895 p_cust_b2b_tbl(i).BUSINESS_LINE,
17896 p_cust_b2b_tbl(i).BUSINESS_SCOPE,
17897 p_cust_b2b_tbl(i).CHIEF_EXECUTIVE_TITLE,
17898 p_cust_b2b_tbl(i).CONGRESSIONAL_DISTRICT_CODE,
17899 p_cust_b2b_tbl(i).CONTROL_YEAR,
17900 p_cust_b2b_tbl(i).CORPORATION_CLASS,
17901 p_cust_b2b_tbl(i).CREDIT_SCORE,
17902 p_cust_b2b_tbl(i).CREDIT_SCORE_COMMENTARY,
17903 p_cust_b2b_tbl(i).CUSTOMER_CATEGORY,
17904 p_cust_b2b_tbl(i).DB_RATING,
17905 p_cust_b2b_tbl(i).DATE_OF_BIRTH,
17906 p_cust_b2b_tbl(i).DATE_OF_DEATH,
17907 p_cust_b2b_tbl(i).DEBARMENTS_COUNT,
17908 p_cust_b2b_tbl(i).DEBARTMENTS_DATE,
17909 p_cust_b2b_tbl(i).DECLARED_ETHNICITY,
17910 p_cust_b2b_tbl(i).DEPARTMENT_INDICATOR,
17911 p_cust_b2b_tbl(i).DESCRIPTION,
17912 p_cust_b2b_tbl(i).DISADVANTAGED_INDICATOR,
17913 p_cust_b2b_tbl(i).ENQUIRY_DUNS,
17914 p_cust_b2b_tbl(i).EXPORT_INDICATOR,
17915 p_cust_b2b_tbl(i).FAILURE_SCORE,
17916 p_cust_b2b_tbl(i).FAILURE_SCORE_COMMENTARY,
17917 p_cust_b2b_tbl(i).FAILURE_SCORE_NATL_PERCENTILE,
17918 p_cust_b2b_tbl(i).FAILURE_SCORE_OVERRIDE_CODE,
17919 -- p_cust_b2b_tbl(i).FISCAL_CODE,
17920 p_cust_b2b_tbl(i).GLOBAL_FAILURE_SCORE,
17921 p_cust_b2b_tbl(i).HEADQUARTER_BRANCH_INDICATOR,
17922 p_cust_b2b_tbl(i).HEAD_OF_HOUSEHOLD_FLAG,
17923 p_cust_b2b_tbl(i).HOUSEHOLD_SIZE,
17924 p_cust_b2b_tbl(i).IMPORT_INDICATOR,
17925 p_cust_b2b_tbl(i).ORGANIZATION_KNOWN_AS,
17926 p_cust_b2b_tbl(i).ORGANIZATION_KNOWN_AS2,
17927 p_cust_b2b_tbl(i).ORGANIZATION_KNOWN_AS3,
17928 p_cust_b2b_tbl(i).ORGANIZATION_KNOWN_AS4,
17929 p_cust_b2b_tbl(i).ORGANIZATION_KNOWN_AS5,
17930 p_cust_b2b_tbl(i).PERSON_KNOWN_AS,
17931 p_cust_b2b_tbl(i).PERSON_KNOWN_AS2,
17932 p_cust_b2b_tbl(i).PERSON_KNOWN_AS3,
17933 p_cust_b2b_tbl(i).PERSON_KNOWN_AS4,
17934 p_cust_b2b_tbl(i).PERSON_KNOWN_AS5,
17935 p_cust_b2b_tbl(i).LABOR_SURPLUS_INDICATOR,
17936 p_cust_b2b_tbl(i).LOCAL_ACTIVITY_CODE,
17937 p_cust_b2b_tbl(i).LOCAL_ACTIVITY_CODE_TYPE,
17938 p_cust_b2b_tbl(i).LOCATION_DIRECTIONS,
17939 -- p_cust_b2b_tbl(i).LOCATION_STATUS,
17940 p_cust_b2b_tbl(i).MARITAL_STATUS,
17941 p_cust_b2b_tbl(i).MARITAL_STATUS_EFFECTIVE_DATE,
17942 p_cust_b2b_tbl(i).MINORITY_OWNED_INDICATOR,
17943 p_cust_b2b_tbl(i).MINORITY_OWNED_TYPE,
17944 -- p_cust_b2b_tbl(i).ORGANIZATION_ALIAS,
17945 p_cust_b2b_tbl(i).ORGANIZATION_TYPE,
17946 p_cust_b2b_tbl(i).ORGANIZATION_URL,
17947 p_cust_b2b_tbl(i).OUT_OF_BUSINESS_INDICATOR,
17948 p_cust_b2b_tbl(i).PERSONAL_INCOME,
17949 p_cust_b2b_tbl(i).PERSON_ACADEMIC_TITLE,
17950 p_cust_b2b_tbl(i).PERSON_FIRST_NAME_PHONETIC,
17951 p_cust_b2b_tbl(i).PERSON_LAST_NAME_PHONETIC,
17952 p_cust_b2b_tbl(i).MIDDLE_NAME_PHONETIC,
17953 p_cust_b2b_tbl(i).PERSON_NAME_PHONETIC,
17954 p_cust_b2b_tbl(i).PERSON_PREVIOUS_TITLE_NAME,
17955 p_cust_b2b_tbl(i).PLACE_OF_BIRTH,
17956 -- p_cust_b2b_tbl(i).PREFERRED_NAME,
17957 p_cust_b2b_tbl(i).PRINCIPAL_NAME,
17958 p_cust_b2b_tbl(i).PRINCIPAL_TITLE,
17959 p_cust_b2b_tbl(i).PUBLIC_PRIVATE_OWNERSHIP_FLAG,
17960 p_cust_b2b_tbl(i).RENT_OWNED_INDICATOR,
17961 -- p_cust_b2b_tbl(i).RENT_OWNER_INDICATOR,
17962 -- p_cust_b2b_tbl(i).SECOND_TITLE,
17963 p_cust_b2b_tbl(i).SHORT_DESCRIPTION,
17964 p_cust_b2b_tbl(i).SMALL_BUSINESS_INDICATOR,
17965 p_cust_b2b_tbl(i).TAX_ID,
17966 p_cust_b2b_tbl(i).WOMAN_OWNED_INDICATOR,
17967 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE1,
17968 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE2,
17969 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE3,
17970 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE4,
17971 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE5,
17972 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE6,
17973 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE7,
17974 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE8,
17975 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE9,
17976 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE10,
17977 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE11,
17978 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE12,
17979 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE13,
17980 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE14,
17981 p_cust_b2b_tbl(i).ORGANIZATION_ATTRIBUTE15,
17982 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE1,
17983 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE2,
17984 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE3,
17985 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE4,
17986 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE5,
17987 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE6,
17988 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE7,
17989 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE8,
17990 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE9,
17991 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE10,
17992 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE11,
17993 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE12,
17994 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE13,
17995 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE14,
17996 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE15,
17997 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE1,
17998 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE2,
17999 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE3,
18000 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE4,
18001 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE5,
18002 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE6,
18003 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE7,
18004 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE8,
18005 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE9,
18006 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE10,
18007 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE11,
18008 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE12,
18009 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE13,
18010 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE14,
18011 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE15,
18012 p_cust_b2b_tbl(i).ORG_ATTRIBUTE_CATEGORY,
18013 p_cust_b2b_tbl(i).ORG_CONTACT_ATTRIBUTE_CATEGORY,
18014 p_cust_b2b_tbl(i).ADDRESS_ATTRIBUTE_CATEGORY,
18015 p_cust_b2b_tbl(i).PARTY_SITE_USE,
18016 p_cust_b2b_tbl(i).VEHICLE_RESPONSE_CODE,
18017 p_cust_b2b_tbl(i).SALES_AGENT_EMAIL_ID,
18018 p_cust_b2b_tbl(i).NOTES,
18019 p_cust_b2b_tbl(i).orig_system_reference
18020 );
18021  END LOOP;
18022 commit;
18023 
18024  exception
18025  WHEN OTHERS THEN
18026     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
18027     FND_MESSAGE.Set_Token('ROW','Error in Create_b2b_src_lines:' || SQLERRM||' '||SQLCODE);
18028     AMS_Utility_PVT.Create_Log (
18029       x_return_status   => x_return_status,
18030       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
18031       p_log_used_by_id  => p_import_list_header_id,
18032       p_msg_data        => FND_MESSAGE.get,
18033       p_msg_type        => 'DEBUG'
18034    );
18035 
18036 end Create_b2b_src_lines;
18037 -- -------------------------------------------------------------------
18038 --
18039 -- This program populates the ams_imp-source_lines table.
18040 --
18041 Procedure      Create_b2c_src_lines(
18042                 p_import_list_header_id   IN number,
18043                 p_cust_b2c_tbl            in cust_b2c_data_in_tbl,
18044                 x_return_status           OUT NOCOPY varchar2,
18045                 x_msg_data                OUT NOCOPY varchar2) IS
18046 
18047 l_batch_id	number;
18048 cursor c_batchID is select batch_id from ams_imp_list_headers_all
18049 where import_list_header_id = p_import_list_header_id;
18050 
18051 begin
18052  open c_batchID;
18053  fetch c_batchID into l_batch_id;
18054  close c_batchID;
18055  FOR i IN 1..p_cust_b2c_tbl.COUNT LOOP
18056  Insert into AMS_HZ_B2C_MAPPING_V(
18057  IMPORT_SOURCE_LINE_ID,
18058  LAST_UPDATED_BY,
18059  LAST_UPDATE_DATE,
18060  CREATION_DATE,
18061  CREATED_BY,
18062  LAST_UPDATE_LOGIN,
18063  IMPORT_SUCCESSFUL_FLAG,
18064  OBJECT_VERSION_NUMBER,
18065  IMPORT_LIST_HEADER_ID,
18066  LOAD_STATUS,
18067  batch_id,
18068  PERSON_FIRST_NAME,
18069  PERSON_MIDDLE_NAME,
18070  PERSON_LAST_NAME,
18071  PERSON_NAME_SUFFIX,
18072  PERSON_NAME_PREFIX,
18073  -- PERSON_PRE_NAME_ADJUNCT,
18074  SALUTATION,
18075  COUNTRY,
18076  ADDRESS1,
18077  ADDRESS2,
18078  CITY,
18079  COUNTY,
18080  STATE,
18081  PROVINCE,
18082  POSTAL_CODE,
18083  EMAIL_ADDRESS,
18084  PHONE_COUNTRY_CODE,
18085  PHONE_AREA_CODE,
18086  PHONE_NUMBER,
18087  PHONE_EXTENTION,
18088  ADDRESS3                   ,
18089  ADDRESS4                   ,
18090  ADDRESS_LINES_PHONETIC     ,
18091 -- bug 4641591: columns obsolete
18092 -- PO_BOX_NUMBER              ,
18093 -- HOUSE_NUMBER               ,
18094 -- STREET_SUFFIX              ,
18095 -- STREET                     ,
18096 -- STREET_NUMBER              ,
18097 -- FLOOR                      ,
18098 -- SUITE                      ,
18099  POSTAL_PLUS4_CODE          ,
18100  identifying_address_flag   ,
18101  party_id,
18102 per_imp_xml_element_id,
18103 add_imp_xml_element_id,
18104 cp_imp_xml_element_id,
18105 em_imp_xml_element_id,
18106 PERSON_LAST_NAME_PHONETIC,
18107 PERSON_FIRST_NAME_PHONETIC,
18108 URL,
18109 DATE_OF_BIRTH,
18110 PERSON_ACADEMIC_TITLE,
18111 PERSON_PREVIOUS_TITLE_NAME,
18112 PERSON_KNOWN_AS,
18113 PERSON_KNOWN_AS2,
18114 PERSON_KNOWN_AS3,
18115 PERSON_KNOWN_AS4,
18116 PERSON_KNOWN_AS5,
18117 PERSON_NAME_PHONETIC,
18118 MIDDLE_NAME_PHONETIC,
18119 FISCAL_CODE,
18120 PLACE_OF_BIRTH,
18121 DATE_OF_DEATH,
18122 DECLARED_ETHNICITY,
18123 MARITAL_STATUS,
18124 PERSONAL_INCOME,
18125 MARITAL_STATUS_EFFECTIVE_DATE,
18126 HEAD_OF_HOUSEHOLD_FLAG,
18127 HOUSEHOLD_SIZE,
18128 LOCATION_DIRECTIONS,
18129 ADDRESS_EFFECTIVE_DATE,
18130 ADDRESS_EXPIRATION_DATE,
18131 PERSON_ATTRIBUTE1,
18132 PERSON_ATTRIBUTE2,
18133 PERSON_ATTRIBUTE3,
18134 PERSON_ATTRIBUTE4,
18135 PERSON_ATTRIBUTE5,
18136 PERSON_ATTRIBUTE6,
18137 PERSON_ATTRIBUTE7,
18138 PERSON_ATTRIBUTE8,
18139 PERSON_ATTRIBUTE9,
18140 PERSON_ATTRIBUTE10,
18141 PERSON_ATTRIBUTE11,
18142 PERSON_ATTRIBUTE12,
18143 PERSON_ATTRIBUTE13,
18144 PERSON_ATTRIBUTE14,
18145 PERSON_ATTRIBUTE15,
18146 ADDRESS_ATTRIBUTE1,
18147 ADDRESS_ATTRIBUTE2,
18148 ADDRESS_ATTRIBUTE3,
18149 ADDRESS_ATTRIBUTE4,
18150 ADDRESS_ATTRIBUTE5,
18151 ADDRESS_ATTRIBUTE6,
18152 ADDRESS_ATTRIBUTE7,
18153 ADDRESS_ATTRIBUTE8,
18154 ADDRESS_ATTRIBUTE9,
18155 ADDRESS_ATTRIBUTE10,
18156 ADDRESS_ATTRIBUTE11,
18157 ADDRESS_ATTRIBUTE12,
18158 ADDRESS_ATTRIBUTE13,
18159 ADDRESS_ATTRIBUTE14,
18160 ADDRESS_ATTRIBUTE15,
18161 PERSON_ATTRIBUTE_CATEGORY,
18162 ADDRESS_ATTRIBUTE_CATEGORY,
18163 PARTY_SITE_USE,
18164 SHORT_DESCRIPTION,
18165 DESCRIPTION,
18166 VEHICLE_RESPONSE_CODE,
18167 SALES_AGENT_EMAIL_ADDRESS,
18168 NOTES,
18169 orig_system_reference,
18170 tax_reference,
18171 rent_owned_indicator
18172 )
18173  VALUES
18174  (
18175  ams_imp_source_lines_s.nextval,    -- IMPORT_SOURCE_LINE_ID,
18176  FND_GLOBAL.User_ID,                   -- LAST_UPDATED_BY,
18177  SYSDATE,                              -- LAST_UPDATE_DATE,
18178  SYSDATE,                              -- CREATION_DATE,
18179  FND_GLOBAL.User_ID,                   -- CREATED_BY,
18180  FND_GLOBAL.Conc_Login_ID,             -- LAST_UPDATE_LOGIN,
18181  'N',
18182  '1',
18183  p_import_list_header_id,
18184  'ACTIVE',
18185  l_batch_id,
18186  p_cust_b2c_tbl(i).PERSON_FIRST_NAME,
18187  p_cust_b2c_tbl(i).PERSON_MIDDLE_NAME,
18188  p_cust_b2c_tbl(i).PERSON_LAST_NAME,
18189  p_cust_b2c_tbl(i).PERSON_NAME_SUFFIX,
18190  p_cust_b2c_tbl(i).PERSON_NAME_PREFIX,
18191 --  p_cust_b2c_tbl(i).PERSON_PRE_NAME_ADJUNCT,
18192  p_cust_b2c_tbl(i).salutation,
18193  p_cust_b2c_tbl(i).COUNTRY,
18194  p_cust_b2c_tbl(i).ADDRESS1,
18195  p_cust_b2c_tbl(i).ADDRESS2,
18196  p_cust_b2c_tbl(i).CITY,
18197  p_cust_b2c_tbl(i).COUNTY,
18198  p_cust_b2c_tbl(i).STATE,
18199  p_cust_b2c_tbl(i).PROVINCE,
18200  p_cust_b2c_tbl(i).POSTAL_CODE,
18201  p_cust_b2c_tbl(i).EMAIL_ADDRESS,
18202  p_cust_b2c_tbl(i).PHONE_COUNTRY_CODE,
18203  p_cust_b2c_tbl(i).PHONE_AREA_CODE,
18204  p_cust_b2c_tbl(i).PHONE_NUMBER,
18205  p_cust_b2c_tbl(i).PHONE_EXTENSION,
18206  p_cust_b2c_tbl(i).ADDRESS3                   ,
18207  p_cust_b2c_tbl(i).ADDRESS4                   ,
18208  p_cust_b2c_tbl(i).ADDRESS_LINES_PHONETIC     ,
18209 -- bug 4641591: columns obsolete
18210 -- p_cust_b2c_tbl(i).PO_BOX_NUMBER              ,
18211 -- p_cust_b2c_tbl(i).HOUSE_NUMBER               ,
18212 -- p_cust_b2c_tbl(i).STREET_SUFFIX              ,
18213 -- p_cust_b2c_tbl(i).STREET                     ,
18214 -- p_cust_b2c_tbl(i).STREET_NUMBER              ,
18215 -- p_cust_b2c_tbl(i).FLOOR                      ,
18216 -- p_cust_b2c_tbl(i).SUITE                      ,
18217  p_cust_b2c_tbl(i).POSTAL_PLUS4_CODE          ,
18218  p_cust_b2c_tbl(i).identifying_address_flag   ,
18219  p_cust_b2c_tbl(i).party_id,
18220 p_cust_b2c_tbl(i).per_imp_xml_element_id,
18221 p_cust_b2c_tbl(i).add_imp_xml_element_id,
18222 p_cust_b2c_tbl(i).cp_imp_xml_element_id,
18223 p_cust_b2c_tbl(i).em_imp_xml_element_id,
18224 p_cust_b2c_tbl(i).PERSON_LAST_NAME_PHONETIC,
18225 p_cust_b2c_tbl(i).PERSON_FIRST_NAME_PHONETIC,
18226 p_cust_b2c_tbl(i).URL,
18227 p_cust_b2c_tbl(i).DATE_OF_BIRTH,
18228 p_cust_b2c_tbl(i).PERSON_ACADEMIC_TITLE,
18229 p_cust_b2c_tbl(i).PERSON_PREVIOUS_TITLE_NAME,
18230 p_cust_b2c_tbl(i).PERSON_KNOWN_AS,
18231 p_cust_b2c_tbl(i).PERSON_KNOWN_AS2,
18232 p_cust_b2c_tbl(i).PERSON_KNOWN_AS3,
18233 p_cust_b2c_tbl(i).PERSON_KNOWN_AS4,
18234 p_cust_b2c_tbl(i).PERSON_KNOWN_AS5,
18235 p_cust_b2c_tbl(i).PERSON_NAME_PHONETIC,
18236 p_cust_b2c_tbl(i).MIDDLE_NAME_PHONETIC,
18237 p_cust_b2c_tbl(i).FISCAL_CODE,
18238 p_cust_b2c_tbl(i).PLACE_OF_BIRTH,
18239 p_cust_b2c_tbl(i).DATE_OF_DEATH,
18240 p_cust_b2c_tbl(i).DECLARED_ETHNICITY,
18241 p_cust_b2c_tbl(i).MARITAL_STATUS,
18242 p_cust_b2c_tbl(i).PERSONAL_INCOME,
18243 p_cust_b2c_tbl(i).MARITAL_STATUS_EFFECTIVE_DATE,
18244 p_cust_b2c_tbl(i).HEAD_OF_HOUSEHOLD_FLAG,
18245 p_cust_b2c_tbl(i).HOUSEHOLD_SIZE,
18246 p_cust_b2c_tbl(i).LOCATION_DIRECTIONS,
18247 p_cust_b2c_tbl(i).ADDRESS_EFFECTIVE_DATE,
18248 p_cust_b2c_tbl(i).ADDRESS_EXPIRATION_DATE,
18249 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE1,
18250 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE2,
18251 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE3,
18252 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE4,
18253 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE5,
18254 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE6,
18255 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE7,
18256 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE8,
18257 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE9,
18258 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE10,
18259 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE11,
18260 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE12,
18261 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE13,
18262 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE14,
18263 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE15,
18264 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE1,
18265 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE2,
18266 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE3,
18267 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE4,
18268 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE5,
18269 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE6,
18270 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE7,
18271 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE8,
18272 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE9,
18273 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE10,
18274 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE11,
18275 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE12,
18276 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE13,
18277 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE14,
18278 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE15,
18279 p_cust_b2c_tbl(i).PERSON_ATTRIBUTE_CATEGORY,
18280 p_cust_b2c_tbl(i).ADDRESS_ATTRIBUTE_CATEGORY,
18281 p_cust_b2c_tbl(i).PARTY_SITE_USE,
18282 p_cust_b2c_tbl(i).SHORT_DESCRIPTION,
18283 p_cust_b2c_tbl(i).DESCRIPTION,
18284 p_cust_b2c_tbl(i).VEHICLE_RESPONSE_CODE,
18285 p_cust_b2c_tbl(i).SALES_AGENT_EMAIL_ID,
18286 p_cust_b2c_tbl(i).NOTES,
18287 p_cust_b2c_tbl(i).orig_system_reference,
18288 p_cust_b2c_tbl(i).tax_reference,
18289 p_cust_b2c_tbl(i).rent_owned_indicator
18290 );
18291  END LOOP;
18292 commit;
18293 
18294  exception
18295  WHEN OTHERS THEN
18296     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
18297     FND_MESSAGE.Set_Token('ROW','Error in Create_b2c_src_lines:' || SQLERRM||' '||SQLCODE);
18298     AMS_Utility_PVT.Create_Log (
18299       x_return_status   => x_return_status,
18300       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
18301       p_log_used_by_id  => p_import_list_header_id,
18302       p_msg_data        => FND_MESSAGE.get,
18303       p_msg_type        => 'DEBUG'
18304    );
18305 
18306 end Create_b2c_src_lines;
18307 
18308 --
18309 -- for XML updates the error in the element table
18310 --
18311 PROCEDURE update_element_error (
18312    				 p_import_list_header_id    IN    NUMBER,
18313 				 p_xml_element_id IN NUMBER,
18314                                  p_colName        IN varchar2,
18315                                  p_error_text     IN varchar2) IS
18316 
18317     x_return_status             VARCHAR2(1);
18318     x_msg_data                  VARCHAR2(2000);
18319     l_error_exist               VARCHAR2(1);
18320 cursor c_error_text is
18321 select 'Y' from AMS_IMP_XML_ELEMENTS where IMP_XML_ELEMENT_ID = p_xml_element_id
18322 and error_text like '%'||p_colName||'%';
18323 begin
18324 	open c_error_text;
18325 	fetch c_error_text into l_error_exist;
18326 	close c_error_text;
18327 		if l_error_exist is NULL then
18328 			update AMS_IMP_XML_ELEMENTS
18329 			   set ERROR_TEXT = substr((ERROR_TEXT ||','||p_error_text),1,4000),
18330 	                       LOAD_STATUS = 'ERROR'
18331 			where  imp_xml_element_id = p_xml_element_id;
18332 		end if;
18333  exception
18334  WHEN OTHERS THEN
18335     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
18336     FND_MESSAGE.Set_Token('ROW','Error in update_element_error :' || SQLERRM||' '||SQLCODE);
18337     AMS_Utility_PVT.Create_Log (
18338       x_return_status   => x_return_status,
18339       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
18340       p_log_used_by_id  => p_import_list_header_id,
18341       p_msg_data        => FND_MESSAGE.get,
18342       p_msg_type        => 'DEBUG'
18343    );
18344 
18345 
18346 end update_element_error;
18347 
18348 
18349 --
18350 -- This procedure is used to create party site use
18351 --
18352 
18353 procedure create_party_site_use (
18354         p_psiteuse_rec          IN      hz_party_site_v2pub.party_site_use_rec_type,
18355         x_return_status         OUT NOCOPY     VARCHAR2,
18356         x_msg_count             OUT NOCOPY     NUMBER,
18357         x_msg_data              OUT NOCOPY     VARCHAR2,
18358         x_party_site_use_id     OUT NOCOPY     NUMBER
18359 ) IS
18360 
18361 psiteuse_rec    hz_party_site_v2pub.party_site_use_rec_type := p_psiteuse_rec;
18362 
18363 begin
18364 
18365   psiteuse_rec.CREATED_BY_MODULE        := 'AMS_LIST_IMPORT';
18366   psiteuse_rec.application_id := 530;
18367   hz_party_site_v2pub.create_party_site_use(
18368                 'F',
18369                 psiteuse_rec,
18370                 x_party_site_use_id,
18371                 x_return_status,
18372                 x_msg_count,
18373                 x_msg_data
18374                 );
18375 end create_party_site_use;
18376 -- -------------------------------------------------------
18377 
18378 
18379 --
18380 -- This procedure creates list notes from import
18381 --
18382 --
18383 PROCEDURE create_list_note
18384         (  p_import_list_header_id in number,
18385            p_import_source_line_id in number,
18386            p_party_id             in number,
18387            p_source_object_code   in varchar2,
18388            p_note_text            in varchar2,
18389            x_return_status         OUT NOCOPY    VARCHAR2,
18390            x_msg_count             OUT NOCOPY    NUMBER,
18391            x_msg_data              OUT NOCOPY    VARCHAR2
18392         ) IS
18393 
18394    l_api_version        NUMBER;
18395    l_init_msg_list      VARCHAR2(1);
18396    l_validation_level   NUMBER;
18397    l_commit             VARCHAR2(1);
18398    l_return_status      VARCHAR2(1);
18399    l_msg_count          NUMBER;
18400    l_msg_data           VARCHAR2(2000);
18401    l_jtf_note_id        NUMBER;
18402    l_source_object_id   NUMBER;
18403    l_source_object_code VARCHAR2(8);
18404    l_note_status        VARCHAR2(8);
18405    l_note_type          VARCHAR2(80);
18406    l_notes              VARCHAR2(2000);
18407    l_notes_detail       VARCHAR2(8000);
18408    l_last_update_date   DATE;
18409    l_last_updated_by    NUMBER;
18410    l_creation_date      DATE;
18411    l_created_by         NUMBER;
18412    l_last_update_login  NUMBER;
18413    l_entered_by         NUMBER;
18414    l_entered_date       DATE;
18415    l_note_contexts      JTF_NOTES_PUB.jtf_note_contexts_tbl_type;
18416    l_msg_index          NUMBER;
18417    l_msg_index_out      NUMBER;
18418 
18419    x_tmp_var                       VARCHAR2(4000);
18420    x_tmp_var1                      VARCHAR2(4000);
18421    L_NOTE_CONTEXT_ID    NUMBER;
18422 
18423 begin
18424 
18425   --==============================================================
18426   --      INITIALIZE THE API STATIC VALUES                     ===
18427   --==============================================================
18428    l_api_version        := 1.0;
18429    l_init_msg_list      := FND_API.g_true;
18430    l_validation_level   := FND_API.g_valid_level_full;
18431    l_commit             := FND_API.g_true;
18432    l_msg_count          := 0;
18433    l_source_object_code := nvl(p_source_object_code,'PARTY');
18434    l_note_status        := 'I';
18435    l_note_type          := 'AS_USER';
18436    l_last_update_date   := SYSDATE;
18437    l_last_updated_by    := FND_GLOBAL.user_id; --LEADS_US
18438    l_last_update_login  := FND_GLOBAL.conc_login_id; --LEADS_US
18439    l_jtf_note_id        := null;
18440   --============================================================
18441   --==        SET THE API VARIABLE VALUES                    ===
18442   --============================================================
18443    l_source_object_id   := p_party_id;
18444    l_notes              := p_note_text;
18445    l_notes_detail       := p_note_text;
18446    l_creation_date      := sysdate;
18447    l_created_by         := FND_GLOBAL.user_id; --LEADS_US
18448    l_entered_date       := sysdate;
18449    l_entered_by         := FND_GLOBAL.user_id; --LEADS_US
18450 
18451 
18452     --============================================================
18453     --==           CALL THE API to create a note               ===
18454     --============================================================
18455     jtf_notes_pub.Create_note
18456       (
18457          p_api_version          => l_api_version
18458         ,p_init_msg_list        => l_init_msg_list
18459         ,p_commit               => l_commit
18460         ,p_validation_level     => l_validation_level
18461         ,x_return_status        => x_return_status
18462         ,x_msg_count            => x_msg_count
18463         ,x_msg_data             => x_msg_data
18464         ,p_jtf_note_id          => l_jtf_note_id
18465         ,p_entered_by           => l_entered_by
18466         ,p_entered_date         => l_entered_date
18467         ,p_source_object_id     => l_source_object_id
18468         ,p_source_object_code   => l_source_object_code
18469         ,p_notes                => l_notes
18470         ,p_notes_detail         => l_notes_detail
18471         ,p_note_type            => l_note_type
18472         ,p_note_status          => l_note_status
18473         ,p_jtf_note_contexts_tab => l_note_contexts
18474         ,x_jtf_note_id          => l_jtf_note_id
18475         ,p_last_update_date     => l_last_update_date
18476         ,p_last_updated_by      => l_last_updated_by
18477         ,p_creation_date        => l_creation_date
18478         ,p_created_by           => l_created_by
18479         ,p_last_update_login    => l_last_update_login
18480       );
18481     if x_msg_count > 1 then
18482      FOR i IN 1..x_msg_count  LOOP
18483            x_tmp_var := fnd_msg_pub.get(p_encoded => fnd_api.g_false);
18484            x_tmp_var1 := substrb(x_tmp_var1 || ' '|| x_tmp_var,1,4000);
18485      END LOOP;
18486     END IF;
18487     if x_return_status <> 'S' then
18488                AMS_List_Import_PUB.error_capture (
18489                  1, 'T', 'F', null,
18490                 x_return_status,
18491                 x_msg_count,
18492                 x_msg_data,
18493                 p_import_list_header_id,
18494                 p_import_source_line_id,
18495                 null, null, null,null,
18496                 'Error in create_list_note :' || SQLERRM||' '||SQLCODE);
18497       return;
18498     end if;
18499  exception
18500  WHEN OTHERS THEN
18501     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
18502     FND_MESSAGE.Set_Token('ROW','Error in create_list_note :' || SQLERRM||' '||SQLCODE);
18503     AMS_Utility_PVT.Create_Log (
18504       x_return_status   => l_return_status,
18505       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
18506       p_log_used_by_id  => p_import_list_header_id,
18507       p_msg_data        => FND_MESSAGE.get,
18508       p_msg_type        => 'DEBUG'
18509    );
18510       update ams_imp_source_lines set load_status = 'ERROR'
18511     where import_list_header_id = p_import_list_header_id
18512       and load_status in ('ACTIVE','RELOAD');
18513 
18514                AMS_List_Import_PUB.error_capture (
18515                  1, 'T', 'F', null,
18516                 x_return_status,
18517                 x_msg_count,
18518                 x_msg_data,
18519                 p_import_list_header_id,
18520                 p_import_source_line_id,
18521                 null, null, null,null,
18522                 'Error in create_list_note :' || SQLERRM||' '||SQLCODE);
18523        x_return_status := 'E';
18524 
18525 end create_list_note;
18526 
18527 -- --------------------------------------------------------------------------
18528 --
18529 -- This procedure is used for existence checking for import process
18530 --
18531 --
18532 PROCEDURE org_existence_checking(
18533    p_import_list_header_id IN   NUMBER,
18534    x_return_status            OUT NOCOPY    VARCHAR2,
18535    x_msg_count                OUT NOCOPY    NUMBER,
18536    x_msg_data                 OUT NOCOPY    VARCHAR2
18537                        ) IS
18538 l_limit_rows            number := 1000;
18539 l_last_fetch            BOOLEAN;
18540 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
18541 TYPE ORG_KEY_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.ORG_KEY%TYPE;
18542 TYPE ORG_EXIST_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.ORG_EXIST%TYPE;
18543 TYPE ORG_PARTY_ID_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.ORG_PARTY_ID%TYPE;
18544 TYPE PARTY_NAME_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.COL1%TYPE;
18545 
18546 L_IMPORT_SOURCE_LINE_ID		IMPORT_SOURCE_LINE_ID_LIST;
18547 L_ORG_KEY			ORG_KEY_LIST;
18548 L_ORG_EXIST			ORG_EXIST_LIST;
18549 L_ORG_PARTY_ID			ORG_PARTY_ID_LIST;
18550 L_PARTY_NAME			PARTY_NAME_LIST;
18551 
18552 cursor c_org_key is
18553 select b2b.party_name, 'N',
18554 hz_fuzzy_pub.Generate_Key('ORGANIZATION',b2b.party_name,null,null,null,null,null,null,null) "org_key"
18555 from ams_hz_b2b_mapping_v b2b
18556 where b2b.import_list_header_id = p_import_list_header_id
18557   and b2b.load_status in ('ACTIVE','RELOAD')
18558   and b2b.party_name is not null
18559   and b2b.org_key is null
18560   and b2b.org_party_id is null
18561 group by b2b.party_name;
18562 
18563 
18564 cursor c_customer_exists is
18565       select b2b.org_key, 'Y'
18566 	from ams_hz_b2b_mapping_v b2b
18567        where b2b.import_list_header_id = 40236
18568          --  and nvl(b2b.org_exist,'N') = 'N'
18569 	     and b2b.org_key is not null
18570          and b2b.load_status in ('ACTIVE','RELOAD')
18571          and exists (select 1 from hz_parties pty
18572              where pty.customer_key = b2b.org_key
18573                and pty.party_type   = 'ORGANIZATION'
18574                and pty.status   = 'A')
18575       group by b2b.org_key;
18576 
18577 
18578 cursor c_address_country is
18579         select b2b.import_source_line_id, max(psite.party_id)
18580 	from hz_party_sites psite, hz_locations loc,
18581         hz_parties party, ams_hz_b2b_mapping_v b2b
18582         where b2b.import_list_header_id = p_import_list_header_id
18583           and b2b.load_status in ('ACTIVE','RELOAD')
18584           and b2b.org_exist = 'Y'
18585           and b2b.address1 is not null
18586 	  and b2b.country is not null
18587 	  and b2b.org_party_id is null
18588           and loc.address1      = b2b.address1
18589           and loc.country       = b2b.country
18590           and party.customer_key = b2b.org_key
18591           and party.party_type   = 'ORGANIZATION'
18592 	  and psite.location_id = loc.location_id
18593           and psite.party_id    = party.party_id
18594           and party.status   = 'A'
18595         group by b2b.import_source_line_id;
18596 
18597 cursor c_country is
18598         select b2b.import_source_line_id, max(psite.party_id)
18599         from hz_party_sites psite, hz_locations loc,
18600         hz_parties party, ams_hz_b2b_mapping_v b2b
18601         where b2b.import_list_header_id = p_import_list_header_id
18602           and b2b.load_status in ('ACTIVE','RELOAD')
18603           and b2b.org_exist = 'Y'
18604           and b2b.country is not null
18605 	  and b2b.org_party_id is null
18606           and loc.country       = b2b.country
18607           and party.customer_key = b2b.org_key
18608           and party.party_type   = 'ORGANIZATION'
18609           and psite.location_id = loc.location_id
18610           and psite.party_id    = party.party_id
18611           and party.status   = 'A'
18612         group by b2b.import_source_line_id;
18613 
18614 cursor c_max_party is
18615        select b2b.import_source_line_id, max(pty. party_id)
18616 	from hz_parties pty, ams_hz_b2b_mapping_v b2b
18617        where b2b.import_list_header_id = p_import_list_header_id
18618           and b2b.load_status in ('ACTIVE','RELOAD')
18619           and b2b.org_exist = 'Y'
18620           and b2b.org_party_id is null
18621 	 and customer_key = b2b.org_key
18622          and party_type   = 'ORGANIZATION'
18623          and pty.status   = 'A'
18624         group by b2b.import_source_line_id;
18625 
18626 BEGIN
18627 x_return_status := FND_API.G_RET_STS_SUCCESS;
18628 -- TO POPULATE ORG_KEY
18629 l_last_fetch   := FALSE;
18630 
18631 open c_org_key;
18632 LOOP
18633     fetch c_org_key BULK COLLECT into
18634 	L_PARTY_NAME,
18635 	L_ORG_EXIST,
18636 	L_ORG_KEY LIMIT l_limit_rows;
18637 
18638 	IF c_org_key%NOTFOUND THEN
18639         	l_last_fetch := TRUE;
18640   	END IF;
18641 
18642   	IF L_PARTY_NAME.COUNT = 0 AND l_last_fetch THEN
18643        		 EXIT;
18644   	END IF;
18645     FORALL i IN L_PARTY_NAME.FIRST..L_PARTY_NAME.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18646          SET org_key = L_ORG_KEY(I),
18647 	     org_exist = L_ORG_EXIST(I)
18648     WHERE  party_name = L_PARTY_NAME(i)
18649       and  import_list_header_id = p_import_list_header_id  ;
18650 
18651     if l_last_fetch then
18652       exit;
18653     end if;
18654     commit;
18655 END LOOP;
18656 close c_org_key;
18657 -- TO POPULATE ORG_KEY
18658 
18659 -- TO POPULATE ORG_EXIST
18660 l_last_fetch   := FALSE;
18661 L_IMPORT_SOURCE_LINE_ID := null;
18662 L_ORG_EXIST		:= null;
18663 L_ORG_KEY               := null;
18664 open c_customer_exists;
18665 LOOP
18666     fetch c_customer_exists BULK COLLECT into
18667         L_ORG_KEY,
18668         L_ORG_EXIST LIMIT l_limit_rows;
18669 
18670         IF c_customer_exists%NOTFOUND THEN
18671                 l_last_fetch := TRUE;
18672         END IF;
18673 
18674         IF L_ORG_KEY.COUNT = 0 AND l_last_fetch THEN
18675                  EXIT;
18676         END IF;
18677     FORALL i IN L_ORG_KEY.FIRST..L_ORG_KEY.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18678          SET org_exist = L_ORG_EXIST(I)
18679     WHERE  org_key = L_ORG_KEY(i)
18680       -- and  org_key is null
18681       and  import_list_header_id = p_import_list_header_id  ;
18682 
18683     if l_last_fetch then
18684       exit;
18685     end if;
18686     commit;
18687 END LOOP;
18688 close c_customer_exists;
18689 -- TO POPULATE ORG_EXIST
18690 
18691 
18692 -- TO CHECK WITH ADDRESS AND COUNTRY
18693 l_last_fetch   := FALSE;
18694 L_IMPORT_SOURCE_LINE_ID := null;
18695 open c_address_country;
18696 LOOP
18697     fetch c_address_country BULK COLLECT into
18698         L_IMPORT_SOURCE_LINE_ID,
18699         L_ORG_PARTY_ID LIMIT l_limit_rows;
18700 
18701         IF c_address_country%NOTFOUND THEN
18702                 l_last_fetch := TRUE;
18703         END IF;
18704 
18705         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
18706                  EXIT;
18707         END IF;
18708     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18709          SET org_party_id = L_ORG_PARTY_ID(I)
18710     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
18711 
18712     if l_last_fetch then
18713       exit;
18714     end if;
18715     commit;
18716 END LOOP;
18717 close c_address_country;
18718 -- TO CHECK WITH ADDRESS AND COUNTRY
18719 
18720 
18721 -- TO CHECK WITH  COUNTRY
18722 l_last_fetch   := FALSE;
18723 L_IMPORT_SOURCE_LINE_ID := null;
18724 L_ORG_PARTY_ID		:= null;
18725 open c_country;
18726 LOOP
18727     fetch c_country BULK COLLECT into
18728         L_IMPORT_SOURCE_LINE_ID,
18729         L_ORG_PARTY_ID LIMIT l_limit_rows;
18730 
18731         IF c_country%NOTFOUND THEN
18732                 l_last_fetch := TRUE;
18733         END IF;
18734 
18735         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
18736                  EXIT;
18737         END IF;
18738     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18739          SET org_party_id = L_ORG_PARTY_ID(I)
18740     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
18741 
18742     if l_last_fetch then
18743       exit;
18744     end if;
18745     commit;
18746 END LOOP;
18747 close c_country;
18748 -- TO CHECK WITH COUNTRY
18749 
18750 
18751 -- TO GET THE MAX PARTY_ID
18752 l_last_fetch   := FALSE;
18753 L_IMPORT_SOURCE_LINE_ID := null;
18754 L_ORG_PARTY_ID          := null;
18755 open c_max_party;
18756 LOOP
18757     fetch c_max_party BULK COLLECT into
18758         L_IMPORT_SOURCE_LINE_ID,
18759         L_ORG_PARTY_ID LIMIT l_limit_rows;
18760 
18761         IF c_max_party%NOTFOUND THEN
18762                 l_last_fetch := TRUE;
18763         END IF;
18764 
18765         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
18766                  EXIT;
18767         END IF;
18768     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18769          SET org_party_id = L_ORG_PARTY_ID(I)
18770     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
18771 
18772     if l_last_fetch then
18773       exit;
18774     end if;
18775     commit;
18776 END LOOP;
18777 close c_max_party;
18778 -- TO GET THE MAX PARTY_ID
18779 
18780 EXCEPTION
18781  WHEN OTHERS THEN
18782     x_return_status := FND_API.G_RET_STS_ERROR;
18783     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
18784     FND_MESSAGE.Set_Token('ROW','Error in org_existence_checking :' || SQLERRM||' '||SQLCODE);
18785     AMS_Utility_PVT.Create_Log (
18786       x_return_status   => x_return_status,
18787       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
18788       p_log_used_by_id  => p_import_list_header_id,
18789       p_msg_data        => FND_MESSAGE.get,
18790       p_msg_type        => 'DEBUG'
18791    );
18792 
18793 end org_existence_checking;
18794 
18795 
18796 -- --------------------------------------------------------------------------
18797 --
18798 -- This procedure is used for existence checking for import process with osr
18799 --
18800 --
18801 PROCEDURE org_existence_checking_osr(
18802    p_import_list_header_id IN   NUMBER,
18803    x_return_status            OUT NOCOPY    VARCHAR2,
18804    x_msg_count                OUT NOCOPY    NUMBER,
18805    x_msg_data                 OUT NOCOPY    VARCHAR2
18806                        ) IS
18807 l_limit_rows            number := 1000;
18808 l_last_fetch            BOOLEAN;
18809 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
18810 TYPE ORG_KEY_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.ORG_KEY%TYPE;
18811 TYPE ORG_EXIST_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.ORG_EXIST%TYPE;
18812 TYPE ORG_PARTY_ID_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.ORG_PARTY_ID%TYPE;
18813 TYPE PARTY_NAME_LIST 		IS TABLE OF AMS_IMP_SOURCE_LINES.COL1%TYPE;
18814 
18815 L_IMPORT_SOURCE_LINE_ID		IMPORT_SOURCE_LINE_ID_LIST;
18816 L_ORG_KEY			ORG_KEY_LIST;
18817 L_ORG_EXIST			ORG_EXIST_LIST;
18818 L_ORG_PARTY_ID			ORG_PARTY_ID_LIST;
18819 L_PARTY_NAME			PARTY_NAME_LIST;
18820 
18821 cursor c_org_key is
18822 select b2b.party_name, 'N',
18823 hz_fuzzy_pub.Generate_Key('ORGANIZATION',b2b.party_name,null,null,null,null,null,null,null) "org_key"
18824 from ams_hz_b2b_mapping_v b2b
18825 where b2b.import_list_header_id = p_import_list_header_id
18826   and b2b.load_status in ('ACTIVE','RELOAD')
18827   and b2b.party_name is not null
18828   and b2b.org_key is null
18829   and b2b.org_party_id is null
18830 
18831 group by b2b.party_name;
18832 
18833 
18834 cursor c_customer_exists is
18835        select b2b.org_key, 'Y'
18836 	from hz_parties pty, ams_hz_b2b_mapping_v b2b
18837        where b2b.import_list_header_id = p_import_list_header_id
18838          and pty.customer_key = b2b.org_key
18839 	 and b2b.org_key is not null
18840          and b2b.org_party_id is null
18841 	 and b2b.load_status in ('ACTIVE','RELOAD')
18842          and pty.party_type   = 'ORGANIZATION'
18843 	 and pty.orig_system_reference = b2b.orig_system_reference
18844          and pty.status = 'A'
18845       group by b2b.org_key,b2b.orig_system_reference;
18846 
18847 
18848 cursor c_address_country is
18849         select b2b.import_source_line_id, max(psite.party_id)
18850 	from hz_party_sites psite, hz_locations loc,
18851         hz_parties party, ams_hz_b2b_mapping_v b2b
18852         where b2b.import_list_header_id = p_import_list_header_id
18853           and b2b.load_status in ('ACTIVE','RELOAD')
18854           and b2b.org_exist = 'Y'
18855           and b2b.address1 is not null
18856 	  and b2b.country is not null
18857   	  and b2b.org_party_id is null
18858           and loc.address1      = b2b.address1
18859           and loc.country       = b2b.country
18860           and party.customer_key = b2b.org_key
18861           and party.party_type   = 'ORGANIZATION'
18862 	  and psite.location_id = loc.location_id
18863           and psite.party_id    = party.party_id
18864 	  and party.orig_system_reference = b2b.orig_system_reference
18865          and party.status = 'A'
18866         group by b2b.import_source_line_id;
18867 
18868 cursor c_country is
18869         select b2b.import_source_line_id, max(psite.party_id)
18870         from hz_party_sites psite, hz_locations loc,
18871         hz_parties party, ams_hz_b2b_mapping_v b2b
18872         where b2b.import_list_header_id = p_import_list_header_id
18873           and b2b.load_status in ('ACTIVE','RELOAD')
18874           and b2b.org_exist = 'Y'
18875           and b2b.country is not null
18876 	  and b2b.org_party_id is null
18877           and loc.country       = b2b.country
18878           and party.customer_key = b2b.org_key
18879           and party.party_type   = 'ORGANIZATION'
18880           and psite.location_id = loc.location_id
18881           and psite.party_id    = party.party_id
18882 	  and party.orig_system_reference = b2b.orig_system_reference
18883          and party.status = 'A'
18884         group by b2b.import_source_line_id;
18885 
18886 cursor c_max_party is
18887        select b2b.import_source_line_id, max(pty. party_id)
18888 	from hz_parties pty, ams_hz_b2b_mapping_v b2b
18889        where b2b.import_list_header_id = p_import_list_header_id
18890           and b2b.load_status in ('ACTIVE','RELOAD')
18891           and b2b.org_exist = 'Y'
18892           and b2b.org_party_id is null
18893 	 and customer_key = b2b.org_key
18894          and party_type   = 'ORGANIZATION'
18895 	 and pty.orig_system_reference = b2b.orig_system_reference
18896          and pty.status = 'A'
18897         group by b2b.import_source_line_id;
18898 
18899 BEGIN
18900 x_return_status := FND_API.G_RET_STS_SUCCESS;
18901 -- TO POPULATE ORG_KEY
18902 l_last_fetch   := FALSE;
18903 open c_org_key;
18904 LOOP
18905     fetch c_org_key BULK COLLECT into
18906 	L_PARTY_NAME,
18907 	L_ORG_EXIST,
18908 	L_ORG_KEY LIMIT l_limit_rows;
18909 
18910 	IF c_org_key%NOTFOUND THEN
18911         	l_last_fetch := TRUE;
18912   	END IF;
18913 
18914   	IF L_PARTY_NAME.COUNT = 0 AND l_last_fetch THEN
18915        		 EXIT;
18916   	END IF;
18917     FORALL i IN L_PARTY_NAME.FIRST..L_PARTY_NAME.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18918          SET org_key = L_ORG_KEY(I),
18919 	     org_exist = L_ORG_EXIST(I)
18920     WHERE  party_name = L_PARTY_NAME(i)
18921       and  import_list_header_id = p_import_list_header_id  ;
18922 
18923     if l_last_fetch then
18924       exit;
18925     end if;
18926     commit;
18927 END LOOP;
18928 close c_org_key;
18929 -- TO POPULATE ORG_KEY
18930 
18931 -- TO POPULATE ORG_EXIST
18932 l_last_fetch   := FALSE;
18933 L_IMPORT_SOURCE_LINE_ID := null;
18934 L_ORG_EXIST		:= null;
18935 L_ORG_KEY               := null;
18936 open c_customer_exists;
18937 LOOP
18938     fetch c_customer_exists BULK COLLECT into
18939         L_ORG_KEY,
18940         L_ORG_EXIST LIMIT l_limit_rows;
18941 
18942         IF c_customer_exists%NOTFOUND THEN
18943                 l_last_fetch := TRUE;
18944         END IF;
18945 
18946         IF L_ORG_KEY.COUNT = 0 AND l_last_fetch THEN
18947                  EXIT;
18948         END IF;
18949     FORALL i IN L_ORG_KEY.FIRST..L_ORG_KEY.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18950          SET org_exist = L_ORG_EXIST(I)
18951     WHERE  org_key = L_ORG_KEY(i)
18952       and  org_key is null
18953       and  import_list_header_id = p_import_list_header_id  ;
18954 
18955     if l_last_fetch then
18956       exit;
18957     end if;
18958     commit;
18959 END LOOP;
18960 close c_customer_exists;
18961 -- TO POPULATE ORG_EXIST
18962 
18963 
18964 -- TO CHECK WITH ADDRESS AND COUNTRY
18965 l_last_fetch   := FALSE;
18966 L_IMPORT_SOURCE_LINE_ID := null;
18967 open c_address_country;
18968 LOOP
18969     fetch c_address_country BULK COLLECT into
18970         L_IMPORT_SOURCE_LINE_ID,
18971         L_ORG_PARTY_ID LIMIT l_limit_rows;
18972 
18973         IF c_address_country%NOTFOUND THEN
18974                 l_last_fetch := TRUE;
18975         END IF;
18976 
18977         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
18978                  EXIT;
18979         END IF;
18980     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
18981          SET org_party_id = L_ORG_PARTY_ID(I)
18982     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
18983 
18984     if l_last_fetch then
18985       exit;
18986     end if;
18987     commit;
18988 END LOOP;
18989 close c_address_country;
18990 -- TO CHECK WITH ADDRESS AND COUNTRY
18991 
18992 
18993 -- TO CHECK WITH  COUNTRY
18994 l_last_fetch   := FALSE;
18995 L_IMPORT_SOURCE_LINE_ID := null;
18996 L_ORG_PARTY_ID		:= null;
18997 open c_country;
18998 LOOP
18999     fetch c_country BULK COLLECT into
19000         L_IMPORT_SOURCE_LINE_ID,
19001         L_ORG_PARTY_ID LIMIT l_limit_rows;
19002 
19003         IF c_country%NOTFOUND THEN
19004                 l_last_fetch := TRUE;
19005         END IF;
19006 
19007         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19008                  EXIT;
19009         END IF;
19010     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19011          SET org_party_id = L_ORG_PARTY_ID(I)
19012     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19013 
19014     if l_last_fetch then
19015       exit;
19016     end if;
19017     commit;
19018 END LOOP;
19019 close c_country;
19020 -- TO CHECK WITH COUNTRY
19021 
19022 
19023 -- TO GET THE MAX PARTY_ID
19024 l_last_fetch   := FALSE;
19025 L_IMPORT_SOURCE_LINE_ID := null;
19026 L_ORG_PARTY_ID          := null;
19027 open c_max_party;
19028 LOOP
19029     fetch c_max_party BULK COLLECT into
19030         L_IMPORT_SOURCE_LINE_ID,
19031         L_ORG_PARTY_ID LIMIT l_limit_rows;
19032 
19033         IF c_max_party%NOTFOUND THEN
19034                 l_last_fetch := TRUE;
19035         END IF;
19036 
19037         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19038                  EXIT;
19039         END IF;
19040     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19041          SET org_party_id = L_ORG_PARTY_ID(I)
19042     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19043 
19044     if l_last_fetch then
19045       exit;
19046     end if;
19047     commit;
19048 END LOOP;
19049 close c_max_party;
19050 -- TO GET THE MAX PARTY_ID
19051 
19052 EXCEPTION
19053  WHEN OTHERS THEN
19054     x_return_status := FND_API.G_RET_STS_ERROR;
19055     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
19056     FND_MESSAGE.Set_Token('ROW','Error in org_existence_checking_osr :' || SQLERRM||' '||SQLCODE);
19057     AMS_Utility_PVT.Create_Log (
19058       x_return_status   => x_return_status,
19059       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
19060       p_log_used_by_id  => p_import_list_header_id,
19061       p_msg_data        => FND_MESSAGE.get,
19062       p_msg_type        => 'DEBUG'
19063    );
19064 
19065 end org_existence_checking_osr;
19066 
19067 -- ------------------------------------------------------
19068 --
19069 -- This procedure is used for existence checking for Person
19070 --
19071 --
19072 PROCEDURE per_existence_checking(
19073    p_import_list_header_id IN   NUMBER,
19074    x_return_status            OUT NOCOPY    VARCHAR2,
19075    x_msg_count                OUT NOCOPY    NUMBER,
19076    x_msg_data                 OUT NOCOPY    VARCHAR2
19077                        ) IS
19078 l_limit_rows            number := 1000;
19079 l_last_fetch            BOOLEAN;
19080 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
19081 TYPE person_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.person_KEY%TYPE;
19082 TYPE person_EXIST_LIST             IS TABLE OF AMS_IMP_SOURCE_LINES.person_EXIST%TYPE;
19083 TYPE person_PARTY_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.person_PARTY_ID%TYPE;
19084 
19085 TYPE person_email_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.col1%TYPE;
19086 TYPE person_phone_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.col1%TYPE;
19087 TYPE person_address1_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.col1%TYPE;
19088 TYPE person_country_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.col1%TYPE;
19089 TYPE person_status_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.load_status%TYPE;
19090 
19091 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
19092 L_person_KEY                       person_KEY_LIST;
19093 L_person_EXIST                     person_EXIST_LIST;
19094 L_person_PARTY_ID                  person_PARTY_ID_LIST;
19095 
19096 L_person_email                     person_email_LIST;
19097 L_person_phone                  person_phone_LIST;
19098 L_person_address1                  person_address1_LIST;
19099 L_person_country                  person_country_LIST;
19100 L_person_status                         person_status_LIST;
19101 
19102 cursor c_per_key is
19103 select b2c.import_source_line_id, 'N',
19104 hz_fuzzy_pub.Generate_Key('PERSON',null,null,null,null,null,null,b2c.PERSON_FIRST_NAME,b2c.PERSON_LAST_NAME) "per_key"
19105 from ams_hz_b2c_mapping_v b2c
19106 where b2c.import_list_header_id = p_import_list_header_id
19107   and b2c.load_status in ('ACTIVE','RELOAD')
19108   and b2c.PERSON_FIRST_NAME is not null
19109   and b2c.PERSON_LAST_NAME is not null
19110   and b2c.PERSON_PARTY_ID is null;
19111 
19112 cursor c_person_exists is
19113        select distinct b2c.import_source_line_id, 'Y'
19114         from hz_parties pty, ams_hz_b2c_mapping_v b2c
19115        where b2c.import_list_header_id = p_import_list_header_id
19116          and pty.customer_key = b2c.person_key
19117          and b2c.person_key is not null
19118 	 and b2c.PERSON_PARTY_ID is null
19119          and b2c.load_status in ('ACTIVE','RELOAD')
19120          and pty.status = 'A'
19121          and pty.party_type   = 'PERSON';
19122 
19123 cursor c_email_address is
19124         select b2c.import_source_line_id, max(p.party_id)
19125           from hz_contact_points cp, hz_parties p, ams_hz_b2c_mapping_v b2c
19126         where b2c.import_list_header_id = p_import_list_header_id
19127           and b2c.load_status in ('ACTIVE','RELOAD')
19128           and b2c.person_exist = 'Y'
19129           and b2c.email_address is not null
19130 	  and b2c.PERSON_PARTY_ID is null
19131           and p.customer_key = b2c.person_key
19132           and p.party_type = 'PERSON'
19133          and p.status = 'A'
19134           and cp.owner_table_id = p.party_id
19135           and cp.owner_table_name = 'HZ_PARTIES'
19136           and upper(cp.email_address) = upper(b2c.email_address)
19137           --and cp.primary_flag = 'Y' -- Hbandi Commented for fixing the bug #8726177 (list import creates new party when imported phone number does not match primary)
19138         group by b2c.import_source_line_id;
19139 
19140 cursor c_ph_number is
19141         select b2c.import_source_line_id, max(p.party_id)
19142           from hz_contact_points cp, hz_parties p, ams_hz_b2c_mapping_v b2c
19143         where b2c.import_list_header_id = p_import_list_header_id
19144           and b2c.load_status in ('ACTIVE','RELOAD')
19145           and b2c.person_exist = 'Y'
19146           and b2c.phone_number is not null
19147           and b2c.person_party_id is null
19148 	  and p.customer_key = b2c.person_key
19149           and p.party_type = 'PERSON'
19150          and p.status = 'A'
19151           and cp.owner_table_id = p.party_id
19152           and cp.owner_table_name = 'HZ_PARTIES'
19153          -- and cp.primary_flag = 'Y' -- Hbandi Commented for fixing the bug #8726177 (list import creates new party when imported phone number does not match primary)
19154           and cp.transposed_phone_number = b2c.transposed_phone_number
19155          -- and cp.phone_number = b2c.phone_number
19156          -- and nvl(cp.phone_country_code,nvl(b2c.phone_country_code,'x')) = nvl(b2c.phone_country_code,'x')
19157          -- and nvl(cp.phone_area_code,nvl(b2c.phone_area_code,'x')) = nvl(b2c.phone_area_code,'x')
19158         group by b2c.import_source_line_id;
19159 
19160 cursor c_address_country is
19161         select b2c.import_source_line_id, max(psite.party_id)
19162 	  from hz_party_sites psite, hz_locations loc, hz_parties party, ams_hz_b2c_mapping_v b2c
19163          where b2c.import_list_header_id = p_import_list_header_id
19164           and b2c.load_status in ('ACTIVE','RELOAD')
19165           and b2c.person_exist = 'Y'
19166           and b2c.address1 is not null
19167           and b2c.country is not null
19168           and b2c.person_party_id is null
19169 	  and psite.location_id = loc.location_id
19170           and loc.address1      = b2c.address1
19171           and loc.country       = b2c.country
19172           and party.customer_key = b2c.person_key
19173           and party.party_type = 'PERSON'
19174          and party.status = 'A'
19175           and psite.party_id      = party.party_id
19176         group by b2c.import_source_line_id;
19177 
19178 cursor c_per_dedup is
19179        select max(import_source_line_id),person_key,email_address,transposed_phone_number,address1,
19180               country, 'DUPLICATE' status
19181          from ams_hz_b2c_mapping_v
19182         where import_list_header_id = p_import_list_header_id
19183           and load_status in ('ACTIVE','RELOAD')
19184           group by person_key,email_address,transposed_phone_number,address1,country;
19185 
19186 begin
19187 x_return_status := FND_API.G_RET_STS_SUCCESS;
19188 -- TO POPULATE person_KEY
19189 l_last_fetch   := FALSE;
19190 
19191 open c_per_key;
19192 LOOP
19193     fetch c_per_key BULK COLLECT into
19194         L_IMPORT_SOURCE_LINE_ID,
19195         L_person_EXIST,
19196         L_person_KEY LIMIT l_limit_rows;
19197 
19198         IF c_per_key%NOTFOUND THEN
19199                 l_last_fetch := TRUE;
19200         END IF;
19201 
19202         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19203 	   EXIT;
19204         END IF;
19205 
19206         FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST
19207          UPDATE AMS_HZ_B2C_MAPPING_V
19208            SET person_key = L_person_KEY(I),
19209                person_exist = L_person_EXIST(I)
19210          WHERE IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19211 
19212     if l_last_fetch then
19213       exit;
19214     end if;
19215     commit;
19216 END LOOP;
19217 close c_per_key;
19218 -- TO POPULATE person_KEY
19219 
19220 -- TO POPULATE person_EXIST
19221 l_last_fetch   := FALSE;
19222 L_IMPORT_SOURCE_LINE_ID := null;
19223 L_person_EXIST             := null;
19224 open c_person_exists;
19225 LOOP
19226     fetch c_person_exists BULK COLLECT into
19227         L_IMPORT_SOURCE_LINE_ID,
19228         L_person_EXIST LIMIT l_limit_rows;
19229 
19230         IF c_person_exists%NOTFOUND THEN
19231                 l_last_fetch := TRUE;
19232         END IF;
19233 
19234         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19235                  EXIT;
19236         END IF;
19237     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19238          SET person_exist = L_person_EXIST(I)
19239     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19240 
19241     if l_last_fetch then
19242       exit;
19243     end if;
19244     commit;
19245 END LOOP;
19246 close c_person_exists;
19247 -- TO POPULATE person_EXIST
19248 
19249 -- TO CHECK WITH email_address
19250 l_last_fetch   := FALSE;
19251 L_IMPORT_SOURCE_LINE_ID := null;
19252 open c_email_address;
19253 LOOP
19254     fetch c_email_address BULK COLLECT into
19255         L_IMPORT_SOURCE_LINE_ID,
19256         L_person_PARTY_ID LIMIT l_limit_rows;
19257 
19258         IF c_email_address%NOTFOUND THEN
19259                 l_last_fetch := TRUE;
19260         END IF;
19261 
19262         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19263                  EXIT;
19264         END IF;
19265     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19266          SET person_party_id = L_person_PARTY_ID(I)
19267     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19268 
19269     if l_last_fetch then
19270       exit;
19271     end if;
19272     commit;
19273 END LOOP;
19274 close c_email_address;
19275 -- TO CHECK WITH email_address
19276 
19277 -- TO CHECK WITH phone number
19278 l_last_fetch   := FALSE;
19279 L_IMPORT_SOURCE_LINE_ID := null;
19280 L_person_PARTY_ID	:= null;
19281 open c_ph_number;
19282 LOOP
19283     fetch c_ph_number BULK COLLECT into
19284         L_IMPORT_SOURCE_LINE_ID,
19285         L_person_PARTY_ID LIMIT l_limit_rows;
19286 
19287         IF c_ph_number%NOTFOUND THEN
19288                 l_last_fetch := TRUE;
19289         END IF;
19290 
19291         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19292                  EXIT;
19293         END IF;
19294     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19295          SET person_party_id = L_person_PARTY_ID(I)
19296     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19297 
19298     if l_last_fetch then
19299       exit;
19300     end if;
19301     commit;
19302 END LOOP;
19303 close c_ph_number;
19304 -- TO CHECK WITH phone_number
19305 
19306 -- TO CHECK WITH address and country
19307 l_last_fetch   := FALSE;
19308 L_IMPORT_SOURCE_LINE_ID := null;
19309 L_person_PARTY_ID       := null;
19310 open c_address_country;
19311 LOOP
19312     fetch c_address_country BULK COLLECT into
19313         L_IMPORT_SOURCE_LINE_ID,
19314         L_person_PARTY_ID LIMIT l_limit_rows;
19315 
19316         IF c_address_country%NOTFOUND THEN
19317                 l_last_fetch := TRUE;
19318         END IF;
19319 
19320         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19321                  EXIT;
19322         END IF;
19323     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19324          SET person_party_id = L_person_PARTY_ID(I)
19325     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19326 
19327     if l_last_fetch then
19328       exit;
19329     end if;
19330     commit;
19331 END LOOP;
19332 close c_address_country;
19333 -- TO CHECK WITH address and country
19334 
19335 -- TO CHECK WITH dedup
19336 l_last_fetch   := FALSE;
19337 L_IMPORT_SOURCE_LINE_ID := null;
19338 L_person_KEY           := null;
19339 L_person_email                := null;
19340 L_person_phone               := null;
19341 L_person_address1            := null;
19342 L_person_country            := null;
19343 L_person_status              := null;
19344 
19345 open c_per_dedup;
19346 LOOP
19347     fetch c_per_dedup BULK COLLECT into
19348         L_IMPORT_SOURCE_LINE_ID,L_person_KEY,L_person_email,L_person_phone,L_person_address1,
19349         L_person_country, L_person_status  LIMIT l_limit_rows;
19350 
19351         IF c_per_dedup%NOTFOUND THEN
19352                 l_last_fetch := TRUE;
19353         END IF;
19354 
19355         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19356                  EXIT;
19357         END IF;
19358     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19359          SET load_status = L_person_status(i)
19360     WHERE import_list_header_id = p_import_list_header_id
19361       and IMPORT_SOURCE_LINE_ID < L_IMPORT_SOURCE_LINE_ID(i)
19362       and load_status in ('ACTIVE','RELOAD')
19363       and person_key = L_person_KEY(i)
19364       and email_address = L_person_email(i)
19365       and transposed_phone_number = L_person_phone(i)
19366       and address1 = L_person_address1(i)
19367       and country = L_person_country(i);
19368 
19369 
19370     if l_last_fetch then
19371       exit;
19372     end if;
19373     commit;
19374 END LOOP;
19375 close c_per_dedup;
19376 -- TO CHECK WITH dedup
19377 
19378 EXCEPTION
19379  WHEN OTHERS THEN
19380     x_return_status := FND_API.G_RET_STS_ERROR;
19381     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
19382     FND_MESSAGE.Set_Token('ROW','Error in per_existence_checking :' || SQLERRM||' '||SQLCODE);
19383     AMS_Utility_PVT.Create_Log (
19384       x_return_status   => x_return_status,
19385       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
19386       p_log_used_by_id  => p_import_list_header_id,
19387       p_msg_data        => FND_MESSAGE.get,
19388       p_msg_type        => 'DEBUG'
19389    );
19390 
19391 end per_existence_checking;
19392 
19393 
19394 -- ------------------------------------------------------
19395 --
19396 -- This procedure is used for existence checking for Person with osr
19397 --
19398 --
19399 PROCEDURE per_existence_checking_osr(
19400    p_import_list_header_id IN   NUMBER,
19401    x_return_status            OUT NOCOPY    VARCHAR2,
19402    x_msg_count                OUT NOCOPY    NUMBER,
19403    x_msg_data                 OUT NOCOPY    VARCHAR2
19404                        ) IS
19405 l_limit_rows            number := 1000;
19406 l_last_fetch            BOOLEAN;
19407 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
19408 TYPE person_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.person_KEY%TYPE;
19409 TYPE person_EXIST_LIST             IS TABLE OF AMS_IMP_SOURCE_LINES.person_EXIST%TYPE;
19410 TYPE person_PARTY_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.person_PARTY_ID%TYPE;
19411 
19412 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
19413 L_person_KEY                       person_KEY_LIST;
19414 L_person_EXIST                     person_EXIST_LIST;
19415 L_person_PARTY_ID                  person_PARTY_ID_LIST;
19416 
19417 cursor c_per_key is
19418 select b2c.import_source_line_id, 'N',
19419 hz_fuzzy_pub.Generate_Key('PERSON',null,null,null,null,null,null,b2c.PERSON_FIRST_NAME,b2c.PERSON_LAST_NAME) "per_key"
19420 from ams_hz_b2c_mapping_v b2c
19421 where b2c.import_list_header_id = p_import_list_header_id
19422   and b2c.load_status in ('ACTIVE','RELOAD')
19423   and b2c.PERSON_FIRST_NAME is not null
19424   and b2c.PERSON_LAST_NAME is not null;
19425 
19426 cursor c_person_exists is
19427       select b2c.import_source_line_id, 'Y'
19428         from ams_hz_b2c_mapping_v b2c
19429        where b2c.import_list_header_id = p_import_list_header_id
19430          and b2c.person_key is not null
19431          and b2c.PERSON_PARTY_ID is null
19432          and b2c.load_status in ('ACTIVE','RELOAD')
19433          and exists (select 1 from hz_parties pty
19434              where pty.customer_key = b2c.person_key
19435                and pty.status = 'A'
19436                and pty.party_type   = 'PERSON');
19437 
19438 cursor c_email_address is
19439         select b2c.import_source_line_id, max(p.party_id)
19440           from hz_contact_points cp, hz_parties p, ams_hz_b2c_mapping_v b2c
19441         where b2c.import_list_header_id = p_import_list_header_id
19442           and b2c.load_status in ('ACTIVE','RELOAD')
19443           and b2c.person_exist = 'Y'
19444 	  and b2c.orig_system_reference = p.orig_system_reference
19445           and b2c.email_address is not null
19446           and p.customer_key = b2c.person_key
19447           and p.party_type = 'PERSON'
19448          and p.status = 'A'
19449           and cp.owner_table_id = p.party_id
19450           and cp.owner_table_name = 'HZ_PARTIES'
19451           and upper(cp.email_address) = upper(b2c.email_address)
19452           and cp.primary_flag = 'Y'
19453         group by b2c.import_source_line_id;
19454 
19455 cursor c_ph_number is
19456         select b2c.import_source_line_id, max(p.party_id)
19457           from hz_contact_points cp, hz_parties p, ams_hz_b2c_mapping_v b2c
19458         where b2c.import_list_header_id = p_import_list_header_id
19459           and b2c.load_status in ('ACTIVE','RELOAD')
19460           and b2c.person_exist = 'Y'
19461           and b2c.phone_number is not null
19462           and b2c.person_party_id is null
19463 	  and b2c.orig_system_reference = p.orig_system_reference
19464 	  and p.customer_key = b2c.person_key
19465           and p.party_type = 'PERSON'
19466          and p.status = 'A'
19467           and cp.owner_table_id = p.party_id
19468           and cp.owner_table_name = 'HZ_PARTIES'
19469           and cp.primary_flag = 'Y'
19470           and cp.transposed_phone_number = b2c.transposed_phone_number
19471           -- and cp.phone_number = b2c.phone_number
19472           -- and nvl(cp.phone_country_code,nvl(b2c.phone_country_code,'x')) = nvl(b2c.phone_country_code,'x')
19473           -- and nvl(cp.phone_area_code,nvl(b2c.phone_area_code,'x')) = nvl(b2c.phone_area_code,'x')
19474         group by b2c.import_source_line_id;
19475 
19476 cursor c_address_country is
19477         select b2c.import_source_line_id, max(psite.party_id)
19478 	  from hz_party_sites psite, hz_locations loc, hz_parties party, ams_hz_b2c_mapping_v b2c
19479          where b2c.import_list_header_id = p_import_list_header_id
19480           and b2c.load_status in ('ACTIVE','RELOAD')
19481           and b2c.person_exist = 'Y'
19482           and b2c.address1 is not null
19483           and b2c.country is not null
19484           and b2c.person_party_id is null
19485 	  and psite.location_id = loc.location_id
19486           and loc.address1      = b2c.address1
19487           and loc.country       = b2c.country
19488           and party.customer_key = b2c.person_key
19489           and party.party_type = 'PERSON'
19490          and party.status = 'A'
19491           and psite.party_id      = party.party_id
19492 	  and b2c.orig_system_reference = party.orig_system_reference
19493         group by b2c.import_source_line_id;
19494 
19495 begin
19496 x_return_status := FND_API.G_RET_STS_SUCCESS;
19497 -- TO POPULATE person_KEY
19498 l_last_fetch   := FALSE;
19499 open c_per_key;
19500 LOOP
19501     fetch c_per_key BULK COLLECT into
19502         L_IMPORT_SOURCE_LINE_ID,
19503         L_person_EXIST,
19504         L_person_KEY LIMIT l_limit_rows;
19505 
19506         IF c_per_key%NOTFOUND THEN
19507                 l_last_fetch := TRUE;
19508         END IF;
19509 
19510         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19511                  EXIT;
19512         END IF;
19513     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19514          SET person_key = L_person_KEY(I),
19515              person_exist = L_person_EXIST(I)
19516     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19517 
19518     if l_last_fetch then
19519       exit;
19520     end if;
19521     commit;
19522 END LOOP;
19523 close c_per_key;
19524 -- TO POPULATE person_KEY
19525 
19526 -- TO POPULATE person_EXIST
19527 l_last_fetch   := FALSE;
19528 L_IMPORT_SOURCE_LINE_ID := null;
19529 L_person_EXIST             := null;
19530 open c_person_exists;
19531 LOOP
19532     fetch c_person_exists BULK COLLECT into
19533         L_IMPORT_SOURCE_LINE_ID,
19534         L_person_EXIST LIMIT l_limit_rows;
19535 
19536         IF c_person_exists%NOTFOUND THEN
19537                 l_last_fetch := TRUE;
19538         END IF;
19539 
19540         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19541                  EXIT;
19542         END IF;
19543     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19544          SET person_exist = L_person_EXIST(I)
19545     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19546 
19547     if l_last_fetch then
19548       exit;
19549     end if;
19550     commit;
19551 END LOOP;
19552 close c_person_exists;
19553 -- TO POPULATE person_EXIST
19554 
19555 -- TO CHECK WITH email_address
19556 l_last_fetch   := FALSE;
19557 L_IMPORT_SOURCE_LINE_ID := null;
19558 open c_email_address;
19559 LOOP
19560     fetch c_email_address BULK COLLECT into
19561         L_IMPORT_SOURCE_LINE_ID,
19562         L_person_PARTY_ID LIMIT l_limit_rows;
19563 
19564         IF c_email_address%NOTFOUND THEN
19565                 l_last_fetch := TRUE;
19566         END IF;
19567 
19568         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19569                  EXIT;
19570         END IF;
19571     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19572          SET person_party_id = L_person_PARTY_ID(I)
19573     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19574 
19575     if l_last_fetch then
19576       exit;
19577     end if;
19578     commit;
19579 END LOOP;
19580 close c_email_address;
19581 -- TO CHECK WITH email_address
19582 
19583 -- TO CHECK WITH phone number
19584 l_last_fetch   := FALSE;
19585 L_IMPORT_SOURCE_LINE_ID := null;
19586 L_person_PARTY_ID	:= null;
19587 open c_ph_number;
19588 LOOP
19589     fetch c_ph_number BULK COLLECT into
19590         L_IMPORT_SOURCE_LINE_ID,
19591         L_person_PARTY_ID LIMIT l_limit_rows;
19592 
19593         IF c_ph_number%NOTFOUND THEN
19594                 l_last_fetch := TRUE;
19595         END IF;
19596 
19597         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19598                  EXIT;
19599         END IF;
19600     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19601          SET person_party_id = L_person_PARTY_ID(I)
19602     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19603 
19604     if l_last_fetch then
19605       exit;
19606     end if;
19607     commit;
19608 END LOOP;
19609 close c_ph_number;
19610 -- TO CHECK WITH phone_number
19611 
19612 -- TO CHECK WITH address and country
19613 l_last_fetch   := FALSE;
19614 L_IMPORT_SOURCE_LINE_ID := null;
19615 L_person_PARTY_ID       := null;
19616 open c_address_country;
19617 LOOP
19618     fetch c_address_country BULK COLLECT into
19619         L_IMPORT_SOURCE_LINE_ID,
19620         L_person_PARTY_ID LIMIT l_limit_rows;
19621 
19622         IF c_address_country%NOTFOUND THEN
19623                 l_last_fetch := TRUE;
19624         END IF;
19625 
19626         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19627                  EXIT;
19628         END IF;
19629     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
19630          SET person_party_id = L_person_PARTY_ID(I)
19631     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19632 
19633     if l_last_fetch then
19634       exit;
19635     end if;
19636     commit;
19637 END LOOP;
19638 close c_address_country;
19639 -- TO CHECK WITH address and country
19640 EXCEPTION
19641  WHEN OTHERS THEN
19642     x_return_status := FND_API.G_RET_STS_ERROR;
19643     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
19644     FND_MESSAGE.Set_Token('ROW','Error in per_existence_checking_osr :' || SQLERRM||' '||SQLCODE);
19645     AMS_Utility_PVT.Create_Log (
19646       x_return_status   => x_return_status,
19647       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
19648       p_log_used_by_id  => p_import_list_header_id,
19649       p_msg_data        => FND_MESSAGE.get,
19650       p_msg_type        => 'DEBUG'
19651    );
19652 
19653 end per_existence_checking_osr;
19654 
19655 -- -------------------------------------------------------
19656 --
19657 -- This procedure is used for existence checking for organization contacts
19658 --
19659 --
19660 PROCEDURE org_cont_existence_checking(
19661    p_import_list_header_id IN  NUMBER,
19662    x_return_status            OUT NOCOPY    VARCHAR2,
19663    x_msg_count                OUT NOCOPY    NUMBER,
19664    x_msg_data                 OUT NOCOPY    VARCHAR2
19665                        ) IS
19666 l_limit_rows            number := 1000;
19667 l_last_fetch            BOOLEAN;
19668 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
19669 TYPE person_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.person_KEY%TYPE;
19670 TYPE ocont_EXIST_LIST             IS TABLE OF AMS_IMP_SOURCE_LINES.ocont_EXIST%TYPE;
19671 TYPE ocont_PARTY_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.ocont_PARTY_ID%TYPE;
19672 TYPE ocont_org_key_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.org_key%TYPE;
19673 TYPE ocont_person_key_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.person_key%TYPE;
19674 TYPE ocont_email_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.col1%TYPE;
19675 TYPE ocont_phnumb_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.transposed_phone_number%TYPE;
19676 TYPE ocont_status_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.col1%TYPE;
19677 
19678 
19679 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
19680 L_person_KEY                       person_KEY_LIST;
19681 L_ocont_EXIST                     ocont_EXIST_LIST;
19682 L_ocont_PARTY_ID                  ocont_PARTY_ID_LIST;
19683 
19684 L_ocont_status                  ocont_status_LIST;
19685 
19686 
19687 L_ocont_org_key                  ocont_org_key_LIST;
19688 L_ocont_person_key               ocont_person_key_LIST;
19689 L_ocont_email                    ocont_email_LIST;
19690 L_ocont_phnumb                   ocont_phnumb_LIST;
19691 
19692 cursor c_per_key is
19693 select b2b.import_source_line_id, 'N',
19694 hz_fuzzy_pub.Generate_Key('PERSON',null,null,null,null,null,null,b2b.PERSON_FIRST_NAME,b2b.PERSON_LAST_NAME)
19695 "per_key"
19696 from ams_hz_b2b_mapping_v b2b
19697 where b2b.import_list_header_id = p_import_list_header_id
19698   and b2b.load_status in ('ACTIVE','RELOAD')
19699   and b2b.PERSON_FIRST_NAME is not null
19700   and b2b.PERSON_LAST_NAME is not null
19701 --  and b2b.org_party_id is not null
19702   and b2b.OCONT_PARTY_ID is null;
19703 
19704 cursor c_person_exists is
19705 SELECT b2b.import_source_line_id, 'Y'
19706   from ams_hz_b2b_mapping_v b2b
19707  where b2b.import_list_header_id = p_import_list_header_id
19708   and b2b.person_key is not null
19709   and b2b.load_status in ('ACTIVE','RELOAD')
19710   and b2b.OCONT_PARTY_ID is null
19711   and exists
19712     ( select null
19713         from hz_parties pty
19714         where pty.customer_key = b2b.person_key
19715           and pty.party_type  = 'PERSON'
19716           and pty.status = 'A' );
19717 /*
19718        select b2b.import_source_line_id, 'Y'
19719         from hz_parties pty, ams_hz_b2b_mapping_v b2b
19720        where b2b.import_list_header_id = p_import_list_header_id
19721          and pty.customer_key = b2b.person_key
19722          and b2b.person_key is not null
19723          and b2b.load_status in ('ACTIVE','RELOAD')
19724          and pty.party_type   = 'PERSON'
19725          and pty.status = 'A'
19726  --        and b2b.org_party_id is not null
19727 	 and b2b.OCONT_PARTY_ID is null;
19728 */
19729 cursor c_cont_email_phone is
19730        select b2b.import_source_line_id, max(per.party_id) from
19731        hz_parties org,
19732        hz_parties per,
19733        hz_relationships rel,
19734        hz_contact_points cpoint,
19735        hz_contact_points cpoint1,
19736        ams_hz_b2b_mapping_v b2b
19737        where b2b.import_list_header_id = p_import_list_header_id
19738           and b2b.load_status in ('ACTIVE','RELOAD')
19739           and b2b.ocont_exist = 'Y'
19740           and b2b.phone_number is not null
19741           and b2b.email_address is not null
19742           and b2b.org_party_id is not null
19743 	  and b2b.OCONT_PARTY_ID is null
19744          and org.party_id           = b2b.org_party_id
19745          and org.party_type         = 'ORGANIZATION'
19746          and rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
19747          and rel.SUBJECT_TYPE       = 'PERSON'
19748          and rel.OBJECT_TABLE_NAME  = 'HZ_PARTIES'
19749          and rel.RELATIONSHIP_CODE  = 'CONTACT_OF'
19750          and rel.OBJECT_ID          = org.party_id
19751          and rel.SUBJECT_ID         = per.PARTY_ID
19752          and per.customer_key       = b2b.person_key
19753          and per.status = 'A'
19754          and org.status = 'A'
19755          and cpoint.owner_table_id  = rel.party_id
19756          and cpoint.owner_table_name = 'HZ_PARTIES'
19757          and cpoint.contact_point_type = 'EMAIL'
19758          and upper(cpoint.email_address)    = upper(b2b.email_address)
19759          and cpoint.status           = 'A'
19760          and cpoint1.owner_table_id  = rel.party_id
19761          and cpoint1.owner_table_name = 'HZ_PARTIES'
19762          and cpoint1.contact_point_type = 'PHONE'
19763          and cpoint1.transposed_phone_number = b2b.transposed_phone_number
19764          -- and cpoint1.phone_area_code||'-'||cpoint1.phone_number||'-'||cpoint1.phone_extension  =
19765          --   b2b.phone_area_code||'-'||b2b.phone_number||'-'||b2b.phone_extention
19766          and (cpoint1.phone_line_type<>'FAX' or cpoint1.phone_line_type is null)
19767          and cpoint1.status           = 'A'
19768 	group by b2b.import_source_line_id;
19769 
19770 cursor c_cont_email is
19771        select b2b.import_source_line_id,max(per.party_id) from
19772        hz_parties org,
19773        hz_parties per,
19774        hz_relationships rel,
19775        hz_contact_points cpoint,
19776        ams_hz_b2b_mapping_v b2b
19777        where b2b.import_list_header_id = p_import_list_header_id
19778           and b2b.load_status in ('ACTIVE','RELOAD')
19779           and b2b.ocont_exist = 'Y'
19780           and b2b.email_address is not null
19781           and b2b.org_party_id is not null
19782           and b2b.ocont_party_id is null
19783 	  and b2b.OCONT_PARTY_ID is null
19784          and org.party_id           = b2b.org_party_id
19785          and org.party_type         = 'ORGANIZATION'
19786          and rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
19787          and rel.SUBJECT_TYPE       = 'PERSON'
19788          and rel.OBJECT_TABLE_NAME  = 'HZ_PARTIES'
19789          and rel.RELATIONSHIP_CODE  = 'CONTACT_OF'
19790          and rel.OBJECT_ID          = org.party_id
19791          and rel.SUBJECT_ID         = per.PARTY_ID
19792          and per.customer_key       = b2b.person_key
19793          and per.status = 'A'
19794          and org.status = 'A'
19795          and cpoint.owner_table_id  = rel.party_id
19796          and cpoint.owner_table_name = 'HZ_PARTIES'
19797          and cpoint.contact_point_type = 'EMAIL'
19798          and upper(cpoint.email_address)    = upper(b2b.email_address)
19799          and cpoint.status           = 'A'
19800 	group by b2b.import_source_line_id;
19801 
19802 cursor c_cont_phone is
19803        select b2b.import_source_line_id,max(per.party_id) from
19804        hz_parties org,
19805        hz_parties per,
19806        hz_relationships rel,
19807        hz_contact_points cpoint,
19808        ams_hz_b2b_mapping_v b2b
19809        where b2b.import_list_header_id = p_import_list_header_id
19810           and b2b.load_status in ('ACTIVE','RELOAD')
19811           and b2b.ocont_exist = 'Y'
19812           and b2b.phone_number is not null
19813           and b2b.org_party_id is not null
19814           and b2b.ocont_party_id is null
19815 	  and b2b.OCONT_PARTY_ID is null
19816          and org.party_id           = b2b.org_party_id
19817          and org.party_type         = 'ORGANIZATION'
19818          and rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
19819          and rel.SUBJECT_TYPE       = 'PERSON'
19820          and rel.OBJECT_TABLE_NAME  = 'HZ_PARTIES'
19821          and rel.RELATIONSHIP_CODE  = 'CONTACT_OF'
19822          and rel.OBJECT_ID          = org.party_id
19823          and rel.SUBJECT_ID         = per.PARTY_ID
19824          and per.customer_key       = b2b.person_key
19825           and per.status = 'A'
19826          and org.status = 'A'
19827          and cpoint.owner_table_id  = rel.party_id
19828          and cpoint.owner_table_name = 'HZ_PARTIES'
19829          and cpoint.contact_point_type = 'PHONE'
19830          and cpoint.transposed_phone_number = b2b.transposed_phone_number
19831         -- and cpoint.phone_area_code||'-'||cpoint.phone_number||'-'||cpoint.phone_extension  =
19832          --    b2b.phone_area_code||'-'||b2b.phone_number||'-'||b2b.phone_extention
19833          and (cpoint.phone_line_type<>'FAX' or cpoint.phone_line_type is null)
19834          and cpoint.status           = 'A'
19835 	group by b2b.import_source_line_id;
19836 
19837 cursor c_cont_dedup is
19838        select max(import_source_line_id), org_key,person_key,email_address,transposed_phone_number ,
19839               'DUPLICATE' status
19840          from ams_hz_b2b_mapping_v
19841         where import_list_header_id = p_import_list_header_id
19842          -- and ocont_party_id is null
19843           and load_status in ('ACTIVE','RELOAD')
19844           group by org_key,person_key,email_address,transposed_phone_number;
19845 
19846 begin
19847 x_return_status := FND_API.G_RET_STS_SUCCESS;
19848 -- TO POPULATE person_KEY
19849 l_last_fetch   := FALSE;
19850 open c_per_key;
19851 LOOP
19852     fetch c_per_key BULK COLLECT into
19853         L_IMPORT_SOURCE_LINE_ID,
19854         L_ocont_EXIST,
19855         L_person_KEY LIMIT l_limit_rows;
19856 
19857         IF c_per_key%NOTFOUND THEN
19858                 l_last_fetch := TRUE;
19859         END IF;
19860 
19861         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19862                  EXIT;
19863         END IF;
19864     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19865          SET person_key = L_person_KEY(I),
19866              ocont_exist = L_ocont_EXIST(I)
19867     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19868 
19869     if l_last_fetch then
19870       exit;
19871     end if;
19872     commit;
19873 END LOOP;
19874 close c_per_key;
19875 -- TO POPULATE person_KEY
19876 
19877 -- TO POPULATE person_EXIST
19878 l_last_fetch   := FALSE;
19879 L_IMPORT_SOURCE_LINE_ID := null;
19880 L_ocont_EXIST             := null;
19881 open c_person_exists;
19882 LOOP
19883     fetch c_person_exists BULK COLLECT into
19884         L_IMPORT_SOURCE_LINE_ID,
19885         L_ocont_EXIST LIMIT l_limit_rows;
19886 
19887         IF c_person_exists%NOTFOUND THEN
19888                 l_last_fetch := TRUE;
19889         END IF;
19890 
19891         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19892                  EXIT;
19893         END IF;
19894     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19895          SET ocont_exist = L_ocont_EXIST(I)
19896     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19897 
19898     if l_last_fetch then
19899       exit;
19900     end if;
19901     commit;
19902 END LOOP;
19903 close c_person_exists;
19904 -- TO POPULATE person_EXIST
19905 
19906 -- TO CHECK WITH email_address and phone
19907 l_last_fetch   := FALSE;
19908 L_IMPORT_SOURCE_LINE_ID := null;
19909 open c_cont_email_phone;
19910 LOOP
19911     fetch c_cont_email_phone BULK COLLECT into
19912         L_IMPORT_SOURCE_LINE_ID,
19913         L_ocont_PARTY_ID LIMIT l_limit_rows;
19914 
19915         IF c_cont_email_phone%NOTFOUND THEN
19916                 l_last_fetch := TRUE;
19917         END IF;
19918 
19919         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19920                  EXIT;
19921         END IF;
19922     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19923          SET ocont_party_id = L_ocont_PARTY_ID(I)
19924     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19925 
19926     if l_last_fetch then
19927       exit;
19928     end if;
19929     commit;
19930 END LOOP;
19931 close c_cont_email_phone;
19932 -- TO CHECK WITH email_address and phone
19933 
19934 -- TO CHECK WITH email_address
19935 l_last_fetch   := FALSE;
19936 L_IMPORT_SOURCE_LINE_ID := null;
19937 L_ocont_PARTY_ID	:= null;
19938 open c_cont_email;
19939 LOOP
19940     fetch c_cont_email BULK COLLECT into
19941         L_IMPORT_SOURCE_LINE_ID,
19942         L_ocont_PARTY_ID LIMIT l_limit_rows;
19943 
19944         IF c_cont_email%NOTFOUND THEN
19945                 l_last_fetch := TRUE;
19946         END IF;
19947 
19948         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19949                  EXIT;
19950         END IF;
19951     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19952          SET ocont_party_id = L_ocont_PARTY_ID(I)
19953     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19954 
19955     if l_last_fetch then
19956       exit;
19957     end if;
19958     commit;
19959 END LOOP;
19960 close c_cont_email;
19961 -- TO CHECK WITH email_address
19962 
19963 -- TO CHECK WITH phone
19964 l_last_fetch   := FALSE;
19965 L_IMPORT_SOURCE_LINE_ID := null;
19966 L_ocont_PARTY_ID        := null;
19967 open c_cont_phone;
19968 LOOP
19969     fetch c_cont_phone BULK COLLECT into
19970         L_IMPORT_SOURCE_LINE_ID,
19971         L_ocont_PARTY_ID LIMIT l_limit_rows;
19972 
19973         IF c_cont_phone%NOTFOUND THEN
19974                 l_last_fetch := TRUE;
19975         END IF;
19976 
19977         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
19978                  EXIT;
19979         END IF;
19980     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
19981          SET ocont_party_id = L_ocont_PARTY_ID(I)
19982     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
19983 
19984     if l_last_fetch then
19985       exit;
19986     end if;
19987     commit;
19988 END LOOP;
19989 close c_cont_phone;
19990 -- TO CHECK WITH phone
19991 
19992 -- TO CHECK WITH dedup
19993 l_last_fetch   := FALSE;
19994 L_IMPORT_SOURCE_LINE_ID := null;
19995 L_ocont_org_key      := null;
19996 L_ocont_person_key    := null;
19997 L_ocont_email          := null;
19998 L_ocont_phnumb         := null;
19999 L_ocont_status        := null;
20000 open c_cont_dedup;
20001 LOOP
20002     fetch c_cont_dedup BULK COLLECT into
20003         L_IMPORT_SOURCE_LINE_ID,L_ocont_org_key,L_ocont_person_key,L_ocont_email,
20004         L_ocont_phnumb,L_ocont_status LIMIT l_limit_rows;
20005 
20006         IF c_cont_dedup%NOTFOUND THEN
20007                 l_last_fetch := TRUE;
20008         END IF;
20009 
20010         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20011                  EXIT;
20012         END IF;
20013     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20014          SET load_status = L_ocont_status(i)
20015     WHERE import_list_header_id = p_import_list_header_id
20016       and IMPORT_SOURCE_LINE_ID < L_IMPORT_SOURCE_LINE_ID(i)
20017       and load_status in ('ACTIVE','RELOAD')
20018       and org_key = L_ocont_org_key(i)
20019       and person_key = L_ocont_person_key(i)
20020       and email_address = L_ocont_email(i)
20021       and transposed_phone_number = L_ocont_phnumb(i);
20022 
20023     if l_last_fetch then
20024       exit;
20025     end if;
20026     commit;
20027 END LOOP;
20028 close c_cont_dedup;
20029 -- TO CHECK WITH dedup
20030 
20031 EXCEPTION
20032  WHEN OTHERS THEN
20033     x_return_status := FND_API.G_RET_STS_ERROR;
20034     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
20035     FND_MESSAGE.Set_Token('ROW','Error in org_cont_existence_checking :' || SQLERRM||' '||SQLCODE);
20036     AMS_Utility_PVT.Create_Log (
20037       x_return_status   => x_return_status,
20038       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
20039       p_log_used_by_id  => p_import_list_header_id,
20040       p_msg_data        => FND_MESSAGE.get,
20041       p_msg_type        => 'DEBUG'
20042    );
20043 
20044 end org_cont_existence_checking;
20045 
20046 
20047 -- -------------------------------------------------------
20048 --
20049 -- This procedure is used for existence checking for organization contacts with osr
20050 --
20051 --
20052 PROCEDURE org_cont_existence_chk_osr(
20053    p_import_list_header_id IN  NUMBER,
20054    x_return_status            OUT NOCOPY    VARCHAR2,
20055    x_msg_count                OUT NOCOPY    NUMBER,
20056    x_msg_data                 OUT NOCOPY    VARCHAR2
20057                        ) IS
20058 l_limit_rows            number := 1000;
20059 l_last_fetch            BOOLEAN;
20060 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
20061 TYPE person_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.person_KEY%TYPE;
20062 TYPE ocont_EXIST_LIST             IS TABLE OF AMS_IMP_SOURCE_LINES.ocont_EXIST%TYPE;
20063 TYPE ocont_PARTY_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.ocont_PARTY_ID%TYPE;
20064 
20065 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
20066 L_person_KEY                       person_KEY_LIST;
20067 L_ocont_EXIST                     ocont_EXIST_LIST;
20068 L_ocont_PARTY_ID                  ocont_PARTY_ID_LIST;
20069 
20070 cursor c_per_key is
20071 select b2b.import_source_line_id, 'N',
20072 hz_fuzzy_pub.Generate_Key('PERSON',null,null,null,null,null,null,b2b.PERSON_FIRST_NAME,b2b.PERSON_LAST_NAME)
20073 "per_key"
20074 from ams_hz_b2b_mapping_v b2b
20075 where b2b.import_list_header_id = p_import_list_header_id
20076   and b2b.load_status in ('ACTIVE','RELOAD')
20077   and b2b.PERSON_FIRST_NAME is not null
20078   and b2b.PERSON_LAST_NAME is not null
20079   and b2b.org_party_id is not null;
20080 
20081 cursor c_person_exists is
20082        select b2b.import_source_line_id, 'Y'
20083         from hz_parties pty, ams_hz_b2b_mapping_v b2b
20084        where b2b.import_list_header_id = p_import_list_header_id
20085          and pty.customer_key = b2b.person_key
20086          and b2b.person_key is not null
20087          and b2b.load_status in ('ACTIVE','RELOAD')
20088          and pty.party_type   = 'PERSON'
20089          and pty.status = 'A'
20090 	 and pty.orig_system_reference = b2b.orig_system_reference
20091          and b2b.org_party_id is not null;
20092 
20093 cursor c_cont_email_phone is
20094        select b2b.import_source_line_id, max(per.party_id) from
20095        hz_parties org,
20096        hz_parties per,
20097        hz_relationships rel,
20098        hz_contact_points cpoint,
20099        hz_contact_points cpoint1,
20100        ams_hz_b2b_mapping_v b2b
20101        where b2b.import_list_header_id = p_import_list_header_id
20102           and b2b.load_status in ('ACTIVE','RELOAD')
20103           and b2b.ocont_exist = 'Y'
20104           and b2b.phone_number is not null
20105           and b2b.email_address is not null
20106           and b2b.org_party_id is not null
20107          and org.party_id           = b2b.org_party_id
20108 	 and org.orig_system_reference = b2b.orig_system_reference
20109          and org.party_type         = 'ORGANIZATION'
20110          and rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
20111          and rel.SUBJECT_TYPE       = 'PERSON'
20112          and rel.OBJECT_TABLE_NAME  = 'HZ_PARTIES'
20113          and rel.RELATIONSHIP_CODE  = 'CONTACT_OF'
20114          and rel.OBJECT_ID          = org.party_id
20115          and rel.SUBJECT_ID         = per.PARTY_ID
20116          and per.customer_key       = b2b.person_key
20117          and per.status = 'A'
20118          and org.status = 'A'
20119          and cpoint.owner_table_id  = rel.party_id
20120          and cpoint.owner_table_name = 'HZ_PARTIES'
20121          and cpoint.contact_point_type = 'EMAIL'
20122          and upper(cpoint.email_address)    = upper(b2b.email_address)
20123          and cpoint.status           = 'A'
20124          and cpoint1.owner_table_id  = rel.party_id
20125          and cpoint1.owner_table_name = 'HZ_PARTIES'
20126          and cpoint1.contact_point_type = 'PHONE'
20127          and cpoint1.transposed_phone_number = b2b.transposed_phone_number
20128          -- and cpoint1.phone_area_code||'-'||cpoint1.phone_number||'-'||cpoint1.phone_extension  =
20129          --    b2b.phone_area_code||'-'||b2b.phone_number||'-'||b2b.phone_extention
20130          and (cpoint1.phone_line_type<>'FAX' or cpoint1.phone_line_type is null)
20131          and cpoint1.status           = 'A'
20132 	group by b2b.import_source_line_id;
20133 
20134 cursor c_cont_email is
20135        select b2b.import_source_line_id,max(per.party_id) from
20136        hz_parties org,
20137        hz_parties per,
20138        hz_relationships rel,
20139        hz_contact_points cpoint,
20140        ams_hz_b2b_mapping_v b2b
20141        where b2b.import_list_header_id = p_import_list_header_id
20142           and b2b.load_status in ('ACTIVE','RELOAD')
20143           and b2b.ocont_exist = 'Y'
20144           and b2b.email_address is not null
20145           and b2b.org_party_id is not null
20146           and b2b.ocont_party_id is null
20147          and org.party_id           = b2b.org_party_id
20148 	 and org.orig_system_reference = b2b.orig_system_reference
20149          and org.party_type         = 'ORGANIZATION'
20150          and rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
20151          and rel.SUBJECT_TYPE       = 'PERSON'
20152          and rel.OBJECT_TABLE_NAME  = 'HZ_PARTIES'
20153          and rel.RELATIONSHIP_CODE  = 'CONTACT_OF'
20154          and rel.OBJECT_ID          = org.party_id
20155          and rel.SUBJECT_ID         = per.PARTY_ID
20156          and per.customer_key       = b2b.person_key
20157          and per.status = 'A'
20158          and org.status = 'A'
20159          and cpoint.owner_table_id  = rel.party_id
20160          and cpoint.owner_table_name = 'HZ_PARTIES'
20161          and cpoint.contact_point_type = 'EMAIL'
20162          and upper(cpoint.email_address)    = upper(b2b.email_address)
20163          and cpoint.status           = 'A'
20164 	group by b2b.import_source_line_id;
20165 
20166 cursor c_cont_phone is
20167        select b2b.import_source_line_id,max(per.party_id) from
20168        hz_parties org,
20169        hz_parties per,
20170        hz_relationships rel,
20171        hz_contact_points cpoint,
20172        ams_hz_b2b_mapping_v b2b
20173        where b2b.import_list_header_id = p_import_list_header_id
20174           and b2b.load_status in ('ACTIVE','RELOAD')
20175           and b2b.ocont_exist = 'Y'
20176           and b2b.phone_number is not null
20177           and b2b.org_party_id is not null
20178           and b2b.ocont_party_id is null
20179          and org.party_id           = b2b.org_party_id
20180 	 and org.orig_system_reference = b2b.orig_system_reference
20181          and org.party_type         = 'ORGANIZATION'
20182          and rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
20183          and rel.SUBJECT_TYPE       = 'PERSON'
20184          and rel.OBJECT_TABLE_NAME  = 'HZ_PARTIES'
20185          and rel.RELATIONSHIP_CODE  = 'CONTACT_OF'
20186          and rel.OBJECT_ID          = org.party_id
20187          and rel.SUBJECT_ID         = per.PARTY_ID
20188          and per.customer_key       = b2b.person_key
20189          and per.status = 'A'
20190          and org.status = 'A'
20191          and cpoint.owner_table_id  = rel.party_id
20192          and cpoint.owner_table_name = 'HZ_PARTIES'
20193          and cpoint.contact_point_type = 'PHONE'
20194          and cpoint.transposed_phone_number = b2b.transposed_phone_number
20195          -- and cpoint.phone_area_code||'-'||cpoint.phone_number||'-'||cpoint.phone_extension  =
20196          --    b2b.phone_area_code||'-'||b2b.phone_number||'-'||b2b.phone_extention
20197          and (cpoint.phone_line_type<>'FAX' or cpoint.phone_line_type is null)
20198          and cpoint.status           = 'A'
20199 	group by b2b.import_source_line_id;
20200 
20201 begin
20202 x_return_status := FND_API.G_RET_STS_SUCCESS;
20203 -- TO POPULATE person_KEY
20204 l_last_fetch   := FALSE;
20205 open c_per_key;
20206 LOOP
20207     fetch c_per_key BULK COLLECT into
20208         L_IMPORT_SOURCE_LINE_ID,
20209         L_ocont_EXIST,
20210         L_person_KEY LIMIT l_limit_rows;
20211 
20212         IF c_per_key%NOTFOUND THEN
20213                 l_last_fetch := TRUE;
20214         END IF;
20215 
20216         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20217                  EXIT;
20218         END IF;
20219     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20220          SET person_key = L_person_KEY(I),
20221              ocont_exist = L_ocont_EXIST(I)
20222     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20223 
20224     if l_last_fetch then
20225       exit;
20226     end if;
20227     commit;
20228 END LOOP;
20229 close c_per_key;
20230 -- TO POPULATE person_KEY
20231 
20232 -- TO POPULATE person_EXIST
20233 l_last_fetch   := FALSE;
20234 L_IMPORT_SOURCE_LINE_ID := null;
20235 L_ocont_EXIST             := null;
20236 open c_person_exists;
20237 LOOP
20238     fetch c_person_exists BULK COLLECT into
20239         L_IMPORT_SOURCE_LINE_ID,
20240         L_ocont_EXIST LIMIT l_limit_rows;
20241 
20242         IF c_person_exists%NOTFOUND THEN
20243                 l_last_fetch := TRUE;
20244         END IF;
20245 
20246         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20247                  EXIT;
20248         END IF;
20249     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20250          SET ocont_exist = L_ocont_EXIST(I)
20251     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20252 
20253     if l_last_fetch then
20254       exit;
20255     end if;
20256     commit;
20257 END LOOP;
20258 close c_person_exists;
20259 -- TO POPULATE person_EXIST
20260 
20261 -- TO CHECK WITH email_address and phone
20262 l_last_fetch   := FALSE;
20263 L_IMPORT_SOURCE_LINE_ID := null;
20264 open c_cont_email_phone;
20265 LOOP
20266     fetch c_cont_email_phone BULK COLLECT into
20267         L_IMPORT_SOURCE_LINE_ID,
20268         L_ocont_PARTY_ID LIMIT l_limit_rows;
20269 
20270         IF c_cont_email_phone%NOTFOUND THEN
20271                 l_last_fetch := TRUE;
20272         END IF;
20273 
20274         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20275                  EXIT;
20276         END IF;
20277     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20278          SET ocont_party_id = L_ocont_PARTY_ID(I)
20279     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20280 
20281     if l_last_fetch then
20282       exit;
20283     end if;
20284     commit;
20285 END LOOP;
20286 close c_cont_email_phone;
20287 -- TO CHECK WITH email_address and phone
20288 
20289 -- TO CHECK WITH email_address
20290 l_last_fetch   := FALSE;
20291 L_IMPORT_SOURCE_LINE_ID := null;
20292 L_ocont_PARTY_ID	:= null;
20293 open c_cont_email;
20294 LOOP
20295     fetch c_cont_email BULK COLLECT into
20296         L_IMPORT_SOURCE_LINE_ID,
20297         L_ocont_PARTY_ID LIMIT l_limit_rows;
20298 
20299         IF c_cont_email%NOTFOUND THEN
20300                 l_last_fetch := TRUE;
20301         END IF;
20302 
20303         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20304                  EXIT;
20305         END IF;
20306     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20307          SET ocont_party_id = L_ocont_PARTY_ID(I)
20308     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20309 
20310     if l_last_fetch then
20311       exit;
20312     end if;
20313     commit;
20314 END LOOP;
20315 close c_cont_email;
20316 -- TO CHECK WITH email_address
20317 
20318 -- TO CHECK WITH phone
20319 l_last_fetch   := FALSE;
20320 L_IMPORT_SOURCE_LINE_ID := null;
20321 L_ocont_PARTY_ID        := null;
20322 open c_cont_phone;
20323 LOOP
20324     fetch c_cont_phone BULK COLLECT into
20325         L_IMPORT_SOURCE_LINE_ID,
20326         L_ocont_PARTY_ID LIMIT l_limit_rows;
20327 
20328         IF c_cont_phone%NOTFOUND THEN
20329                 l_last_fetch := TRUE;
20330         END IF;
20331 
20332         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20333                  EXIT;
20334         END IF;
20335     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20336          SET ocont_party_id = L_ocont_PARTY_ID(I)
20337     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20338 
20339     if l_last_fetch then
20340       exit;
20341     end if;
20342     commit;
20343 END LOOP;
20344 close c_cont_phone;
20345 -- TO CHECK WITH phone
20346 
20347 EXCEPTION
20348  WHEN OTHERS THEN
20349     x_return_status := FND_API.G_RET_STS_ERROR;
20350     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
20351     FND_MESSAGE.Set_Token('ROW','Error in org_cont_existence_chk_osr :' || SQLERRM||' '||SQLCODE);
20352     AMS_Utility_PVT.Create_Log (
20353       x_return_status   => x_return_status,
20354       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
20355       p_log_used_by_id  => p_import_list_header_id,
20356       p_msg_data        => FND_MESSAGE.get,
20357       p_msg_type        => 'DEBUG'
20358    );
20359 
20360 end org_cont_existence_chk_osr;
20361 
20362 -- -------------------------------------------------------------------
20363 -- This procedure is used for existence checking for organization address
20364 --
20365 --
20366 PROCEDURE org_address_existence_checking(
20367    p_import_list_header_id IN   NUMBER,
20368    x_return_status            OUT NOCOPY    VARCHAR2,
20369    x_msg_count                OUT NOCOPY    NUMBER,
20370    x_msg_data                 OUT NOCOPY    VARCHAR2
20371                        ) is
20372 l_limit_rows            number := 1000;
20373 l_last_fetch            BOOLEAN;
20374 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
20375 TYPE address_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.address_KEY%TYPE;
20376 TYPE PARTY_location_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.PARTY_location_ID%TYPE;
20377 
20378 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
20379 L_address_KEY                       address_KEY_LIST;
20380 L_PARTY_location_ID                  PARTY_location_ID_LIST;
20381 
20382 cursor c_addr_key is
20383 select b2b.import_source_line_id,
20384 hz_fuzzy_pub.Generate_Key('ADDRESS',null,b2b.address1,b2b.address2,b2b.address3,b2b.address4,b2b.postal_code,null,null)
20385 "add_key"
20386 from ams_hz_b2b_mapping_v b2b
20387 where b2b.import_list_header_id = p_import_list_header_id
20388   and b2b.load_status in ('ACTIVE','RELOAD')
20389   and b2b.address1 is not null;
20390 
20391 cursor c_addr_ps is
20392        select b2b.import_source_line_id,max(loc.location_id)
20393        from  hz_party_sites ps, hz_locations loc,ams_hz_b2b_mapping_v b2b
20394 	where b2b.import_list_header_id = p_import_list_header_id
20395   	and b2b.load_status in ('ACTIVE','RELOAD')
20396   	and b2b.address_key is not null
20397         and b2b.org_party_id is not null
20398         and ps.party_id          = b2b.org_party_id
20399          and ps.location_id       = loc.location_id
20400          and loc.address_key      = b2b.address_key
20401          and loc.country          = b2b.country
20402          and nvl(loc.city,nvl(b2b.city,'x')) = nvl(b2b.city,'x')
20403 	group by b2b.import_source_line_id;
20404 
20405 cursor c_addr is
20406        select b2b.import_source_line_id,max(loc.location_id)
20407        from   hz_locations loc,ams_hz_b2b_mapping_v b2b
20408         where b2b.import_list_header_id = p_import_list_header_id
20409         and b2b.load_status in ('ACTIVE','RELOAD')
20410         and b2b.address_key is not null
20411         and b2b.party_location_id is null
20412         and loc.address_key     = b2b.address_key
20413          and loc.country          = b2b.country
20414          and nvl(loc.city,nvl(b2b.city,'x')) = nvl(b2b.city,'x')
20415 	group by b2b.import_source_line_id;
20416 
20417 begin
20418 x_return_status := FND_API.G_RET_STS_SUCCESS;
20419 -- TO POPULATE address_KEY
20420 l_last_fetch   := FALSE;
20421 open c_addr_key;
20422 LOOP
20423     fetch c_addr_key BULK COLLECT into
20424         L_IMPORT_SOURCE_LINE_ID,
20425         L_address_KEY LIMIT l_limit_rows;
20426 
20427         IF c_addr_key%NOTFOUND THEN
20428                 l_last_fetch := TRUE;
20429         END IF;
20430 
20431         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20432                  EXIT;
20433         END IF;
20434     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20435          SET address_key = L_address_KEY(I)
20436     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20437 
20438     if l_last_fetch then
20439       exit;
20440     end if;
20441     commit;
20442 END LOOP;
20443 close c_addr_key;
20444 -- TO POPULATE address_KEY
20445 
20446 -- TO CHECK WITH address with ps
20447 l_last_fetch   := FALSE;
20448 L_IMPORT_SOURCE_LINE_ID := null;
20449 open c_addr_ps;
20450 LOOP
20451     fetch c_addr_ps BULK COLLECT into
20452         L_IMPORT_SOURCE_LINE_ID,
20453         L_PARTY_location_ID LIMIT l_limit_rows;
20454 
20455         IF c_addr_ps%NOTFOUND THEN
20456                 l_last_fetch := TRUE;
20457         END IF;
20458 
20459         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20460                  EXIT;
20461         END IF;
20462     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20463          SET party_location_id = L_PARTY_location_ID(I)
20464     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20465 
20466     if l_last_fetch then
20467       exit;
20468     end if;
20469     commit;
20470 END LOOP;
20471 close c_addr_ps;
20472 -- TO CHECK WITH address ps
20473 
20474 -- TO CHECK WITH address
20475 l_last_fetch   := FALSE;
20476 L_IMPORT_SOURCE_LINE_ID := null;
20477 L_PARTY_location_ID := null;
20478 open c_addr;
20479 LOOP
20480     fetch c_addr BULK COLLECT into
20481         L_IMPORT_SOURCE_LINE_ID,
20482         L_PARTY_location_ID LIMIT l_limit_rows;
20483 
20484         IF c_addr%NOTFOUND THEN
20485                 l_last_fetch := TRUE;
20486         END IF;
20487 
20488         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20489                  EXIT;
20490         END IF;
20491     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20492          SET party_location_id = L_PARTY_location_ID(I)
20493     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20494 
20495     if l_last_fetch then
20496       exit;
20497     end if;
20498     commit;
20499 END LOOP;
20500 close c_addr;
20501 -- TO CHECK WITH address
20502 
20503 EXCEPTION
20504  WHEN OTHERS THEN
20505     x_return_status := FND_API.G_RET_STS_ERROR;
20506     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
20507     FND_MESSAGE.Set_Token('ROW','Error in org_address_existence_checking :' || SQLERRM||' '||SQLCODE);
20508     AMS_Utility_PVT.Create_Log (
20509       x_return_status   => x_return_status,
20510       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
20511       p_log_used_by_id  => p_import_list_header_id,
20512       p_msg_data        => FND_MESSAGE.get,
20513       p_msg_type        => 'DEBUG'
20514    );
20515 
20516 end org_address_existence_checking;
20517 
20518 
20519 
20520 -- -------------------------------------------------------------------
20521 -- This procedure is used for existence checking for organization address
20522 --
20523 --
20524 PROCEDURE org_address1_exist_checking(
20525    p_import_list_header_id IN   NUMBER,
20526    x_return_status            OUT NOCOPY    VARCHAR2,
20527    x_msg_count                OUT NOCOPY    NUMBER,
20528    x_msg_data                 OUT NOCOPY    VARCHAR2
20529                        ) is
20530 l_limit_rows            number := 1000;
20531 l_last_fetch            BOOLEAN;
20532 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
20533 TYPE address_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.org_address_KEY%TYPE;
20534 TYPE PARTY_location_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.org_location_ID%TYPE;
20535 
20536 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
20537 L_org_address_KEY                       address_KEY_LIST;
20538 L_org_location_ID                  party_location_ID_LIST;
20539 
20540 cursor c_addr_key is
20541 select b2b.import_source_line_id,
20542 hz_fuzzy_pub.Generate_Key('ADDRESS',null,b2b.org_address1,b2b.org_address2,b2b.org_address3,b2b.org_address4,b2b.org_postal_code,null,null)
20543 "add_key"
20544 from ams_hz_b2b_mapping_v b2b
20545 where b2b.import_list_header_id = p_import_list_header_id
20546   and b2b.load_status in ('ACTIVE','RELOAD')
20547   and b2b.org_address1 is not null;
20548 
20549 cursor c_addr_ps is
20550        select b2b.import_source_line_id,max(loc.location_id)
20551        from  hz_party_sites ps, hz_locations loc,ams_hz_b2b_mapping_v b2b
20552 	where b2b.import_list_header_id = p_import_list_header_id
20553   	and b2b.load_status in ('ACTIVE','RELOAD')
20554   	and b2b.org_address_key is not null
20555         and b2b.org_party_id is not null
20556         and ps.party_id          = b2b.org_party_id
20557          and ps.location_id       = loc.location_id
20558          and loc.address_key      = b2b.org_address_key
20559          and loc.country          = b2b.org_country
20560          and nvl(loc.city,nvl(b2b.org_city,'x')) = nvl(b2b.org_city,'x')
20561 	group by b2b.import_source_line_id;
20562 
20563 cursor c_addr is
20564        select b2b.import_source_line_id,max(loc.location_id)
20565        from   hz_locations loc,ams_hz_b2b_mapping_v b2b
20566         where b2b.import_list_header_id = p_import_list_header_id
20567         and b2b.load_status in ('ACTIVE','RELOAD')
20568         and b2b.org_address_key is not null
20569         and b2b.org_location_id is null
20570         and loc.address_key     = b2b.org_address_key
20571          and loc.country          = b2b.org_country
20572          and nvl(loc.city,nvl(b2b.org_city,'x')) = nvl(b2b.org_city,'x')
20573 	group by b2b.import_source_line_id;
20574 
20575 begin
20576 x_return_status := FND_API.G_RET_STS_SUCCESS;
20577 -- TO POPULATE address_KEY
20578 l_last_fetch   := FALSE;
20579 open c_addr_key;
20580 LOOP
20581     fetch c_addr_key BULK COLLECT into
20582         L_IMPORT_SOURCE_LINE_ID,
20583         L_org_address_KEY LIMIT l_limit_rows;
20584 
20585         IF c_addr_key%NOTFOUND THEN
20586                 l_last_fetch := TRUE;
20587         END IF;
20588 
20589         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20590                  EXIT;
20591         END IF;
20592     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20593          SET org_address_key = L_org_address_KEY(I)
20594     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20595 
20596     if l_last_fetch then
20597       exit;
20598     end if;
20599     commit;
20600 END LOOP;
20601 close c_addr_key;
20602 -- TO POPULATE address_KEY
20603 
20604 -- TO CHECK WITH address with ps
20605 l_last_fetch   := FALSE;
20606 L_IMPORT_SOURCE_LINE_ID := null;
20607 open c_addr_ps;
20608 LOOP
20609     fetch c_addr_ps BULK COLLECT into
20610         L_IMPORT_SOURCE_LINE_ID,
20611         L_org_location_ID LIMIT l_limit_rows;
20612 
20613         IF c_addr_ps%NOTFOUND THEN
20614                 l_last_fetch := TRUE;
20615         END IF;
20616 
20617         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20618                  EXIT;
20619         END IF;
20620     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20621          SET org_location_id = L_org_location_ID(I)
20622     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20623 
20624     if l_last_fetch then
20625       exit;
20626     end if;
20627     commit;
20628 END LOOP;
20629 close c_addr_ps;
20630 -- TO CHECK WITH address ps
20631 
20632 -- TO CHECK WITH address
20633 l_last_fetch   := FALSE;
20634 L_IMPORT_SOURCE_LINE_ID := null;
20635 L_org_location_ID := null;
20636 open c_addr;
20637 LOOP
20638     fetch c_addr BULK COLLECT into
20639         L_IMPORT_SOURCE_LINE_ID,
20640         L_org_location_ID LIMIT l_limit_rows;
20641 
20642         IF c_addr%NOTFOUND THEN
20643                 l_last_fetch := TRUE;
20644         END IF;
20645 
20646         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20647                  EXIT;
20648         END IF;
20649     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2B_MAPPING_V
20650          SET org_location_id = L_org_location_ID(I)
20651     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20652 
20653     if l_last_fetch then
20654       exit;
20655     end if;
20656     commit;
20657 END LOOP;
20658 close c_addr;
20659 -- TO CHECK WITH address
20660 
20661 EXCEPTION
20662  WHEN OTHERS THEN
20663     x_return_status := FND_API.G_RET_STS_ERROR;
20664     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
20665     FND_MESSAGE.Set_Token('ROW','Error in org_address1_exist_checking :' || SQLERRM||' '||SQLCODE);
20666     AMS_Utility_PVT.Create_Log (
20667       x_return_status   => x_return_status,
20668       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
20669       p_log_used_by_id  => p_import_list_header_id,
20670       p_msg_data        => FND_MESSAGE.get,
20671       p_msg_type        => 'DEBUG'
20672    );
20673 
20674 end org_address1_exist_checking;
20675 
20676 -- -------------------------------------------------------------
20677 --
20678 -- This procedure is used for existence checking for person address
20679 --
20680 --
20681 PROCEDURE per_address_existence_checking(
20682    p_import_list_header_id IN NUMBER,
20683    x_return_status            OUT NOCOPY    VARCHAR2,
20684    x_msg_count                OUT NOCOPY    NUMBER,
20685    x_msg_data                 OUT NOCOPY    VARCHAR2
20686                        ) IS
20687 
20688 l_limit_rows            number := 1000;
20689 l_last_fetch            BOOLEAN;
20690 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
20691 TYPE address_KEY_LIST            IS TABLE OF AMS_IMP_SOURCE_LINES.address_KEY%TYPE;
20692 TYPE PARTY_location_ID_LIST          IS TABLE OF AMS_IMP_SOURCE_LINES.PARTY_location_ID%TYPE;
20693 
20694 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
20695 L_address_KEY                       address_KEY_LIST;
20696 L_PARTY_location_ID                  PARTY_location_ID_LIST;
20697 
20698 cursor c_addr_key is
20699 select b2c.import_source_line_id,
20700 hz_fuzzy_pub.Generate_Key('ADDRESS',null,b2c.address1,b2c.address2,b2c.address3,b2c.address4,b2c.postal_code,null,null)
20701 "add_key"
20702 from ams_hz_b2c_mapping_v b2c
20703 where b2c.import_list_header_id = p_import_list_header_id
20704   and b2c.load_status in ('ACTIVE','RELOAD')
20705   and b2c.address1 is not null;
20706 
20707 cursor c_addr_ps is
20708        select b2c.import_source_line_id,max(loc.location_id)
20709        from  hz_party_sites ps, hz_locations loc,ams_hz_b2c_mapping_v b2c
20710 	where b2c.import_list_header_id = p_import_list_header_id
20711   	and b2c.load_status in ('ACTIVE','RELOAD')
20712   	and b2c.address_key is not null
20713         and b2c.person_party_id is not null
20714         and ps.party_id          = b2c.person_party_id
20715          and ps.location_id       = loc.location_id
20716          and loc.address_key      = b2c.address_key
20717          and loc.country          = b2c.country
20718          and nvl(loc.city,nvl(b2c.city,'x')) = nvl(b2c.city,'x')
20719 	group by b2c.import_source_line_id;
20720 
20721 cursor c_addr is
20722        select b2c.import_source_line_id,max(loc.location_id)
20723        from   hz_locations loc,ams_hz_b2c_mapping_v b2c
20724         where b2c.import_list_header_id = p_import_list_header_id
20725         and b2c.load_status in ('ACTIVE','RELOAD')
20726         and b2c.address_key is not null
20727         and b2c.party_location_id is null
20728         and loc.address_key     = b2c.address_key
20729          and loc.country          = b2c.country
20730          and nvl(loc.city,nvl(b2c.city,'x')) = nvl(b2c.city,'x')
20731 	group by b2c.import_source_line_id;
20732 
20733 begin
20734 x_return_status := FND_API.G_RET_STS_SUCCESS;
20735 -- TO POPULATE address_KEY
20736 l_last_fetch   := FALSE;
20737 open c_addr_key;
20738 LOOP
20739     fetch c_addr_key BULK COLLECT into
20740         L_IMPORT_SOURCE_LINE_ID,
20741         L_address_KEY LIMIT l_limit_rows;
20742 
20743         IF c_addr_key%NOTFOUND THEN
20744                 l_last_fetch := TRUE;
20745         END IF;
20746 
20747         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20748                  EXIT;
20749         END IF;
20750     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
20751          SET address_key = L_address_KEY(I)
20752     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20753 
20754     if l_last_fetch then
20755       exit;
20756     end if;
20757     commit;
20758 END LOOP;
20759 close c_addr_key;
20760 -- TO POPULATE address_KEY
20761 
20762 -- TO CHECK WITH address with ps
20763 l_last_fetch   := FALSE;
20764 L_IMPORT_SOURCE_LINE_ID := null;
20765 open c_addr_ps;
20766 LOOP
20767     fetch c_addr_ps BULK COLLECT into
20768         L_IMPORT_SOURCE_LINE_ID,
20769         L_PARTY_location_ID LIMIT l_limit_rows;
20770 
20771         IF c_addr_ps%NOTFOUND THEN
20772                 l_last_fetch := TRUE;
20773         END IF;
20774 
20775         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20776                  EXIT;
20777         END IF;
20778     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
20779          SET party_location_id = L_PARTY_location_ID(I)
20780     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20781 
20782     if l_last_fetch then
20783       exit;
20784     end if;
20785     commit;
20786 END LOOP;
20787 close c_addr_ps;
20788 -- TO CHECK WITH address ps
20789 
20790 -- TO CHECK WITH address
20791 l_last_fetch   := FALSE;
20792 L_IMPORT_SOURCE_LINE_ID := null;
20793 L_PARTY_location_ID := null;
20794 open c_addr;
20795 LOOP
20796     fetch c_addr BULK COLLECT into
20797         L_IMPORT_SOURCE_LINE_ID,
20798         L_PARTY_location_ID LIMIT l_limit_rows;
20799 
20800         IF c_addr%NOTFOUND THEN
20801                 l_last_fetch := TRUE;
20802         END IF;
20803 
20804         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
20805                  EXIT;
20806         END IF;
20807     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_HZ_B2C_MAPPING_V
20808          SET party_location_id = L_PARTY_location_ID(I)
20809     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
20810 
20811     if l_last_fetch then
20812       exit;
20813     end if;
20814     commit;
20815 END LOOP;
20816 close c_addr;
20817 -- TO CHECK WITH address
20818 
20819 EXCEPTION
20820  WHEN OTHERS THEN
20821     x_return_status := FND_API.G_RET_STS_ERROR;
20822     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
20823     FND_MESSAGE.Set_Token('ROW','Error in per_address_existence_checking :' || SQLERRM||' '||SQLCODE);
20824     AMS_Utility_PVT.Create_Log (
20825       x_return_status   => x_return_status,
20826       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
20827       p_log_used_by_id  => p_import_list_header_id,
20828       p_msg_data        => FND_MESSAGE.get,
20829       p_msg_type        => 'DEBUG'
20830    );
20831 
20832 end per_address_existence_checking;
20833 
20834 -- ---------------------------------------
20835 --
20836 -- This procedure is used to update the status for b2b/b2c import.
20837 --
20838 --
20839 PROCEDURE update_cust_import_status(
20840    p_import_list_header_id    IN    NUMBER
20841                             ) IS
20842    x_import_list_header_id number;
20843    l_import_type        VARCHAR2(30);
20844    l_msg_code           NUMBER;
20845    l_msg_buf            VARCHAR2(4000);
20846    l_batch_id           NUMBER;
20847    l_lookup_code        VARCHAR2(30);
20848    l_return_status      VARCHAR2(1);
20849    X_RETURN_STATUS      VARCHAR2(1);
20850    x_msg_count          NUMBER;
20851    x_msg_data           VARCHAR2(2000);
20852    i_return_status      VARCHAR2(1);
20853    l_dedupe_flag        VARCHAR2(1);
20854    l_b2b_flag           VARCHAR2(1);
20855    l_validate_file      VARCHAR2(1);
20856    i_msg_data           VARCHAR2(2000);
20857    i_msg_buf            VARCHAR2(4000);
20858    i_msg_code           NUMBER;
20859    i_msg_count          NUMBER;
20860    l_list_header_id     NUMBER;
20861    l_duplicate_records  NUMBER;
20862    l_user_status_id     NUMBER;
20863 
20864    l_lead_status        VARCHAR2(30);
20865    i_processed_records  NUMBER;
20866    i_failed_records     NUMBER;
20867    l_request_id         NUMBER;
20868    l_conc_prog_name     VARCHAR2(60);
20869    l_finish_status      VARCHAR2(30);
20870    l_status_code        VARCHAR2(30);
20871 
20872    l_error_exist        VARCHAR2(1);
20873    l_execute_mode       VARCHAR2(1);
20874    l_rec_in_stag_tab    VARCHAR2(1);
20875    l_loaded_records     NUMBER;
20876    l_failed_records     NUMBER;
20877    l_loaded_rows        NUMBER;
20878    L_TOTAL_RECORDS      NUMBER;
20879    l_gen_list           VARCHAR2(1);
20880    l_list_name          VARCHAR2(240);
20881    l_OWNER_USER_ID      NUMBER;
20882       L_TOTAL_DUP_RECORDS  number;
20883    i_file_type VARCHAR2(30);
20884    i_xml_element_id     NUMBER;
20885    i_dedupe_flag        VARCHAR2(1);
20886 
20887    cursor c_import_type is
20888    select
20889    GENERATE_LIST,GENERATED_LIST_NAME,OWNER_USER_ID,dedupe_flag
20890    from ams_imp_list_headers_all
20891    where import_list_header_id = p_import_list_header_id;
20892 
20893    cursor c_dup_recs is
20894           select count(*) from ams_imp_source_lines
20895           where import_list_header_id = p_import_list_header_id
20896             and duplicate_flag = 'Y';
20897 
20898  cursor c_error_exist is
20899    select 'Y' from ams_list_import_errors
20900    where import_list_header_id = p_import_list_header_id
20901      and error_type = 'E'
20902      and rownum < 2;
20903 
20904  cursor c_loaded_records is
20905    select count(*) from ams_imp_source_lines
20906    where import_list_header_id = p_import_list_header_id
20907      and load_status = G_STATUS_SUCCESS;
20908 
20909  cursor c_failed_records is
20910    select count(*) from ams_imp_source_lines
20911    where import_list_header_id = p_import_list_header_id
20912      and load_status = G_STATUS_ERROR;
20913 
20914  cursor c_total_records is
20915    select count(*) from ams_imp_source_lines
20916    where import_list_header_id = p_import_list_header_id
20917      and load_status = 'ACTIVE';
20918 
20919  cursor c_dup_records is
20920    select count(*) from ams_imp_source_lines
20921    where import_list_header_id = p_import_list_header_id
20922      and load_status = G_STATUS_DUPLICATE;
20923 
20924  cursor c_file_type is
20925     select file_type from ams_imp_documents
20926     where import_list_header_id = p_import_list_header_id;
20927 
20928  cursor c_dup_xml_recs is
20929      select COL68 from ams_imp_source_lines
20930      where load_status = 'DUPLICATE'
20931     AND import_list_header_id = p_import_list_header_id;
20932 
20933 
20934 begin
20935       open c_import_type;
20936       fetch c_import_type into l_gen_list,l_list_name,l_OWNER_USER_ID,i_dedupe_flag;
20937       close c_import_type;
20938 
20939 -- ------------------------------------------------------
20940 -- ------------RAISE POST BUSINESS EVENT START ---------------------
20941 
20942               Raise_Business_event(p_import_list_header_id,
20943                                         'oracle.apps.ams.list.ListImportPostEvent');
20944 
20945 -- ------------RAISE POST BUSINESS EVENT END ---------------------
20946 -- ------------------------------------------------------
20947       open c_error_exist;
20948       fetch c_error_exist into l_error_exist;
20949       close c_error_exist;
20950       if l_error_exist = 'Y' then
20951          l_lookup_code := 'ERROR';
20952          l_user_status_id := null;
20953          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
20954          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
20955          system_status_code = 'ERROR' and default_flag = 'Y';
20956 
20957          UPDATE ams_imp_list_headers_all
20958          set status_code       =  l_lookup_code,
20959             user_status_id    =  l_user_status_id,
20960             status_date       =  sysdate
20961          where import_list_header_id = p_import_list_header_id;
20962       end if;
20963       if l_error_exist is NULL then
20964        l_lookup_code := 'COMPLETED';
20965          l_user_status_id := null;
20966          SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
20967          WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
20968          system_status_code = 'COMPLETED' and default_flag = 'Y';
20969 
20970          UPDATE ams_imp_list_headers_all
20971          set status_code       =  l_lookup_code,
20972             user_status_id    =  l_user_status_id,
20973             status_date       =  sysdate
20974          where import_list_header_id = p_import_list_header_id;
20975       end if;
20976 
20977         -- Delete all the errors from the errors table which are sucessful.
20978                 delete from ams_list_import_errors where import_list_header_id
20979                 = p_import_list_header_id and import_source_line_id in
20980                 (select import_source_line_id from ams_imp_source_lines where
20981                 import_list_header_id = p_import_list_header_id and load_status = G_STATUS_SUCCESS);
20982      open c_loaded_records;
20983      fetch c_loaded_records into l_loaded_records;
20984      close c_loaded_records;
20985      open c_failed_records;
20986      fetch c_failed_records into l_failed_records;
20987      close c_failed_records;
20988      open c_dup_records;
20989      fetch c_dup_records into L_TOTAL_DUP_RECORDS;
20990      close c_dup_records;
20991      UPDATE ams_imp_list_headers_all
20992         SET loaded_no_of_rows = l_loaded_records,
20993             number_of_failed_records = l_failed_records,
20994             number_of_duplicate_records = L_TOTAL_DUP_RECORDS,
20995             loaded_date = sysdate
20996       WHERE import_list_header_id = p_import_list_header_id;
20997 
20998   open c_file_type;
20999   fetch c_file_type into i_file_type;
21000   close c_file_type;
21001 
21002  if i_file_type = 'XML' and i_dedupe_flag = 'Y' then
21003         open  c_dup_xml_recs;
21004         LOOP
21005            fetch c_dup_xml_recs into i_xml_element_id;
21006 
21007            exit when c_dup_xml_recs%notfound;
21008            AMS_List_Import_PUB.process_element_duplicate (
21009                                  p_import_list_header_id,
21010                                  i_xml_element_id);
21011         END LOOP;
21012         close c_dup_xml_recs;
21013  end if;
21014 
21015    if l_gen_list = 'Y' then
21016             AMS_Utility_PVT.Create_Log (
21017               x_return_status   => l_return_status,
21018               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21019               p_log_used_by_id  => p_import_list_header_id,
21020               p_msg_data        => 'Starting List Generation for List Import.',
21021               p_msg_type        => 'DEBUG'
21022               );
21023               l_loaded_rows := 0;
21024               select LOADED_NO_OF_ROWS into l_loaded_rows from ams_imp_list_headers_all
21025               where import_list_header_id = p_import_list_header_id;
21026 
21027              if l_loaded_rows > 0 then
21028                AMS_ListGeneration_PKG.create_import_list
21029                 ( 1,
21030                   'T',
21031                   'T',
21032                   FND_API.G_VALID_LEVEL_FULL,
21033                   l_owner_user_id,
21034                   p_import_list_header_id,
21035                   i_return_status,
21036                   i_msg_count,
21037                   i_msg_data,
21038                   l_list_header_id,
21039                   l_list_name) ;
21040 
21041              If i_return_status <> 'S' then
21042               AMS_Utility_PVT.Create_Log (
21043               x_return_status   => l_return_status,
21044               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21045               p_log_used_by_id  => p_import_list_header_id,
21046               p_msg_data        => 'Error in List Generation --'||i_msg_data,
21047               p_msg_type        => 'DEBUG'
21048               );
21049              End if;
21050              end if;
21051              AMS_Utility_PVT.Create_Log (
21052               x_return_status   => l_return_status,
21053               p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21054               p_log_used_by_id  => p_import_list_header_id,
21055               p_msg_data        => 'End List Generation for List Import.',
21056               p_msg_type        => 'DEBUG'
21057               );
21058   end if;  -- p_generate_list
21059 
21060            l_total_records := 0;
21061            open c_total_records;
21062            fetch c_total_records into l_total_records;
21063            close c_total_records;
21064              AMS_Utility_PVT.Create_Log (
21065                   x_return_status   => l_return_status,
21066                   p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21067                   p_log_used_by_id  => p_import_list_header_id,
21068                   p_msg_data  => 'Total Number of records not processed: '||to_char(l_total_records),
21069                   p_msg_type        => 'DEBUG'
21070                 );
21071 
21072 end update_cust_import_status;
21073 
21074 
21075 --
21076 -- This procedure is updates the records with request_id ordered by party_name
21077 --
21078 --
21079 PROCEDURE org_party_update(
21080    p_import_list_header_id IN   NUMBER,
21081    p_request_id            IN   NUMBER,
21082    p_batch_size            IN   NUMBER,
21083    x_return_status            OUT NOCOPY    VARCHAR2,
21084    x_msg_count                OUT NOCOPY    NUMBER,
21085    x_msg_data                 OUT NOCOPY    VARCHAR2
21086                        ) IS
21087 
21088 l_limit_rows            number := 1000;
21089 l_last_fetch            BOOLEAN;
21090 
21091 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
21092 
21093 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
21094 
21095 cursor c_ordered_recs is
21096 
21097 select ab.import_source_line_id from
21098 (select import_source_line_id from ams_imp_source_lines
21099 where import_list_header_id = p_import_list_header_id
21100   and request_id is  null
21101 order by org_key) ab
21102 where  rownum <= p_batch_size;
21103 /*
21104 select import_source_line_id from ams_imp_source_lines
21105 where import_list_header_id = p_import_list_header_id
21106   and request_id is null
21107   and rownum <= p_batch_size;
21108 
21109 
21110 SELECT AB.import_source_line_id
21111 from
21112 ( select import_source_line_id, org_key ,ROW_NUMBER() OVER (order by org_key)  as id
21113  from  ams_imp_source_lines
21114 where import_list_header_id = p_import_list_header_id
21115   and request_id is null ) AB
21116 where AB.id <= p_batch_size;
21117 */
21118 
21119 begin
21120 l_last_fetch   := FALSE;
21121 L_IMPORT_SOURCE_LINE_ID := null;
21122 open c_ordered_recs;
21123 LOOP
21124     fetch c_ordered_recs BULK COLLECT into
21125         L_IMPORT_SOURCE_LINE_ID LIMIT l_limit_rows;
21126 
21127         IF c_ordered_recs%NOTFOUND THEN
21128                 l_last_fetch := TRUE;
21129         END IF;
21130 
21131         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
21132                  EXIT;
21133         END IF;
21134     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_IMP_SOURCE_LINES
21135          SET request_id = p_request_id
21136     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
21137 
21138     if l_last_fetch then
21139       exit;
21140     end if;
21141     commit;
21142 END LOOP;
21143 close c_ordered_recs;
21144 commit;
21145 EXCEPTION
21146  WHEN OTHERS THEN
21147     x_return_status := FND_API.G_RET_STS_ERROR;
21148     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
21149     FND_MESSAGE.Set_Token('ROW','Error in org_party_update:' || SQLERRM||' '||SQLCODE);
21150     AMS_Utility_PVT.Create_Log (
21151       x_return_status   => x_return_status,
21152       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21153       p_log_used_by_id  => p_import_list_header_id,
21154       p_msg_data        => FND_MESSAGE.get,
21155       p_msg_type        => 'DEBUG'
21156    );
21157 
21158 end org_party_update;
21159 
21160 -- ------------------------------------
21161 --
21162 -- This procedure is updates the records with transposed phone number.
21163 --
21164 --
21165 PROCEDURE gen_transposed_phone_number(
21166    p_import_list_header_id IN   NUMBER,
21167    x_return_status            OUT NOCOPY    VARCHAR2,
21168    x_msg_count                OUT NOCOPY    NUMBER,
21169    x_msg_data                 OUT NOCOPY    VARCHAR2
21170                        ) IS
21171 
21172 l_limit_rows            number := 1000;
21173 l_last_fetch            BOOLEAN;
21174 l_imp_type              varchar2(30);
21175 
21176 TYPE IMPORT_SOURCE_LINE_ID_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.IMPORT_SOURCE_LINE_ID%TYPE;
21177 TYPE TRANSPOSED_PH_NUMBER_LIST IS TABLE OF AMS_IMP_SOURCE_LINES.TRANSPOSED_PHONE_NUMBER%TYPE;
21178 
21179 L_IMPORT_SOURCE_LINE_ID         IMPORT_SOURCE_LINE_ID_LIST;
21180 L_TRANSPOSED_PHONE_NUMBER       TRANSPOSED_PH_NUMBER_LIST;
21181 
21182 cursor c_imp_type is
21183 select import_type from ams_imp_list_headers_all
21184 where import_list_header_id = p_import_list_header_id;
21185 
21186 cursor c_b2b_ph_no is
21187 select IMPORT_SOURCE_LINE_ID ,
21188 hz_phone_number_pkg.transpose(PHONE_COUNTRY_CODE||PHONE_AREA_CODE||PHONE_NUMBER) "TRANS_PHONE_NUMBER"
21189 from
21190 ams_hz_b2b_mapping_v
21191 where import_list_header_id = p_import_list_header_id
21192   and phone_number is not null
21193   and TRANSPOSED_PHONE_NUMBER is null
21194   and load_status in ('ACTIVE','RELOAD');
21195 
21196 cursor c_b2c_ph_no is
21197 select IMPORT_SOURCE_LINE_ID ,
21198 hz_phone_number_pkg.transpose(PHONE_COUNTRY_CODE||PHONE_AREA_CODE||PHONE_NUMBER) "TRANS_PHONE_NUMBER"
21199 from
21200 ams_hz_b2c_mapping_v
21201 where import_list_header_id = p_import_list_header_id
21202   and phone_number is not null
21203   and TRANSPOSED_PHONE_NUMBER is null
21204   and load_status in ('ACTIVE','RELOAD');
21205 begin
21206 l_last_fetch   := FALSE;
21207 open c_imp_type;
21208 fetch c_imp_type into l_imp_type;
21209 close c_imp_type;
21210 
21211 if l_imp_type = 'B2B' then
21212   open c_b2b_ph_no;
21213   LOOP
21214     fetch c_b2b_ph_no BULK COLLECT into
21215         L_IMPORT_SOURCE_LINE_ID, L_TRANSPOSED_PHONE_NUMBER LIMIT l_limit_rows;
21216 
21217         IF c_b2b_ph_no%NOTFOUND THEN
21218                 l_last_fetch := TRUE;
21219         END IF;
21220 
21221         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
21222                  EXIT;
21223         END IF;
21224     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_IMP_SOURCE_LINES
21225          SET TRANSPOSED_PHONE_NUMBER = L_TRANSPOSED_PHONE_NUMBER(i)
21226     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
21227     if l_last_fetch then
21228       exit;
21229     end if;
21230     commit;
21231   END LOOP;
21232 close c_b2b_ph_no;
21233 end if ; -- _b2b_flag = 'Y'
21234 if l_imp_type = 'B2C' then
21235   open c_b2c_ph_no;
21236   LOOP
21237     fetch c_b2c_ph_no BULK COLLECT into
21238         L_IMPORT_SOURCE_LINE_ID, L_TRANSPOSED_PHONE_NUMBER LIMIT l_limit_rows;
21239 
21240         IF c_b2c_ph_no%NOTFOUND THEN
21241                 l_last_fetch := TRUE;
21242         END IF;
21243 
21244         IF L_IMPORT_SOURCE_LINE_ID.COUNT = 0 AND l_last_fetch THEN
21245                  EXIT;
21246         END IF;
21247     FORALL i IN L_IMPORT_SOURCE_LINE_ID.FIRST..L_IMPORT_SOURCE_LINE_ID.LAST UPDATE AMS_IMP_SOURCE_LINES
21248          SET TRANSPOSED_PHONE_NUMBER = L_TRANSPOSED_PHONE_NUMBER(i)
21249     WHERE  IMPORT_SOURCE_LINE_ID = L_IMPORT_SOURCE_LINE_ID(i);
21250     if l_last_fetch then
21251       exit;
21252     end if;
21253     commit;
21254   END LOOP;
21255 close c_b2c_ph_no;
21256 end if ; -- l_b2b_flag = 'N'
21257 commit;
21258 EXCEPTION
21259  WHEN OTHERS THEN
21260     x_return_status := FND_API.G_RET_STS_ERROR;
21261     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
21262     FND_MESSAGE.Set_Token('ROW','Error in gen_transposed_phone_number :' || SQLERRM||' '||SQLCODE);
21263     AMS_Utility_PVT.Create_Log (
21264       x_return_status   => x_return_status,
21265       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21266       p_log_used_by_id  => p_import_list_header_id,
21267       p_msg_data        => FND_MESSAGE.get,
21268       p_msg_type        => 'DEBUG'
21269    );
21270 
21271 end gen_transposed_phone_number;
21272 
21273 
21274 --
21275 -- for XML updates the error in the element table
21276 --
21277 PROCEDURE update_xml_error_text (
21278                                  p_import_list_header_id    IN    NUMBER,
21279                                  p_import_type        IN varchar2) IS
21280 
21281 l_org_imp_xml_element_id        number;
21282 l_add_imp_xml_element_id        number;
21283 l_ocont_imp_xml_element_id      number;
21284 l_cp_imp_xml_element_id         number;
21285 l_em_imp_xml_element_id         number;
21286 l_per_imp_xml_element_id        number;
21287 l_return_status			varchar2(1000);
21288 
21289 cursor c_b2bxmlrec is
21290 select org_imp_xml_element_id, add_imp_xml_element_id, ocont_imp_xml_element_id,
21291 cp_imp_xml_element_id, em_imp_xml_element_id
21292 from ams_hz_b2b_mapping_v
21293 where import_list_header_id = p_import_list_header_id
21294   and load_status = 'RELOAD';
21295 
21296 cursor c_b2cxmlrec is
21297 select per_imp_xml_element_id, add_imp_xml_element_id,cp_imp_xml_element_id, em_imp_xml_element_id
21298 from ams_hz_b2c_mapping_v
21299 where import_list_header_id = p_import_list_header_id
21300   and load_status = 'RELOAD';
21301 
21302 begin
21303  if p_import_type = 'B2B' then
21304     open c_b2bxmlrec;
21305     loop
21306       fetch c_b2bxmlrec into l_org_imp_xml_element_id, l_add_imp_xml_element_id,
21307             l_ocont_imp_xml_element_id, l_cp_imp_xml_element_id, l_em_imp_xml_element_id;
21308       exit when c_b2bxmlrec%notfound;
21309             update AMS_IMP_XML_ELEMENTS
21310             set ERROR_TEXT = NULL
21311             where  imp_xml_element_id = l_org_imp_xml_element_id;
21312             update AMS_IMP_XML_ELEMENTS
21313             set ERROR_TEXT = NULL
21314             where  imp_xml_element_id = l_add_imp_xml_element_id;
21315             update AMS_IMP_XML_ELEMENTS
21316             set ERROR_TEXT = NULL
21317             where  imp_xml_element_id = l_ocont_imp_xml_element_id;
21318             update AMS_IMP_XML_ELEMENTS
21319             set ERROR_TEXT = NULL
21320             where  imp_xml_element_id = l_cp_imp_xml_element_id;
21321             update AMS_IMP_XML_ELEMENTS
21322             set ERROR_TEXT = NULL
21323             where  imp_xml_element_id = l_em_imp_xml_element_id;
21324     end loop;
21325     close c_b2bxmlrec;
21326  end if;
21327 
21328 
21329  if p_import_type = 'B2C' then
21330     open c_b2cxmlrec;
21331     loop
21332       fetch c_b2cxmlrec into l_per_imp_xml_element_id , l_add_imp_xml_element_id,
21333             l_cp_imp_xml_element_id, l_em_imp_xml_element_id;
21334       exit when c_b2cxmlrec%notfound;
21335             update AMS_IMP_XML_ELEMENTS
21336             set ERROR_TEXT = NULL
21337             where  imp_xml_element_id = l_per_imp_xml_element_id;
21338             update AMS_IMP_XML_ELEMENTS
21339             set ERROR_TEXT = NULL
21340             where  imp_xml_element_id = l_add_imp_xml_element_id;
21341             update AMS_IMP_XML_ELEMENTS
21342             set ERROR_TEXT = NULL
21343             where  imp_xml_element_id = l_cp_imp_xml_element_id;
21344             update AMS_IMP_XML_ELEMENTS
21345             set ERROR_TEXT = NULL
21346             where  imp_xml_element_id = l_em_imp_xml_element_id;
21347     end loop;
21348     close c_b2cxmlrec;
21349  end if;
21350 
21351 EXCEPTION
21352  WHEN OTHERS THEN
21353     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
21354     FND_MESSAGE.Set_Token('ROW','Error in update_xml_error_text :' || SQLERRM||' '||SQLCODE);
21355     AMS_Utility_PVT.Create_Log (
21356       x_return_status   => l_return_status,
21357       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21358       p_log_used_by_id  => p_import_list_header_id,
21359       p_msg_data        => FND_MESSAGE.get,
21360       p_msg_type        => 'DEBUG'
21361    );
21362 
21363 end update_xml_error_text;
21364 -- -----------------------------
21365 -- This Program will raise pre business event from list import
21366 PROCEDURE Raise_Business_event(
21367                             p_import_list_header_id NUMBER,
21368                             p_event                 VARCHAR2
21369                             ) IS
21370 
21371  l_parameter_list  WF_PARAMETER_LIST_T;
21372  l_new_item_key    VARCHAR2(30);
21373  l_return_status   VARCHAR2(30);
21374  l_import_type     VARCHAR2(30);
21375  l_user_id 	   NUMBER;
21376  l_vendor_id       NUMBER;
21377  l_lang_encoding   VARCHAR2(30);
21378  l_resp_id         NUMBER :=  FND_GLOBAL.resp_id;
21379  l_error_code      VARCHAR2(1);
21380  l_error_text      VARCHAR2(4000);
21381  l_user_status_id  NUMBER;
21382 
21383  Cursor c_header_info is
21384         select import_type,last_updated_by,vendor_id,charset from ams_imp_list_headers_all
21385         where  import_list_header_id = p_import_list_header_id;
21386 
21387 Begin
21388       AMS_Utility_PVT.Create_Log (
21389          x_return_status   => l_return_status,
21390          p_arc_log_used_by => 'IMPH',
21391          p_log_used_by_id  => p_import_list_header_id,
21392          p_msg_data        => ' Start Business event : '||p_event,
21393          p_msg_type        => 'DEBUG'
21394        );
21395     open c_header_info;
21396     fetch c_header_info into l_import_type,l_user_id,l_vendor_id,l_lang_encoding;
21397     close c_header_info;
21398          l_new_item_key    := p_import_list_header_id|| TO_CHAR(SYSDATE,'DDMMRRRRHH24MISS');
21399          l_parameter_list := WF_PARAMETER_LIST_T();
21400 
21401          wf_event.AddParameterToList(p_name           => 'IMPORT_LIST_HEADER_ID',
21402                                     p_value           => p_import_list_header_id,
21403                                     p_parameterlist   => l_parameter_list);
21404 
21405          wf_event.AddParameterToList(p_name           => 'IMPORT_TYPE',
21406                                     p_value           => l_import_type,
21407                                     p_parameterlist   => l_parameter_list);
21408 
21409          wf_event.AddParameterToList(p_name           => 'USER_ID',
21410                                     p_value           => l_user_id,
21411                                     p_parameterlist   => l_parameter_list);
21412 
21413          wf_event.AddParameterToList(p_name           => 'VENDOR_ID',
21414                                     p_value           => l_vendor_id,
21415                                     p_parameterlist   => l_parameter_list);
21416 
21417          wf_event.AddParameterToList(p_name           => 'LANGUAGE_ENCODING',
21418                                     p_value           => l_lang_encoding,
21419                                     p_parameterlist   => l_parameter_list);
21420 
21421          wf_event.AddParameterToList(p_name           => 'RESPONSIBILITY_ID',
21422                                     p_value           => l_resp_id,
21423                                     p_parameterlist   => l_parameter_list);
21424 /*
21425          wf_event.AddParameterToList(p_name           => 'ERROR_CODE',
21426                                     p_value           => l_error_code,
21427                                     p_parameterlist   => l_parameter_list);
21428 
21429          wf_event.AddParameterToList(p_name           => 'ERROR_TEXT',
21430                                     p_value           => l_error_text,
21431                                     p_parameterlist   => l_parameter_list);
21432 */
21433          WF_EVENT.Raise
21434             ( p_event_name   =>  p_event,
21435               p_event_key    =>  l_new_item_key,
21436               p_parameters   =>  l_parameter_list);
21437 
21438      AMS_Utility_PVT.Create_Log (
21439          x_return_status   => l_return_status,
21440          p_arc_log_used_by => 'IMPH',
21441          p_log_used_by_id  => p_import_list_header_id,
21442          p_msg_data        => 'End Business event : '||p_event,
21443          p_msg_type        => 'DEBUG'
21444        );
21445       commit;
21446 /*
21447       if l_error_code = 'E' then
21448 	    AMS_Utility_PVT.Create_Log (
21449       		x_return_status   => l_return_status,
21450       		p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21451       		p_log_used_by_id  => p_import_list_header_id,
21452       		p_msg_data        => 'Business Event Error: '||l_error_text,
21453       		p_msg_type        => 'DEBUG'
21454    		);
21455                 l_user_status_id := null;
21456                 SELECT user_status_id into l_user_status_id FROM ams_user_statuses_vl
21457                 WHERE system_status_type = 'AMS_IMPORT_STATUS' AND
21458                 system_status_code = 'ERROR'  and default_flag = 'Y';
21459                 UPDATE ams_imp_list_headers_all
21460                 set status_code       = 'ERROR' ,
21461                 user_status_id    =  l_user_status_id,
21462                 status_date       =  sysdate
21463                 where import_list_header_id = p_import_list_header_id;
21464 
21465          return;
21466       end if;
21467 */
21468  EXCEPTION
21469  WHEN OTHERS THEN
21470     FND_MESSAGE.set_name('AMS', 'API_DEBUG_MESSAGE');
21471     FND_MESSAGE.Set_Token('ROW','Error in Raise_Business_event :' ||SQLERRM||' '||SQLCODE);
21472     AMS_Utility_PVT.Create_Log (
21473       x_return_status   => l_return_status,
21474       p_arc_log_used_by => G_ARC_IMPORT_HEADER,
21475       p_log_used_by_id  => p_import_list_header_id,
21476       p_msg_data        => FND_MESSAGE.get,
21477       p_msg_type        => 'DEBUG'
21478    );
21479 
21480 end Raise_Business_event;
21481 
21482 -- -----------------------------
21483 FUNCTION TEST_Pre_sub
21484 ( p_subscription_guid In RAW
21485 , p_event IN OUT NOCOPY WF_EVENT_T
21486 )
21487 RETURN VARCHAR2 IS
21488 
21489 l_return_status		varchar2(30);
21490 l_import_list_header_id	number;
21491 l_import_type		varchar2(30);
21492 l_user_id         NUMBER;
21493 l_resp_id         NUMBER;
21494 l_VENDOR_ID	  NUMBER;
21495 l_LANGUAGE_ENCODING	varchar2(30);
21496 
21497 
21498 begin
21499   -- SAVEPOINT TEST_Pre_sub;
21500 
21501   l_import_list_header_id := p_event.GetValueForParameter('IMPORT_LIST_HEADER_ID');
21502   l_import_type           := p_event.GetValueForParameter('IMPORT_TYPE');
21503   l_user_id		  := p_event.GetValueForParameter('USER_ID');
21504   l_resp_id		  := p_event.GetValueForParameter('RESPONSIBILITY_ID');
21505   l_VENDOR_ID		  := p_event.GetValueForParameter('VENDOR_ID');
21506   l_LANGUAGE_ENCODING	  := p_event.GetValueForParameter('LANGUAGE_ENCODING');
21507     AMS_Utility_PVT.Create_Log (
21508       x_return_status   => l_return_status,
21509       p_arc_log_used_by => 'IMPH',
21510       p_log_used_by_id  => l_import_list_header_id,
21511       p_msg_data        => 'COMING INSIDE TEST_Pre_sub EVENT.......',
21512       p_msg_type        => 'DEBUG'
21513    );
21514 
21515     AMS_Utility_PVT.Create_Log (
21516       x_return_status   => l_return_status,
21517       p_arc_log_used_by => 'IMPH',
21518       p_log_used_by_id  => l_import_list_header_id,
21519       p_msg_data        => 'IMPORT_LIST_HEADER_ID = '||to_char(l_import_list_header_id),
21520       p_msg_type        => 'DEBUG');
21521 
21522     AMS_Utility_PVT.Create_Log (
21523       x_return_status   => l_return_status,
21524       p_arc_log_used_by => 'IMPH',
21525       p_log_used_by_id  => l_import_list_header_id,
21526       p_msg_data        => 'IMPORT_TYPE = '||l_import_type,
21527       p_msg_type        => 'DEBUG');
21528 
21529     AMS_Utility_PVT.Create_Log (
21530       x_return_status   => l_return_status,
21531       p_arc_log_used_by => 'IMPH',
21532       p_log_used_by_id  => l_import_list_header_id,
21533       p_msg_data        => 'USER_ID = '||to_char(l_user_id),
21534       p_msg_type        => 'DEBUG');
21535 
21536     AMS_Utility_PVT.Create_Log (
21537       x_return_status   => l_return_status,
21538       p_arc_log_used_by => 'IMPH',
21539       p_log_used_by_id  => l_import_list_header_id,
21540       p_msg_data        => 'RESPONSIBILITY_ID = '||to_char(l_resp_id),
21541       p_msg_type        => 'DEBUG');
21542 
21543     AMS_Utility_PVT.Create_Log (
21544       x_return_status   => l_return_status,
21545       p_arc_log_used_by => 'IMPH',
21546       p_log_used_by_id  => l_import_list_header_id,
21547       p_msg_data        => 'VENDOR_ID = '||to_char(l_VENDOR_ID),
21548       p_msg_type        => 'DEBUG');
21549 
21550     AMS_Utility_PVT.Create_Log (
21551       x_return_status   => l_return_status,
21552       p_arc_log_used_by => 'IMPH',
21553       p_log_used_by_id  => l_import_list_header_id,
21554       p_msg_data        => 'LANGUAGE_ENCODING = '||l_LANGUAGE_ENCODING,
21555       p_msg_type        => 'DEBUG');
21556 
21557    update ams_hz_b2b_mapping_v
21558       set CUSTOM_PROCESSING_STATUS = 'pre-processing'
21559    where import_list_header_id = l_import_list_header_id;
21560 
21561    return 'SUCCESS';
21562 EXCEPTION
21563     WHEN OTHERS  THEN
21564 --     ROLLBACK TO TEST_Pre_sub;
21565 /*
21566      FND_MESSAGE.SET_NAME( 'AMS', 'API_DEBUG_MESSAGE' );
21567      FND_MESSAGE.SET_TOKEN( 'GENERIC_TEXT' ,SQLERRM );
21568      FND_MSG_PUB.ADD;
21569 */
21570      WF_CORE.CONTEXT('AMS_LIST_IMPORT_PUB', 'TEST_Pre_sub', p_event.getEventName(), p_subscription_guid);
21571      WF_EVENT.setErrorInfo(p_event, 'ERROR');
21572 
21573      RETURN 'ERROR';
21574 
21575 end TEST_Pre_sub;
21576 
21577 -- -----------------------------
21578 FUNCTION TEST_Post_sub
21579 ( p_subscription_guid In RAW
21580 , p_event IN OUT NOCOPY WF_EVENT_T
21581 )
21582 RETURN VARCHAR2 IS
21583 
21584 l_return_status         varchar2(30);
21585 l_import_list_header_id number;
21586 l_import_type           varchar2(30);
21587 l_user_id         NUMBER;
21588 l_resp_id         NUMBER;
21589 l_VENDOR_ID       NUMBER;
21590 l_LANGUAGE_ENCODING     varchar2(30);
21591 
21592 
21593 begin
21594   -- SAVEPOINT TEST_Post_sub;
21595 
21596   l_import_list_header_id := p_event.GetValueForParameter('IMPORT_LIST_HEADER_ID');
21597   l_import_type           := p_event.GetValueForParameter('IMPORT_TYPE');
21598   l_user_id               := p_event.GetValueForParameter('USER_ID');
21599   l_resp_id               := p_event.GetValueForParameter('RESPONSIBILITY_ID');
21600   l_VENDOR_ID             := p_event.GetValueForParameter('VENDOR_ID');
21601   l_LANGUAGE_ENCODING     := p_event.GetValueForParameter('LANGUAGE_ENCODING');
21602     AMS_Utility_PVT.Create_Log (
21603       x_return_status   => l_return_status,
21604       p_arc_log_used_by => 'IMPH',
21605       p_log_used_by_id  => l_import_list_header_id,
21606       p_msg_data        => 'COMING INSIDE TEST_Post_sub EVENT.......',
21607       p_msg_type        => 'DEBUG'
21608    );
21609     AMS_Utility_PVT.Create_Log (
21610       x_return_status   => l_return_status,
21611       p_arc_log_used_by => 'IMPH',
21612       p_log_used_by_id  => l_import_list_header_id,
21613       p_msg_data        => 'IMPORT_LIST_HEADER_ID = '||to_char(l_import_list_header_id),
21614       p_msg_type        => 'DEBUG');
21615 
21616     AMS_Utility_PVT.Create_Log (
21617       x_return_status   => l_return_status,
21618       p_arc_log_used_by => 'IMPH',
21619       p_log_used_by_id  => l_import_list_header_id,
21620       p_msg_data        => 'IMPORT_TYPE = '||l_import_type,
21621       p_msg_type        => 'DEBUG');
21622 
21623     AMS_Utility_PVT.Create_Log (
21624       x_return_status   => l_return_status,
21625       p_arc_log_used_by => 'IMPH',
21626       p_log_used_by_id  => l_import_list_header_id,
21627       p_msg_data        => 'USER_ID = '||to_char(l_user_id),
21628       p_msg_type        => 'DEBUG');
21629 
21630     AMS_Utility_PVT.Create_Log (
21631       x_return_status   => l_return_status,
21632       p_arc_log_used_by => 'IMPH',
21633       p_log_used_by_id  => l_import_list_header_id,
21634       p_msg_data        => 'RESPONSIBILITY_ID = '||to_char(l_resp_id),
21635       p_msg_type        => 'DEBUG');
21636 
21637     AMS_Utility_PVT.Create_Log (
21638       x_return_status   => l_return_status,
21639       p_arc_log_used_by => 'IMPH',
21640       p_log_used_by_id  => l_import_list_header_id,
21641       p_msg_data        => 'VENDOR_ID = '||to_char(l_VENDOR_ID),
21642       p_msg_type        => 'DEBUG');
21643 
21644     AMS_Utility_PVT.Create_Log (
21645       x_return_status   => l_return_status,
21646       p_arc_log_used_by => 'IMPH',
21647       p_log_used_by_id  => l_import_list_header_id,
21648       p_msg_data        => 'LANGUAGE_ENCODING = '||l_LANGUAGE_ENCODING,
21649       p_msg_type        => 'DEBUG');
21650 /*
21651    update ams_hz_b2b_mapping_v
21652       set CUSTOM_PROCESSING_STATUS = 'pre-processing'
21653    where import_list_header_id = l_import_list_header_id;
21654 */
21655    return 'SUCCESS';
21656 EXCEPTION
21657     WHEN OTHERS  THEN
21658 --     ROLLBACK TO TEST_Post_sub;
21659 /*
21660      FND_MESSAGE.SET_NAME( 'AMS', 'API_DEBUG_MESSAGE' );
21661      FND_MESSAGE.SET_TOKEN( 'GENERIC_TEXT' ,SQLERRM );
21662      FND_MSG_PUB.ADD;
21663 */
21664      WF_CORE.CONTEXT('AMS_LIST_IMPORT_PUB', 'TEST_Post_sub', p_event.getEventName(), p_subscription_guid);
21665      WF_EVENT.setErrorInfo(p_event, 'ERROR');
21666 
21667      RETURN 'ERROR';
21668 
21669 end TEST_Post_sub;
21670 
21671 end AMS_ListImport_PVT;