Exporting data in (.CSV) in MS Dynamics Ax 2009
static void ExportDataToCSV(Args _args)
{
Query q;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
QueryRun qr;
CommaIO commaIO;
FileName fileName;
Pwc_PaymSchedule _paymSchedule;
SalesId _bkId;
Description _dscrp;
PaymMode _mop;
str _payRef;
DocumentDate _insDt;
CurrencyCode _insCur;
Amount _insAmt;
PwC_Sugar_Bank _bnkDet;
PwC_PaymentScheduleStatus _paymStat;
SysDate _doa;
PwC_ClearanceStatus _clrStat;
TransDate _clrDt;
Amount _clrAmt;
PwC_SugarRecordId _sugId;
;
fileName = WINAPI::getTempPath() + "PaymDetails123" + ".csv";
commaIO = new CommaIO(fileName,'W');
q = new Query();
qbds = q.addDataSource(tablenum(Pwc_PaymSchedule));
//qbr = qbds.addRange(fieldnum(Pwc_PaymSchedule,ItemId));
qr = new QueryRun(q);
commaIO.write("Sales order","Description","Method of payment","Payment ref","Instrument date","Instrument currency","Instrument amount","CRM Bank Details","Status","Date of action","Clearance Status","Clearance Date","Amount Paid","Sugar ID");
while( qr.next() )
{
_paymSchedule = qr.get(tablenum(Pwc_PaymSchedule));
_bkId = _paymSchedule.SalesId;
_dscrp = _paymSchedule.Description;
_mop = _paymSchedule.PaymMode;
_payRef = _paymSchedule.PaymReference;
_insDt = _paymSchedule.InstrumentDate;
_insCur = _paymSchedule.InstrumentCurrencyCode;
_insAmt = _paymSchedule.InstrumentAmount;
_bnkDet = _paymSchedule.BankDetails;
_paymStat = _paymSchedule.PaymentScheduleStatus;
_doa = _paymSchedule.DateOfAction;
_clrStat = _paymSchedule.ClearanceStatus;
_clrDt = _paymSchedule.ClearanceDate;
_clrAmt = _paymSchedule.ClearedAmount;
_sugId = _paymSchedule.SugarRecordId;
commaIO.write(_bkId,_dscrp,_mop,_payRef,_insDt,_insCur,_insAmt,_bnkDet,_paymStat,_doa,_clrStat,_clrDt,_clrAmt,_sugId);
}
WINAPI::shellExecute(fileName);
}
static void ExportDataToCSV(Args _args)
{
Query q;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
QueryRun qr;
CommaIO commaIO;
FileName fileName;
Pwc_PaymSchedule _paymSchedule;
SalesId _bkId;
Description _dscrp;
PaymMode _mop;
str _payRef;
DocumentDate _insDt;
CurrencyCode _insCur;
Amount _insAmt;
PwC_Sugar_Bank _bnkDet;
PwC_PaymentScheduleStatus _paymStat;
SysDate _doa;
PwC_ClearanceStatus _clrStat;
TransDate _clrDt;
Amount _clrAmt;
PwC_SugarRecordId _sugId;
;
fileName = WINAPI::getTempPath() + "PaymDetails123" + ".csv";
commaIO = new CommaIO(fileName,'W');
q = new Query();
qbds = q.addDataSource(tablenum(Pwc_PaymSchedule));
//qbr = qbds.addRange(fieldnum(Pwc_PaymSchedule,ItemId));
qr = new QueryRun(q);
commaIO.write("Sales order","Description","Method of payment","Payment ref","Instrument date","Instrument currency","Instrument amount","CRM Bank Details","Status","Date of action","Clearance Status","Clearance Date","Amount Paid","Sugar ID");
while( qr.next() )
{
_paymSchedule = qr.get(tablenum(Pwc_PaymSchedule));
_bkId = _paymSchedule.SalesId;
_dscrp = _paymSchedule.Description;
_mop = _paymSchedule.PaymMode;
_payRef = _paymSchedule.PaymReference;
_insDt = _paymSchedule.InstrumentDate;
_insCur = _paymSchedule.InstrumentCurrencyCode;
_insAmt = _paymSchedule.InstrumentAmount;
_bnkDet = _paymSchedule.BankDetails;
_paymStat = _paymSchedule.PaymentScheduleStatus;
_doa = _paymSchedule.DateOfAction;
_clrStat = _paymSchedule.ClearanceStatus;
_clrDt = _paymSchedule.ClearanceDate;
_clrAmt = _paymSchedule.ClearedAmount;
_sugId = _paymSchedule.SugarRecordId;
commaIO.write(_bkId,_dscrp,_mop,_payRef,_insDt,_insCur,_insAmt,_bnkDet,_paymStat,_doa,_clrStat,_clrDt,_clrAmt,_sugId);
}
WINAPI::shellExecute(fileName);
}
No comments:
Post a Comment