=====================================
XmlDocument doc;
XmlElement nodeXml,Audit;
XmlElement nodeTable,BusinessUnit,AlternateId,VendorCustomFields;
XmlElement nodeAccount,name,name2,StreetAddress1,StreetAddress2,
StreetAddress3,StreetAddress4,City,State,PostalCode,Country,ContactName,
ContactPhone,ContactFax,ContactEmail,BusinessUnitID,BusinessUnitName,
Status,PaymentMethod,PaymentTerm,AlternateType,AlternateIDNbr,
CFNbr,Value,Description,CustCount,BusinessUnitCount;
XmlElement nodeName;
int count1 = 0;
CustTable custTable;
DirPartyLocation dirpartylocation;
DirPartyTable dirPartyTable,dir;
LogisticsPostalAddress logisticsPostalAddress,logisticsPostalAddressloc;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress logisticsElectronicAddress,logisticsFax,logisticsEmail;
CompanyInfo company;
#define.filename(@'C:\Temp\customerinfo.xml')
doc = XmlDocument::newBlank();
nodeXml = doc.createElement('xml');
doc.appendChild(nodeXml);
while select custTable
where custTable.Blocked == CustVendorBlocked::No
{
select dirPartyTable
where dirPartyTable.RecId == custTable.Party;
select logisticsPostalAddress
where logisticsPostalAddress.Location == dirPartyTable.PrimaryAddressLocation;
select logisticsLocation
where logisticsLocation.RecId == dirPartyTable.PrimaryAddressLocation;
count1++;
dir = DirPartyTable::findRec(custTable.Party);
logisticsElectronicAddress = LogisticsElectronicAddress::findRecId(dir.PrimaryContactPhone,true);
logisticsFax = LogisticsElectronicAddress::findRecId(dir.PrimaryContactFax);
logisticsEmail = LogisticsElectronicAddress::findRecId(dir.PrimaryContactEmail);
nodeTable = doc.createElement("customers"); nodeXml.appendChild(nodeTable);
nodeAccount = doc.createElement("CustomersAccountNumber");
nodeAccount.appendChild(doc.createTextNode(custTable.AccountNum));
nodeTable.appendChild(nodeAccount);
name = doc.createElement("Name");
name.appendChild(doc.createTextNode(dirPartyTable.Name));
nodeTable.appendChild(name);
name2 = doc.createElement("Name2");
nodeTable.appendChild(name2);
StreetAddress1 = doc.createElement("StreetAddress1");
StreetAddress1.appendChild(doc.createTextNode(logisticsPostalAddress.Street));
nodeTable.appendChild(StreetAddress1);
StreetAddress2 = doc.createElement("StreetAddress2");
nodeTable.appendChild(StreetAddress2);
StreetAddress3 = doc.createElement("StreetAddress3");
nodeTable.appendChild(StreetAddress3);
StreetAddress4 = doc.createElement("StreetAddress4");
nodeTable.appendChild(StreetAddress4);
City = doc.createElement("City");
City.appendChild(doc.createTextNode(logisticsPostalAddress.City));
nodeTable.appendChild(City);
State = doc.createElement("State-Region");
State.appendChild(doc.createTextNode(logisticsPostalAddress.state));
nodeTable.appendChild(State);
PostalCode = doc.createElement("PostalCode");
PostalCode.appendChild(doc.createTextNode(logisticsPostalAddress.ZipCode));
nodeTable.appendChild(PostalCode);
Country = doc.createElement("Country");
Country.appendChild(doc.createTextNode(logisticsPostalAddress.County));
nodeTable.appendChild(Country);
ContactName = doc.createElement("ContactName");
ContactName.appendChild(doc.createTextNode(logisticsElectronicAddress.Description));
nodeTable.appendChild(ContactName);
ContactPhone = doc.createElement("ContactPhone");
ContactPhone.appendChild(doc.createTextNode(logisticsElectronicAddress.locator));
nodeTable.appendChild(ContactPhone);
ContactFax = doc.createElement("ContactFax");
ContactFax.appendChild(doc.createTextNode(logisticsFax.locator));
nodeTable.appendChild(ContactFax);
ContactEmail = doc.createElement("ContactEmail");
ContactEmail.appendChild(doc.createTextNode(logisticsEmail.locator));
nodeTable.appendChild(ContactEmail);
BusinessUnit = doc.createElement("BusinessUnit");
nodeTable.appendChild(BusinessUnit);
BusinessUnitID = doc.createElement("BusinessUnitID");
BusinessUnitID.appendChild(doc.createTextNode(custTable.DataAreaId));
BusinessUnit.appendChild(BusinessUnitID);
BusinessUnitName = doc.createElement("BusinessUnitName");
BusinessUnitName.appendChild(doc.createTextNode(company.Name));
BusinessUnit.appendChild(BusinessUnitName);
Status = doc.createElement("Status");
Status.appendChild(doc.createTextNode("Active"));
BusinessUnit.appendChild(Status);
PaymentMethod = doc.createElement("PaymentMethod");
PaymentMethod.appendChild(doc.createTextNode(custTable.PaymMode));
BusinessUnit.appendChild(PaymentMethod);
PaymentTerm = doc.createElement("PaymentTerm");
PaymentTerm.appendChild(doc.createTextNode(custTable.PaymTermId));
BusinessUnit.appendChild(PaymentTerm);
AlternateID = doc.createElement("AlternateID");
BusinessUnit.appendChild(AlternateID);
AlternateType = doc.createElement("AlternateType");
AlternateType.appendChild(doc.createTextNode("ALT"));
AlternateID.appendChild(AlternateType);
VendorCustomFields = doc.createElement("VendorCustomFields");
BusinessUnit.appendChild(VendorCustomFields);
while select dirpartylocation
where dirpartylocation.Party == custTable.Party
{
if(dirpartylocation.PostalAddressRoles == enum2Str(LogisticsLocationRoleType::RemitTo))
{
select logisticsPostalAddressloc
where logisticsPostalAddressloc.Location == dirpartylocation.Location;
CFNbr = doc.createElement("CFNbr");
CFNbr.appendChild(doc.createTextNode("1"));
VendorCustomFields.appendChild(CFNbr);
Value = doc.createElement("Value");
Value.appendChild(doc.createTextNode(logisticsPostalAddressloc.Address));
VendorCustomFields.appendChild(Value);
Description = doc.createElement("Description");
Description.appendChild(doc.createTextNode(logisticsPostalAddressloc.Address));
VendorCustomFields.appendChild(Description);
}
}
}
output:
No comments:
Post a Comment