static void GITS_ESH_CleanupCustomer(Args _args)
{
CustTable custTable;
CustTable tmplCustTable;
DirpartyTable dirpartyTable;
DirpartyTable _dirpartyTable;
DirpartyTable tmplDirpartyTable;
Address address;
Address tmplAddress;
container c;
Integer Start, PartyStart;
TextIo io;
str fileName, FRS;
TextBuffer b;
DirPartyType DirPartyType;
ExtendedTypeId id;
NumberSeq num;
DirPartyId localDirPartyId;
AccountNum AccountNum;
// Addressing address;
CustPaymModeTable custPaymModeTable;
Name PaymName;
int recordCount;
str inLine;
boolean OK;
;
fileName = @"C:\temp\xxx.csv";
b=new Textbuffer();
io = SysLicenseCodeReadFile::openFile(fileName,’r');
c = io.read();
if (!io)
throw error(strfmt("@SYS18678",fileName));
io.inFieldDelimiter(";");
recordCount = 0;
while (io.status() == IO_Status::Ok)
{
c = io.read();
if (conlen(c) > 0)
{
AccountNum = conpeek(c,11);
OK = true;
if (OK)
if (CustTable::find(AccountNum))
{
info(strfmt("**** %1 er allerede oprettet",AccountNum));
OK = false;
}
if (OK)
{
recordCount += 1;
custTable = CustTable::find("98823560");
custTable.AccountNum = AccountNum;
custTable.Name = conpeek(c,5);
custTable.NameAlias = custTable.Name;
custTable.IdentificationNumber = conpeek(c,1);
custTable.Street = conpeek(c,6) + ‘\n’ + conpeek(c,7);
custTable.CountryRegionId = conpeek(c,8);
custTable.ZipCode = conpeek(c,9);
custTable.City = conpeek(c,10);
custTable.Phone = conpeek(c,11);
custTable.EinvoiceEANNum = conpeek(c,12);
custTable.Email = conpeek(c,13);
custTable.PartyId = ”;
custtable.PartyType = DirPartyType::Organization;
custTable.Address = Address::formatAddress(custTable.Street,custTable.ZipCode,custTable.City,custTable.CountryRegionId,custTable.State,custTable.County);
// custTable.PartyId = DirParty::createPartyFromCommon(custTable).PartyId;
if (OK)
if (!AddressZipCode::exist(custTable.ZipCode))
{
info(strfmt("**** %1: Postnummer %2 ukendt", AccountNum, custTable.ZipCode));
OK = false;
}
if (OK)
{
custTable.insert();
info(strfmt("%1 OK",AccountNum));
}
// delete_from DirpartyTable
// where DirpartyTable.PartyId == accountNum;
// dirpartyTable = DirpartyTable::find(custTable.PartyId, true);
//
// dirpartyTable.Type = DirPartyType::Organization;
// dirpartyTable.Name = custTable.Name;
// dirpartyTable.NameAlias = custTable.Name;
// dirpartyTable.LanguageId = "DK";
// dirpartyTable.PartyId = AccountNum;
//
// dirpartyTable.insert();
//
// address.AddrRecId = dirpartytable.RecId;
// address.AddrTableId = dirpartytable.TableId;
// address.Name = custTable.Name;
// address.type = addresstype::Delivery;
// address.IsPrimary = NoYes::Yes;
// address.CountryRegionId = custTable.CountryRegionId;
// address.Street = custTable.Street;
// address.ZipCode = custTable.ZipCode;
// address.City = custTable.City;
// address.Address = custTable.Address;
//
// address.insert();
}
}
}
info("finish");
}