Hello Everyone,
I have written a code to create a XML file and that file i am uploading to the Azure blob storage.
The file is successfully uploaded to the blob storage but the file is generating blank.
if i save the file in @"C:\\" C drive file is generating. but that's not my requirement.
I have written the following code to create XML file.
Please help me with it.
#Localcodepage
XmlNode IT_TRANSACTION, RETAILLINEITEM, TAX, DISCOUNT, itemTENDER, itemLine, itemStoreId, itemTAX, itemDiscount;
XmlNode newNode;
XmlAttribute newNodeAttribute;
XmlAttribute secondNodeAttribute;
XmlDocument doc;
XmlElement nodeXmlRetailLineItem, nodeXmlTaxLineItems, nodeXmlDiscountItems, nodeXmlTender, nodeXmlTax;
XmlElement nodeIT_Transactions, nodeLineData, nodeTaxData, nodeDiscount, nodeTenderData;
PwcIntegSAPSalesExportStaging sapSalesExportStaging ,sapSalesExportStagingTrans, stagingLoc;
RetailTransactionPaymentTrans transactionPaymentTrans;
AsciiStreamIo file;
str fileContent;
const str filename = 'RetailSales.xml';
CommaStreamIo io = CommaStreamIo::constructForWrite();
doc = XmlDocument::newBlank();
newNode = doc.createElement("ABC");
newNodeAttribute = doc.CreateAttribute("xmlns:");
newNodeAttribute.Value("XYZ");
newNode.attributes().setNamedItem(newNodeAttribute);
doc.appendChild(newNode);
// IT_TRANSACTION tag initiated
IT_TRANSACTION = doc.createElement("IT_TRANSACTION");
newNode.appendChild(IT_TRANSACTION);
while select sapSalesExportStaging group by sapSalesExportStaging.RETAILSTOREID
where sapSalesExportStaging.FileCreated == NoYes::No
{
select * from stagingLoc
where stagingLoc.RETAILSTOREID == sapSalesExportStaging.RETAILSTOREID;
// item tag initiated
itemStoreId = doc.createElement("item");
IT_TRANSACTION.appendChild(itemStoreId);
// Fetching retail strore header data
itemStoreId.appendChild(doc.createElement("RETAILSTOREID")).appendChild(doc.createTextNode(stagingLoc.RETAILSTOREID));
itemStoreId.appendChild(doc.createElement("BUSINESSDAYDATE")).appendChild(doc.createTextNode(stagingLoc.BUSINESSDAYDATE));
itemStoreId.appendChild(doc.createElement("TRANSTYPECODE")).appendChild(doc.createTextNode(stagingLoc.TRANSTYPECODE));
itemStoreId.appendChild(doc.createElement("WORKSTATIONID")).appendChild(doc.createTextNode(stagingLoc.WORKSTATIONID));
itemStoreId.appendChild(doc.createElement("TRANSNUMBER")).appendChild(doc.createTextNode(stagingLoc.TRANSNUMBER));
itemStoreId.appendChild(doc.createElement("BEGINTIMESTAMP")).appendChild(doc.createTextNode(stagingLoc.BEGINTIMESTAMP));
itemStoreId.appendChild(doc.createElement("ENDTIMESTAMP")).appendChild(doc.createTextNode(stagingLoc.ENDTIMESTAMP));
itemStoreId.appendChild(doc.createElement("DEPARTMENT")).appendChild(doc.createTextNode(stagingLoc.DEPARTMENT));
itemStoreId.appendChild(doc.createElement("OPERATORID")).appendChild(doc.createTextNode(stagingLoc.OPERATORID));
itemStoreId.appendChild(doc.createElement("TRANSCURRENCY")).appendChild(doc.createTextNode(stagingLoc.TRANSCURRENCY));
// Retail line item node initiated
nodeXmlRetailLineItem = itemStoreId.appendChild(doc.createElement("RETAILLINEITEM"));
// Tender node initiated
nodeXmlTender = itemStoreId.appendChild(doc.createElement("TENDER"));
while select sapSalesExportStagingTrans
where sapSalesExportStagingTrans.RETAILSTOREID == sapSalesExportStaging.RETAILSTOREID
{
// Tag item initiated for line data
itemLine = doc.createElement("item");
nodeXmlRetailLineItem.appendChild(itemLine);
// Fetching line data
itemLine.appendChild(doc.createElement("RETAILNUMBER")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_RetailNumber));
itemLine.appendChild(doc.createElement("RETAILTYPECODE")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_RetailTypeCode));
itemLine.appendChild(doc.createElement("ITEMIDQUALIFIER")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_ItemIdQualifier));
itemLine.appendChild(doc.createElement("ITEMID")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_ItemId));
itemLine.appendChild(doc.createElement("RETAILQUANTITY")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_RetailQuantity));
itemLine.appendChild(doc.createElement("SALESUOM")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_SalesUOM));
itemLine.appendChild(doc.createElement("SALESAMOUNT")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_SalesAmount));
itemLine.appendChild(doc.createElement("NORMALSALESAMT")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Line_NormalSalesAmt));
// Tax node initiated
nodeXmlTax = itemLine.appendChild(doc.createElement("TAX"));
// Tag item initiated for tax data
itemTax = doc.createElement("item");
nodeXmlTax.appendChild(itemTax);
// Fetching tax data
itemTAX.appendChild(doc.createElement("TAXNUMBER")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Tax_Taxnumber));
itemTAX.appendChild(doc.createElement("TAXTYPECODE")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Tax_TaxTypeCode));
itemTAX.appendChild(doc.createElement("TAXAMOUNT")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Tax_TaxAmount));
// discount node initiated
nodeXmlDiscountItems = itemLine.appendChild(doc.createElement("DISCOUNT"));
// Tag item initiated for discount data
itemDiscount = doc.createElement("item");
nodeXmlDiscountItems.appendChild(itemDiscount);
// Fetching discount data
itemDiscount.appendChild(doc.createElement("DISCNUMBER")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Discount_DiscNumber));
itemDiscount.appendChild(doc.createElement("DISCTYPECODE")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Discount_DiscTypeCode));
itemDiscount.appendChild(doc.createElement("REDUCTIONAMOUNT")).appendChild(doc.createTextNode(sapSalesExportStagingTrans.Discount_ReductionAmount));
select firstonly transactionPaymentTrans
where transactionPaymentTrans.Store == stagingLoc.RETAILSTOREID
&& transactionPaymentTrans.lineNum == any2Int(sapSalesExportStagingTrans.Line_RetailNumber);
// Tag item initiated for tender
itemTENDER = doc.createElement("item");
nodeXmlTender.appendChild(itemTENDER);
// Fetching tender data
itemTENDER.appendChild(doc.createElement("TENDERNUMBER")).appendChild(doc.createTextNode(transactionPaymentTrans.receiptId));
itemTENDER.appendChild(doc.createElement("TENDERTYPECODE")).appendChild(doc.createTextNode(transactionPaymentTrans.tenderType));
itemTENDER.appendChild(doc.createElement("TENDERAMOUNT")).appendChild(doc.createTextNode(any2Str(transactionPaymentTrans.amountTendered)));
itemTENDER.appendChild(doc.createElement("TENDERCURRENCY")).appendChild(doc.createTextNode(transactionPaymentTrans.currency));
}
}
XMLWriter writer = XMLWriter::newFile(filename);
//doc.writeContentTo(writer);
doc.writeTo(writer);
System.IO.Stream stream = io.getStream();
stream.Position = 0;
System.IO.StreamReader sReader = new System.IO.StreamReader(stream);
fileContent = sReader.ReadToEnd();
this.uploadFileToAzure(stream, filename);
}