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]的更多相关文章

  1. How to using x++ code create GL journal[AX2012]

    static void FAN_GLImport(Args _args) { AxLedgerJournalTable header = new AxLedgerJournalTable(); AxL ...

  2. 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 ...

  3. spring源码分析之@ImportSelector、@Import、ImportResource工作原理分析

    1. @importSelector定义: /** * Interface to be implemented by types that determine which @{@link Config ...

  4. Python on VS Code

    install python extension Press F1, and input "ext install python". Then the icon at the le ...

  5. 小白的Python之路 day5 python模块详解及import本质

    一.定义 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能) 本质就是.py结尾的python文件(文件名:test.py,对应的模块名:test) 包:用来从逻辑上组织模块 ...

  6. Spring注解之@Import

    /** * Indicates one or more {@link Configuration @Configuration} classes to import. * 表示import 一个或多个 ...

  7. python标准库介绍——30 code 模块详解

    ==code 模块== ``code`` 模块提供了一些用于模拟标准交互解释器行为的函数. ``compile_command`` 与内建 ``compile`` 函数行为相似, 但它会通过测试来保证 ...

  8. ES6中的import与export对class操作相关用法举例

    两种用法: 一.指定输出类名 // export 输出 export class App extends React.Componet { // ..code } // import 引入 impor ...

  9. 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 ...

随机推荐

  1. fatal: Not a git repository (or any of the parent directories): .git

    $ git remote add origin https://github.com/heyuanchao/YouxibiClient.gitfatal: Not a git repository ( ...

  2. UIView之基础控件综合事例

    九宫格算法实现及优化 2015年11月19日 星期四 23:21 1.九宫格之初实现 要求: 1.1在主界面中,点击添加按钮就能添加商品,点击删除按钮就能删除商品; 1.2在初始化界面中,添加按钮处于 ...

  3. Integer cache

    View.findViewById采用深度遍历,找到第一个匹配的控件 Integer Cache public static void testIntegerCache() { Class cache ...

  4. HDFS Java API 常用操作

    package com.luogankun.hadoop.hdfs.api; import java.io.BufferedInputStream; import java.io.File; impo ...

  5. SparkStreaming结合Kafka使用

    spark自带的example中就有streaming结合kafka使用的案例: $SPARK_HOME/examples/src/main/scala/org/apache/spark/exampl ...

  6. http是什么?

    http HyperText Transfer Protocol 超文本传输协议,是一个应用层通信协议. 可以用wireshark抓取.

  7. jmeter随笔(29)-关于自己的jar包和beanshell的使用

    点击标题下「蓝色微信名」可快速关注 坚持的是分享,搬运的是知识,图的是大家的进步,没有收费的培训,没有虚度的吹水,喜欢就关注.转发(免费帮助更多伙伴)等来交流,想了解的知识请留言,给你带来更多价值,是 ...

  8. Unity协程(Coroutine)原理深入剖析(转载)

    记得去年6月份刚开始实习的时候,当时要我写网络层的结构,用到了协程,当时有点懵,完全不知道Unity协程的执行机制是怎么样的,只是知道函数的返回值是IEnumerator类型,函数中使用yield r ...

  9. win7下eclipse中文字显示过小

    用win7英文版系统,在eclipse里输入中文字的时候小的可怜,今天实在忍不下去了,随网上搜了搜找到了解决办法,记录下来备用. 操作步骤:打开Elcipse --点击菜单栏上的 “Windows”— ...

  10. 多线程查询FTP Server上的文件

    情形是这样的,最近做一个自动化的项目,当batch跑成功了,FTP Server上会有特定的生成文件.但是不确定是什么时候会有,大概是batch跑完了5分钟之内吧,所以在脚本里设置检查点的时候,需要每 ...