this i wrote on the run method
private void run()
{
CommaIo io;
Dialog dialog;
DialogField dlgFileName;
Filename csvfileName;
FileIOPermission permission;
PurchLine_IN purchLine_IN;
int recordCount = 0;
int i=0;
String20 quotaionJourId;
int strLength;
String10 offer;
AccountNum accountNum;
SalesTaker pesron;
int j;
//str City;
//str Country;
SysOperationProgress exportprogress = new SysOperationProgress();
#File
#AviFiles
try
{
exportprogress.setCaption(“Exporting quotation lines to CSV file…”);
exportprogress.setAnimation(#AviTransfer);
// Header Column
conHeader = [“SL NO “,“Card issue date”,“Sample card”,“Version”,“Product class”,“Customer”,“End customer”,“City”,“Country”,“Person”,“Part Name”,“Part Number”,“Label SIze”,“New FACELIFT”,“Model”,“SOP”,“Qty per Annum”,“Price per set”,“Approx Annual value”,“Sample Qty”,“Cust Date”,“PD Date”,“Dispatch Date”,“Offer”,“BOM Info”,””,"","",“OPeration info”,"",“Remarks”];
conSubHeader = ["","","","","","","","","","","","","","","","","","","","","","","","",“Item Name”,“Product Name”,“Item size”,“item Qty”,“operation Name”,“Operaton Description”];
dialog = new Dialog(“Exporting quotation lines”);
dialog.filenameLookupFilter([“Excel Files”,"*.csv"]);
dlgFileName = dialog.addField(extendedTypeStr(FilePath),“File Path”);
queryRun = new QueryRun(queryStr(PwC_SampleCard));
if(dialog.run())
{
csvfileName = strFmt(@"%1%2%3_%4.csv",dlgFileName.value(), “QuotationDetails”, date2str(today(),321,2,0,2,0,4),strRem(time2Str(timeNow(), TimeSeparator::Colon, TimeFormat::Hour24), “:”));
if(csvfileName)
{
permission = new FileIOPermission(csvfileName,#io_write);
permission.assert();
io = new CommaIo(csvfileName,#io_write);
io.inFieldDelimiter(’,’);
if(!io || io.status() != IO_Status::Ok)
{
throw error(“Error in opening file!”);
}
io.writeExp(conHeader);
io.writeExp(consubheader);
if(queryRun.prompt())
{
while( queryRun.next())
{
//j = 4;
custQuotationJour = queryRun.get(tableNum(CustQuotationJour));
custQuotationTrans = queryRun.get(tableNum(CustQuotationTrans));
//pwC_AdditionalBOMItems = queryRun.get(tableNum(PwC_AdditionalBOMItems));
inventtable = queryRun.get(tableNum(InventTable));
salesQuotationLine = queryRun.get(tableNum(SalesQuotationLine));
custTable = CustTable::find(custQuotationJour.InvoiceAccount);
City = dirparty::primaryPostalAddress(custtable.Party).City;
Country = dirparty::primaryPostalAddress(custtable.Party).CountryRegionId;
select WorkerSalesTaker from salesQuotationTable
where SalesQuotationTable.QuotationId == SalesQuotationLine.QuotationId;
pesron = salesQuotationTable.WorkerSalesTaker;
inventTable = InventTable::find(custQuotationTrans.ItemId);
select ItemGroupId from inventItemGroupItem
where inventItemGroupItem.ItemId == inventTable.ItemId;
i++;
quotaionJourId = custQuotationJour.QuotationId + ‘-’;
strLength = strLen(quotaionJourId);
//select * from salesQuotationLine
// where salesQuotationLine.QuotationId == custQuotationTrans.QuotationId
// && salesQuotationLine.InventTransId == custQuotationTrans.InventTransId
// join pwC_AdditionalBOMItems
// where pwC_AdditionalBOMItems.InventTransId == salesQuotationLine.InventTransId
// join pwC_OperationInfoTable
// where pwC_OperationInfoTable.QuotationId == salesQuotationLine.QuotationId
// && pwC_OperationInfoTable.InventTransId == salesQuotationLine.InventTransId;
select * from salesQuotationTable
where salesQuotationTable.QuotationId == custQuotationJour.QuotationId;
select ExternalItemID from custVendExternalItem
where custVendExternalItem.CustVendRelation == custQuotationJour.OrderAccount
&& custVendExternalItem.ModuleType == 4
&& custVendExternalItem.ItemId == inventTable.ItemId;
if(salesQuotationTable.PwC_Offer == NoYes::Yes)
{
offer = ‘Offer’;
}
else
{
offer = ‘Sample’;
}
while select * from pwC_AdditionalBOMItems
where pwC_AdditionalBOMItems.InventTransId == custQuotationTrans.InventTransId
while select * from pwC_OperationInfoTable
where pwC_OperationInfoTable.InventTransId == custQuotationTrans.InventTransId
// conQuotationData = conNull();
conQuotationData = [i, //1 sl no
custQuotationJour.QuotationDate,//2 Card issue date
custQuotationTrans.quotationDocNum(),//3 sample card
strDel(custQuotationTrans.quotationDocNum(),1,strLength),// 4 version
inventItemGroupItem.ItemGroupId,//5 product class
custQuotationJour.OrderAccount,//6 customer name
inventTable.PwC_CustName,//7 End customer
City,// 8 city
Country,// 9 country
HcmWorker::find(pesron).name(),//10 person
//salesQuotationTable.WorkerSalesTaker,// 10 person
inventTable.itemName(),// 11 part name
custVendExternalItem.ExternalItemId,// 12 Part No
salesQuotationLine.PwC_LabelDim,// 13 Label dim
salesQuotationLine.PwC_NewFaceLift,// 14 new/facelift
inventTable.PwC_ModelID,//15 model
salesQuotationLine.PwC_Sopdate,// 16 sop
salesQuotationLine.PwC_QuantityPerAnnum,// 17 Qty per annum
custQuotationTrans.SalesPrice,// 18 Price per set
salesquotationline.PwC_ApproxAnnualValueOfBusiness,// 19 Aprox annual value of Bussiness
custQuotationTrans.Qty,// 20 sample Qty
salesQuotationLine.ShippingDateRequested,// 21 Cust. Date
salesquotationline.PwC_Pddate,// 22 pd date
salesquotationline.ConfirmedDlv,// 23 Disp. Date
offer,// 24 offer/ sample
pwC_AdditionalBOMItems.ItemId,// 25 item id of bom
pwC_AdditionalBOMItems.ItemName, // 26 Item name
pwC_AdditionalBOMItems.ItemSize,// 27 item size
pwC_AdditionalBOMItems.Qty,// 28 Item qty
pwC_OperationInfoTable.OperationName,// 29 Operation Name
pwC_OperationInfoTable.OperationDescription,// 3o Operation Desc
salesquotationline.PwC_SpecialRemarks// 31 remarks
];
io.writeExp(conQuotationData);
// while select * from pwC_AdditionalBOMItems
// where pwC_AdditionalBOMItems.InventTransId == custQuotationTrans.InventTransId
// {
// conBOMItems = ["","","","","","","","","","","","","","","","","","","","","","","","",pwC_AdditionalBOMItems.ItemId,
//pwC_AdditionalBOMItems.ItemName,
//pwC_AdditionalBOMItems.ItemSize,
//pwC_AdditionalBOMItems.Qty
//];
//io.writeExp(conBOMItems);
//}
//while select * from pwC_OperationInfoTable
//where pwC_OperationInfoTable.InventTransId == custQuotationTrans.InventTransId
//{
//j++;
//conins(conBOMItems,j,
//}
}
}
CodeAccessPermission::revertAssert();
info(strFmt(“Report generated and saved. Path: %1”, csvfileName));
}
else
{
info(“Invalid file name specified!”);
}
}
}
catch(Exception::Error)
{
throw error(“Erorr in exporting journal lines.”);
}
}