static void Fcc_UploadCustomerInfoCsv(Args _args)
{
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
DirPartyPostalAddressView addressView;
str accountnum,phone;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress electronicAddress;
DirPartyLocation dirpartyLocation, findDirPartyLocation;
CustTable custTable;
LogisticsPostalAddress address;
FileName fileName;
DirParty dirParty;
VendTable vendTable;
RecId partyRecId;
int Ccount;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
accountnum = conPeek(readCon,1);
phone = conPeek(readCon,3);
custTable = CustTable::find(accountnum);
select findDirPartyLocation
where findDirPartyLocation.Party == custTable.Party
&& findDirPartyLocation.IsPostalAddress == false;
partyRecId = custTable.Party;
DirParty = DirParty::constructFromPartyRecId(partyRecId);
address.clear();
address.CountryRegionId = strLRTrim(conPeek(readCon,2));
if( address.CountryRegionId != "")
{
address.Street = strLRTrim(conPeek(readCon,4));
addressView.LocationName = "Address";
addressView.IsPrimary = NoYes::Yes;
addressView.Party = partyRecId;
addressview.initFromPostalAddress(address);
DirParty = DirParty::constructFromPartyRecId(addressView.Party );
DirParty.createOrUpdatePostalAddress(addressView);
}
if (!findDirPartyLocation && accountnum != "")
{
logisticsLocation.clear();
logisticsLocation.initValue();
logisticsLocation.IsPostalAddress = NoYes::No;
logisticsLocation.insert();
electronicAddress.Description = "Customer phone Number";
electronicAddress.Location = logisticsLocation.RecId;
electronicAddress.Locator = phone;
electronicAddress.Type = LogisticsElectronicAddressMethodType::Phone;
electronicAddress.IsPrimary = NoYes::Yes;
electronicAddress.insert();
dirpartyLocation.Location = logisticsLocation.RecId;
dirpartyLocation.Party = custTable.Party;
dirpartyLocation.IsPrimary = NoYes::Yes;
dirpartyLocation.IsLocationOwner = NoYes::Yes;
dirpartyLocation.IsPostalAddress = NoYes::No;
dirpartyLocation.insert();
icount++;
}
}
}
ttsCommit;
info(strFmt(" No of Records updated is %1",icount));
}
}
static void Fcc_UploadCustomerInfoCsv(Args _args)
{
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
str accountnum,phone;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress electronicAddress;
DirPartyLocation dirpartyLocation, findDirPartyLocation;
CustTable custTable;
FileName fileName;
VendTable vendTable;
int Ccount;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
accountnum = conPeek(readCon,1);
phone = conPeek(readCon,2);
custTable = CustTable::find(accountnum);
select findDirPartyLocation
where findDirPartyLocation.Party == custTable.Party
&& findDirPartyLocation.IsPostalAddress == false;
if (!findDirPartyLocation && accountnum != "")
{
logisticsLocation.clear();
logisticsLocation.initValue();
logisticsLocation.IsPostalAddress = NoYes::No;
logisticsLocation.insert();
electronicAddress.Description = "Customer phone Number";
electronicAddress.Location = logisticsLocation.RecId;
electronicAddress.Locator = phone;
electronicAddress.Type = LogisticsElectronicAddressMethodType::Phone;
electronicAddress.IsPrimary = NoYes::Yes;
electronicAddress.insert();
dirpartyLocation.Location = logisticsLocation.RecId;
dirpartyLocation.Party = custTable.Party;
dirpartyLocation.IsPrimary = NoYes::Yes;
dirpartyLocation.IsLocationOwner = NoYes::Yes;
dirpartyLocation.IsPostalAddress = NoYes::No;
dirpartyLocation.insert();
icount++;
}
}
}
ttsCommit;
info(strFmt(" No of Records updated is %1",icount));
}
}
{
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
DirPartyPostalAddressView addressView;
str accountnum,phone;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress electronicAddress;
DirPartyLocation dirpartyLocation, findDirPartyLocation;
CustTable custTable;
LogisticsPostalAddress address;
FileName fileName;
DirParty dirParty;
VendTable vendTable;
RecId partyRecId;
int Ccount;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
accountnum = conPeek(readCon,1);
phone = conPeek(readCon,3);
custTable = CustTable::find(accountnum);
select findDirPartyLocation
where findDirPartyLocation.Party == custTable.Party
&& findDirPartyLocation.IsPostalAddress == false;
partyRecId = custTable.Party;
DirParty = DirParty::constructFromPartyRecId(partyRecId);
address.clear();
address.CountryRegionId = strLRTrim(conPeek(readCon,2));
if( address.CountryRegionId != "")
{
address.Street = strLRTrim(conPeek(readCon,4));
addressView.LocationName = "Address";
addressView.IsPrimary = NoYes::Yes;
addressView.Party = partyRecId;
addressview.initFromPostalAddress(address);
DirParty = DirParty::constructFromPartyRecId(addressView.Party );
DirParty.createOrUpdatePostalAddress(addressView);
}
if (!findDirPartyLocation && accountnum != "")
{
logisticsLocation.clear();
logisticsLocation.initValue();
logisticsLocation.IsPostalAddress = NoYes::No;
logisticsLocation.insert();
electronicAddress.Description = "Customer phone Number";
electronicAddress.Location = logisticsLocation.RecId;
electronicAddress.Locator = phone;
electronicAddress.Type = LogisticsElectronicAddressMethodType::Phone;
electronicAddress.IsPrimary = NoYes::Yes;
electronicAddress.insert();
dirpartyLocation.Location = logisticsLocation.RecId;
dirpartyLocation.Party = custTable.Party;
dirpartyLocation.IsPrimary = NoYes::Yes;
dirpartyLocation.IsLocationOwner = NoYes::Yes;
dirpartyLocation.IsPostalAddress = NoYes::No;
dirpartyLocation.insert();
icount++;
}
}
}
ttsCommit;
info(strFmt(" No of Records updated is %1",icount));
}
}
static void Fcc_UploadCustomerInfoCsv(Args _args)
{
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
str accountnum,phone;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress electronicAddress;
DirPartyLocation dirpartyLocation, findDirPartyLocation;
CustTable custTable;
FileName fileName;
VendTable vendTable;
int Ccount;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
accountnum = conPeek(readCon,1);
phone = conPeek(readCon,2);
custTable = CustTable::find(accountnum);
select findDirPartyLocation
where findDirPartyLocation.Party == custTable.Party
&& findDirPartyLocation.IsPostalAddress == false;
if (!findDirPartyLocation && accountnum != "")
{
logisticsLocation.clear();
logisticsLocation.initValue();
logisticsLocation.IsPostalAddress = NoYes::No;
logisticsLocation.insert();
electronicAddress.Description = "Customer phone Number";
electronicAddress.Location = logisticsLocation.RecId;
electronicAddress.Locator = phone;
electronicAddress.Type = LogisticsElectronicAddressMethodType::Phone;
electronicAddress.IsPrimary = NoYes::Yes;
electronicAddress.insert();
dirpartyLocation.Location = logisticsLocation.RecId;
dirpartyLocation.Party = custTable.Party;
dirpartyLocation.IsPrimary = NoYes::Yes;
dirpartyLocation.IsLocationOwner = NoYes::Yes;
dirpartyLocation.IsPostalAddress = NoYes::No;
dirpartyLocation.insert();
icount++;
}
}
}
ttsCommit;
info(strFmt(" No of Records updated is %1",icount));
}
}
No comments:
Post a Comment