static void loadCSVFile(Args _args)
{
LedgerJournalTrans_Asset ledgerJournalTrans_Asset;
DimensionValue displayValue;
DimensionDisplayValue dimensionDisplayValue;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
DimensionAttributeValueSet dimensionAttributeValueSet;
str 70 transType,dates;
LedgerJournalTrans ledgerJournalTrans;
DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
Dialog dialog;
DialogField dialogFileName;
SysOperationProgress simpleProgress;
Filename filename;
FileIOPermission permission;
TextIo textIo;
container c1,c2;
#File
#avifiles
;
dialog = new Dialog("Pick the file");
dialogFileName = dialog.addField(extendedTypeStr(FilenameOpen));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
filename = dialogFileName.value();
}
//csvFile = new CommaIO(filename, 'r');
if(!filename)
{
info("Filename must be filled");
error("file name must be filled");
}
permission = new FileIOPermission(filename,#io_read);
permission.assert();
textIo = new TextIo(filename,#io_read);
textIo.inFieldDelimiter(';');///Change the Delimeter if it is , or ; etc
simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing sales data',100);
if(textIo)
{
while(textIo.status() == IO_Status::Ok)
{
c1 = textIo.read();
if (c1)
{
ledgerJournalTrans.clear();
ttsbegin;
ledgerJournalTrans.AccountType = LedgerJournalACType::FixedAssets;
dates = conPeek(c1,1);
ledgerJournalTrans.AcknowledgementDate = str2Date(dates,123);
ledgerJournalTrans.AmountCurDebit = conPeek(c1,2);
ledgerJournalTrans.Company = conPeek(c1,3);
ledgerJournalTrans.CurrencyCode = conPeek(c1,4);
ledgerJournalTrans.ExchRate = conPeek(c1,5);
ledgerJournalTrans.JournalNum = conPeek(c1,6);
///////////////////////////////////LEDGER DIMENSION/////////////////////
displayValue = conPeek(c1,7);
select * from dimensionAttributeValueCombination where dimensionAttributeValueCombination.DisplayValue == displayValue;
ledgerJournalTrans.LedgerDimension = dimensionAttributeValueCombination.RecId;
///////////////////////////////////////////////////////////////////////
ledgerJournalTrans.LineNum = conPeek(c1,8);
ledgerJournalTrans.OffsetAccountType = LedgerJournalACType::Ledger;
ledgerJournalTrans.OffsetCompany = conPeek(c1,9);
/////////////////////////OFFSETDEFAULTDIMENSION///////////////
displayValue = conPeek(c1,10);
select * from dimensionAttributeValueSetItem where dimensionAttributeValueSetItem.DisplayValue == displayValue;
ledgerJournalTrans.OffsetDefaultDimension = dimensionAttributeValueSetItem.RecId;
////////////////////////////////////////
////////////////////////////////OFSETLEDGERDIMENSION//////////////////////////
displayValue = conPeek(c1,11);
select * from dimensionAttributeValueCombination where dimensionAttributeValueCombination.DisplayValue == displayValue;
ledgerJournalTrans.OffsetLedgerDimension = dimensionAttributeValueCombination.RecId;
///////////////////////////////////////////////////////////////////////////////
ledgerJournalTrans.Price = conPeek(c1,12);
ledgerJournalTrans.Qty = conPeek(c1,13);
ledgerJournalTrans.TaxItemGroup = conPeek(c1,14);
ledgerJournalTrans.Voucher = conPeek(c1,15);
dates = conPeek(c1,16);
ledgerJournalTrans.TransDate = str2Date(dates,123);
ledgerJournalTrans.Txt = conPeek(c1,17);
ledgerJournalTrans.CurrencyCode = conPeek(c1,18);
//LedgerJournalTrans.insert();
ttscommit;
}
}
}
}
No comments:
Post a Comment