How to using to code import to GL journal[AX2012]
static void THK_importLedgerJournalTrans(Args _args)
{
Filename fileName = "C:\\Users\\ksiu3880\\Desktop\\GL Journal test.xlsx"; LedgerJournalId ledgerJournalId = "000425_010";
Name nameDimensionAttribute1 = "Department";
Name nameDimensionAttribute2 = "CostCenter";
Name nameDimensionAttribute3 = "ExpensePurpose"; LedgerJournalTrans_Asset ledgerJournalTrans_Asset; AxLedgerJournalTable axLedgerJournalTable;
AxLedgerJournalTrans axLedgerJournalTrans; DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage; SysExcelApplication application = SysExcelApplication::construct();
SysExcelWorkbooks workbooks = application.workbooks();
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells; COMVariantType type; TransDate transDate;
LedgerJournalACType ledgerJournalACType, ledgerJournalACTypeOffset;
MainAccountNum mainAccountNum, mainAccountNumOffset;
DimensionValue dimensionValue1, dimensionValue2, dimensionValue3;
LedgerJournalTransTxt ledgerJournalTransTxt;
CurrencyCode currencyCode;
AmountCur amountCur;
ExchRate exchRate, exchRateSecond;
InvoiceId invoiceId;
DocumentDate documentDate;
DueDate dueDate;
PaymTermId paymTermId;
AssetTransTypeJournal assetTransTypeJournal;
AssetBookIdPurchSalesInvent assetBookIdPurchSalesInvent; container con, conOffset;
int numOfDimension; int row = ; setPrefix("THK_importLedgerJournalTrans"); try
{
if (!LedgerJournalTable::checkExist(ledgerJournalId))
throw Exception::Error; workbooks.open(fileName); workbook = workbooks.item();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum();
cells = worksheet.cells(); ttsBegin; do
{
row++; print row; setPrefix(strFmt("Row %1", row)); transDate = cells.item(row, ).value().date();
mainAccountNum = strLRTrim(cells.item(row, ).value().bStr());
dimensionValue1 = strLRTrim(cells.item(row, ).value().bStr());
dimensionValue2 = strLRTrim(cells.item(row, ).value().bStr());
dimensionValue3 = strLRTrim(cells.item(row, ).value().bStr());
ledgerJournalTransTxt = strLRTrim(cells.item(row, ).value().bStr());
currencyCode = strLRTrim(cells.item(row, ).value().bStr());
amountCur = cells.item(row, ).value().double();
exchRate = cells.item(row, ).value().double();
exchRateSecond = cells.item(row, ).value().double();
invoiceId = strLRTrim(cells.item(row, ).value().bStr());
documentDate = cells.item(row, ).value().date();
dueDate = cells.item(row, ).value().date();
paymTermId = strLRTrim(cells.item(row, ).value().bStr());
assetBookIdPurchSalesInvent = strLRTrim(cells.item(row, ).value().bStr());
mainAccountNumOffset = strLRTrim(cells.item(row, ).value().bStr()); switch (strLRTrim(cells.item(row, ).value().bStr()))
{
case "Bank": ledgerJournalACType = ledgerJournalACType::Bank; break;
case "Customer": ledgerJournalACType = ledgerJournalACType::Cust; break;
case "Fixed Assets": ledgerJournalACType = ledgerJournalACType::FixedAssets; break;
case "Ledger": ledgerJournalACType = ledgerJournalACType::Ledger; break;
case "Project": ledgerJournalACType = ledgerJournalACType::Project; break;
case "Vendor": ledgerJournalACType = ledgerJournalACType::Vend; break;
default: ledgerJournalACType = ledgerJournalACType::Ledger; break;
} switch (strLRTrim(cells.item(row, ).value().bStr()))
{
case "Acquisition": assetTransTypeJournal = AssetTransTypeJournal::Acquisition; break;
case "Acquisition Adjustment": assetTransTypeJournal = AssetTransTypeJournal::AcquisitionAdj; break;
default: assetTransTypeJournal = AssetTransTypeJournal::Acquisition; break;
} switch (strLRTrim(cells.item(row, ).value().bStr()))
{
case "Bank": ledgerJournalACTypeOffset = ledgerJournalACType::Bank; break;
case "Customer": ledgerJournalACTypeOffset = ledgerJournalACType::Cust; break;
case "Fixed Assets": ledgerJournalACTypeOffset = ledgerJournalACType::FixedAssets; break;
case "Ledger": ledgerJournalACTypeOffset = ledgerJournalACType::Ledger; break;
case "Project": ledgerJournalACTypeOffset = ledgerJournalACType::Project; break;
case "Vendor": ledgerJournalACTypeOffset = ledgerJournalACType::Vend; break;
default: ledgerJournalACTypeOffset = ledgerJournalACType::Ledger; break;
} axLedgerJournalTrans = new AxLedgerJournalTrans();
con = [mainAccountNum, mainAccountNum];
conOffset = [mainAccountNumOffset, mainAccountNumOffset];
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
numOfDimension = ; if (dimensionValue1)
{
con += [nameDimensionAttribute1, dimensionValue1];
conOffset += [nameDimensionAttribute1, dimensionValue1];
numOfDimension ++; dimensionAttributeValueSetStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(nameDimensionAttribute1), dimensionValue1));
} if (dimensionValue2)
{
con += [nameDimensionAttribute2, dimensionValue2];
conOffset += [nameDimensionAttribute2, dimensionValue2];
numOfDimension ++; dimensionAttributeValueSetStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(nameDimensionAttribute2), dimensionValue2));
} if (dimensionValue3)
{
con += [nameDimensionAttribute3, dimensionValue3];
conOffset += [nameDimensionAttribute3, dimensionValue3];
numOfDimension ++; dimensionAttributeValueSetStorage.addItem(DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(nameDimensionAttribute3), dimensionValue3));
} con = conIns(con, , numOfDimension);
conOffset = conIns(conOffset, , numOfDimension); axLedgerJournalTrans.parmJournalNum(ledgerJournalId);
axLedgerJournalTrans.parmTransDate(transDate);
axLedgerJournalTrans.parmAccountType(ledgerJournalACType);
axLedgerJournalTrans.parmLedgerDimension(AxdDimensionUtil::getMultiTypeAccountId(enumNum(LedgerJournalACType), ledgerJournalACType, con));
axLedgerJournalTrans.parmTxt(ledgerJournalTransTxt);
axLedgerJournalTrans.parmCurrencyCode(currencyCode);
axLedgerJournalTrans.parmExchRate(exchRate * );
axLedgerJournalTrans.parmPaymId(num2str(exchRateSecond, , , , ));
axLedgerJournalTrans.parmInvoice(invoiceId);
axLedgerJournalTrans.parmDocumentDate(documentDate);
axLedgerJournalTrans.parmDue(dueDate);
axLedgerJournalTrans.parmPayment(paymTermId); if (ledgerJournalACType != LedgerJournalACType::Ledger)
axLedgerJournalTrans.parmDefaultDimension(dimensionAttributeValueSetStorage.save()); if (amountCur >= )
axLedgerJournalTrans.parmAmountCurDebit(amountCur);
else
axLedgerJournalTrans.parmAmountCurCredit(-amountCur); if (mainAccountNumOffset)
{
axLedgerJournalTrans.parmOffsetAccountType(ledgerJournalACTypeOffset);
axLedgerJournalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getMultiTypeAccountId(enumNum(LedgerJournalACType), ledgerJournalACTypeOffset, conOffset)); if (ledgerJournalACTypeOffset != LedgerJournalACType::Ledger)
axLedgerJournalTrans.parmOffsetDefaultDimension(dimensionAttributeValueSetStorage.save());
} axLedgerJournalTrans.save(); if (axLedgerJournalTrans.ledgerJournalTrans().isFixedAssetsTransaction())
{
ledgerJournalTrans_Asset.clear();
ledgerJournalTrans_Asset.initValue(); ledgerJournalTrans_Asset.RefRecId = axLedgerJournalTrans.ledgerJournalTrans().RecId;
ledgerJournalTrans_Asset.AssetId = axLedgerJournalTrans.ledgerJournalTrans().getAssetId();
ledgerJournalTrans_Asset.Company = axLedgerJournalTrans.ledgerJournalTrans().getAssetCompany();
ledgerJournalTrans_Asset.TransType = assetTransTypeJournal;
ledgerJournalTrans_Asset.BookId = assetBookIdPurchSalesInvent; if (!ledgerJournalTrans_Asset.validateWrite())
throw Exception::Error; ledgerJournalTrans_Asset.insert();
} type = cells.item(row + , ).value().variantType();
}
while (type != COMVariantType::VT_EMPTY); ttsCommit;
}
catch (Exception::Error)
{
} application.quit();
}
How to using to code import to GL journal[AX2012]的更多相关文章
- How to using x++ code create GL journal[AX2012]
static void FAN_GLImport(Args _args) { AxLedgerJournalTable header = new AxLedgerJournalTable(); AxL ...
- R12: Improving Performance of General Ledger and Journal Import (Doc ID 858725.1 )
In this Document Purpose Scope Details A) Database Init.ora Parameters B) Concurrent Progr ...
- spring源码分析之@ImportSelector、@Import、ImportResource工作原理分析
1. @importSelector定义: /** * Interface to be implemented by types that determine which @{@link Config ...
- Python on VS Code
install python extension Press F1, and input "ext install python". Then the icon at the le ...
- 小白的Python之路 day5 python模块详解及import本质
一.定义 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能) 本质就是.py结尾的python文件(文件名:test.py,对应的模块名:test) 包:用来从逻辑上组织模块 ...
- Spring注解之@Import
/** * Indicates one or more {@link Configuration @Configuration} classes to import. * 表示import 一个或多个 ...
- python标准库介绍——30 code 模块详解
==code 模块== ``code`` 模块提供了一些用于模拟标准交互解释器行为的函数. ``compile_command`` 与内建 ``compile`` 函数行为相似, 但它会通过测试来保证 ...
- ES6中的import与export对class操作相关用法举例
两种用法: 一.指定输出类名 // export 输出 export class App extends React.Componet { // ..code } // import 引入 impor ...
- 6 Easy Steps to Learn Naive Bayes Algorithm (with code in Python)
6 Easy Steps to Learn Naive Bayes Algorithm (with code in Python) Introduction Here’s a situation yo ...
随机推荐
- ubuntu14.04离线配置cm5.5.1
cd /opt/cm-5.5.1/具体参考http://www.aboutyun.com/thread-10852-1-1.html 离线安装:下载所需文件 http://archive.cloude ...
- Troubleshooting 'library cache: mutex X' Waits.
What is a 'library cache: mutex X' wait? The mutex feature is a mechanism to control access to in me ...
- Android——requestWindowFeature
requestWindowFeature可以设置的值有:1.DEFAULT_FEATURES:系统默认状态,一般不需要指定2.FEATURE_CONTEXT_MENU:启用ContextMenu,默认 ...
- UIButton 详解
1)创建 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 风格有如下 typedef enum { UIButt ...
- 学习总结 java 创建及其练习
创建: 打开eclipse—文件—新建—java项目—项目名称命名—点击texe-1练习下拉箭头—右击src—新建—类—设置类名称(名称设置时不要添加空格),在“想要创建哪些方法跟”下面点击:publ ...
- Android 操作系统的内存回收机制
参考 http://www.ibm.com/developerworks/cn/opensource/os-cn-android-mmry-rcycl/index.html
- CLRS:sorting in linear time O(n)
//intput array A,output array result. count array count . //all the elements is in te range of 0~k ...
- 【IHttpHandler】ASP.NET 生命周期
对由 Microsoft® Internet 信息服务 (IIS) 处理的 Microsoft® ASP.NET 页面的每个请求都会被移交到 ASP.NET HTTP 管道.HTTP 管道由一系列托管 ...
- 【IHttpHandler】了解 IHttpHandler
1 .概述 说明:HttpHandler是一个HTTP请求的真正处理中心.在HttpHandler容器中,ASP.NET Framework才调用HttpHandler的ProcessRequest成 ...
- JavaScript字符串转日期格式
var dependedVal="2005-3-4"; //根据日期字符串转换成日期 var regEx = new RegExp("\\-","gi ...