static void ledgerjournalTrans_FixedAsset(Args _args)
{
LedgerJournalTrans_Asset LedgerJournalTrans_Asset;
DimensionDisplayValue DimensionDisplayValue;
LedgerJournalTrans LedgerJournalTrans;
DimensionAttributeValueCombination DimensionAttributeValueCombination;
CommaIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
str contactperson;
str 70 TransType;
BinData binData;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr(FileNameOpen));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
filename = dfFileName.value();
}
csvFile = new CommaIO(filename, 'r');
if (csvFile)
{
readCon = csvFile.read();
ttsbegin;
while (csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
icount++;
if (readCon)
{
DimensionDisplayValue = conPeek(readCon,1);
select * from DimensionAttributeValueCombination where DimensionAttributeValueCombination.DisplayValue == DimensionDisplayValue;
select * from LedgerJournalTrans where LedgerJournalTrans.LedgerDimension == DimensionAttributeValueCombination.RecId ;
LedgerJournalTrans_Asset.clear();
select * from LedgerJournalTrans_Asset where LedgerJournalTrans_Asset.RefRecId == LedgerJournalTrans.RecId;
if(!LedgerJournalTrans_Asset)
{
ttsBegin;
LedgerJournalTrans_Asset.AssetId = DimensionDisplayValue;
LedgerJournalTrans_Asset.RefAssetID = DimensionDisplayValue;
LedgerJournalTrans_Asset.BookId = conPeek(readCon,2);
LedgerJournalTrans_Asset.Company = conPeek(readCon,3);
LedgerJournalTrans_Asset.FAQty = conPeek(readCon,4);
LedgerJournalTrans_Asset.FAUnit = conPeek(readCon,5);
LedgerJournalTrans_Asset.FAUnitPrice = conPeek(readCon,6);
TransType = conPeek(readCon,7);
if(TransType == "Acquisition")
{
LedgerJournalTrans_Asset.TransType = AssetTransTypeJournal::Acquisition;
}
else
if(TransType == "Depreciation")
{
LedgerJournalTrans_Asset.TransType = AssetTransTypeJournal::Depreciation;
}
LedgerJournalTrans_Asset.insert();
ttsCommit;
}
}
}
ttsCommit;
}
info(strfmt("%1 records inserted out of %2",inserted,icount));
}
No comments:
Post a Comment