Pages

Banner 468 x 60px

 

Wednesday, November 22, 2017

In AX 2012 typeid should be replaced to extendedTypeStr

0 comments
In AX 2012 typeid should be replaced to extendedTypeStr :

EXAMPLE :
static void BITImportFAPostingProfile(Args _args)
{
    AssetLedger         _AssetLedger;
    AssetledgerAccounts _AssetledgerAccounts;

    FileNameFilter      filter;
    Dialog              dialog;
    DialogField         field;
    FilenameOpen        filenameOpen;

    COMVariant          COMVariant;
    COMVariantType      type;
    SysExcelApplication app;
    SysExcelWorkbooks   Workbooks;
    SysExcelWorkbook    Workbook;
    SysExcelWorksheets  Worksheets;
    SysExcelWorksheet   Worksheet;
    SysExcelCells       Cells;
    SysExcelCell        Cell;
    int                 i,j;
    #excel
    ;

    filter = ["*.xlsx","*.xls"];

    dialog = new Dialog("Choose Excel");
    // field  = dialog.addField(typeId(FilenameOpen), "File Name");         // AX 2009
    field = dialog.addField(extendedTypeStr(filenameOpen), "File Name");    // AX 2012
    dialog.run();

    if (dialog.closedOK())
    {
         app = SysExcelApplication::construct();
         Workbooks = app.Workbooks();
         COMVariant = new COMVariant();
         COMVariant.bStr(field.value());
         Workbook = Workbooks.Add(COMVariant);
         Worksheets = Workbook.worksheets();
         Worksheet = Worksheets.itemFromNum(1);
         Cells = Worksheet.Cells();

         i = 2;
         while (Cells.item(i,1).value().variantType() != COMVariantType::VT_EMPTY)
         {
             _AssetledgerAccounts.clear();
                switch (Cells.item(i, 1).value().bStr())
                {
                case "None"             : _AssetledgerAccounts.TransType = assettranstype::None; break;
                case "Acquisition"      : _AssetledgerAccounts.TransType = assettranstype::Acquisition; break;                   
                case "AcquisitionAdj"   : _AssetledgerAccounts.TransType = assettranstype::AcquisitionAdj; break;
                case "Depreciation"     : _AssetledgerAccounts.TransType = assettranstype::Depreciation; break;
                case "DepreciationAdj"  : _AssetledgerAccounts.TransType = AssetTranstype::DepreciationAdj; break;    
                case "Revaluation"      : _AssetledgerAccounts.TransType = AssetTranstype::Revaluation; break;
                case "WriteUpAdj"       : _AssetledgerAccounts.TransType = AssetTransType::WriteUpAdj; break;
                case "WriteDownAdj"     : _AssetledgerAccounts.TransType = AssetTransType::WriteDownAdj; break;
                case "DisposalSale"     : _AssetledgerAccounts.TransType = AssetTransType::DisposalSale; break;
                case "DisposalScrap"    : _AssetledgerAccounts.TransType = AssetTransType::DisposalScrap; break;
                case "NetBookValue"     : _AssetledgerAccounts.TransType = AssetTransType::NetBookValue; break;
                case "ProfitLoss"       : _AssetledgerAccounts.TransType = AssetTransType::ProfitLoss; break;
                case "AcqPriorYears"    : _AssetledgerAccounts.TransType = AssetTransType::AcqPriorYears; break;
                case "AcqThisYear"      : _AssetledgerAccounts.TransType = AssetTransType::AcqThisYear; break;
                case "AcqAdjPriorYears" : _AssetledgerAccounts.TransType = AssetTransType::AcqAdjPriorYears;break;
                case "AcqAdjThisYear"   : _AssetledgerAccounts.TransType = AssetTransType::AcqAdjThisYear; break;
                case "DepPriorYears"    : _AssetledgerAccounts.TransType = AssetTransType::DepPriorYears; break;
                case "DepThisYear"      : _AssetledgerAccounts.TransType = AssetTransType::DepThisYear; break;
                case "DepAdjPriorYears" : _AssetledgerAccounts.TransType = AssetTransType::DepAdjPriorYears; break;
                case "DepAdjThisYear"   : _AssetledgerAccounts.TransType = AssetTransType::DepAdjThisYear; break;
                case "RevaluePriorYears": _AssetledgerAccounts.TransType = AssetTransType::RevaluePriorYears; break;
                case "RevalueThisYear"  : _AssetledgerAccounts.TransType = AssetTransType::WriteUpAdjPriorYears; break;
                case "WriteUpAdjThisYear" : _AssetledgerAccounts.TransType = AssetTransType::WriteUpAdjThisYear; break;
                case "WriteDownAdjPriorYears" : _AssetledgerAccounts.TransType = AssetTransType::WriteDownAdjPriorYears; break;
                case "WriteDownAdjThisYear" : _AssetledgerAccounts.TransType = AssetTransType::WriteDownAdjThisYear; break;
                case "CapitalReserve"   : _AssetledgerAccounts.TransType = AssetTransType::CapitalReserve; break;
                case "CapitalReserveTransfer" : _AssetledgerAccounts.TransType = assettranstype::CapitalReserveTransfer; break;
                case "ExtraordinaryDepreciation" : _AssetledgerAccounts.TransType = AssetTransType::ExtraordinaryDepreciation; break;
                case "ExtraDepPriorYears" : _AssetledgerAccounts.TransType = AssetTransType::ExtraDepPriorYears; break;
                case "ExtraDepThisYear" : _AssetledgerAccounts.TransType   = AssetTransType::ExtraDepThisYear; break;
                case "BonusDepreciation": _AssetledgerAccounts.TransType   = AssetTransType::BonusDepreciation; break;
                case "BonusDepPriorYears" : _AssetledgerAccounts.TransType  = AssetTransType::BonusDepPriorYears; break;
                case "BonusDepThisYear" : _AssetledgerAccounts.TransType = AssetTransType::BonusDepThisYear; break;
                case "DerogatoryIncrease" : _AssetledgerAccounts.TransType = AssetTransType::DerogatoryIncrease; break;
                case "DerogatoryDecrease" : _AssetledgerAccounts.TransType = AssetTransType::DerogatoryDecrease; break;
                case "DerogatoryIncreaseAllYears" : _AssetledgerAccounts.TransType = AssetTransType::DerogatoryIncreaseAllYears; break;
                case "DerogatoryDecreaseAllYears" : _AssetledgerAccounts.TransType = AssetTransType::DerogatoryDecreaseAllYears; break;
                case "AssetTransfer"    : _AssetledgerAccounts.TransType = AssetTransType::AssetTransfer; break;
                case "PreAcquisition_CZ" : _AssetledgerAccounts.TransType = AssetTransType::PreAcquisition_CZ; break;
                case "DepreciationNotCost_PL" : _AssetledgerAccounts.TransType = AssetTransType::DepreciationNotCost_PL; break;
                case "DepNotCostPriorYears_PL" : _AssetledgerAccounts.TransType = AssetTransType::DepNotCostPriorYears_PL; break;
                case "DeprNotCostThisYear_PL" : _AssetledgerAccounts.TransType = AssetTransType::DeprNotCostThisYear_PL; break;
                case "AccumulatedDepreciation_PL" : _AssetledgerAccounts.TransType = AssetTransType::AccumulatedDepreciation_PL; break;
                case "PostOffAccDepreciation_PL" : _AssetledgerAccounts.TransType = AssetTransType::PostOffAccDepreciation_PL; break;
                case "PostOffAccDeprPriorYears_PL" : _AssetledgerAccounts.TransType = AssetTransType::PostOffAccDeprPriorYears_PL; break;
                case "PostOffAccDeprThisYear_PL" : _AssetledgerAccounts.TransType = AssetTransType::PostOffAccDeprThisYear_PL; break;
                case "AccDepreciationPriorYears_PL" : _AssetledgerAccounts.TransType = AssetTransType::AccDepreciationPriorYears_PL; break;
                case "AccDepreciationThisYear_PL" : _AssetledgerAccounts.TransType = AssetTransType::AccDepreciationThisYear_PL; break;
                case "DEL_Movement_LV"  : _AssetledgerAccounts.TransType = AssetTransType::DEL_Movement_LV; break;
                case "ReductionEntryReserve_JP" : _AssetledgerAccounts.TransType = AssetTransType::ReductionEntryReserve_JP; break;
                case "ReductionEntryReserveAllocation_JP" : _AssetledgerAccounts.TransType = AssetTransType::ReductionEntryReserveAllocation_JP; break;
                case "AssetRetirementObligationInterest_JP" : _AssetledgerAccounts.TransType = AssetTransType::AssetRetirementObligationInterest_JP; break;
                default         : break;
                }
                info(strFmt("%1 %2",_AssetledgerAccounts.TransType,  Cells.item(i, 1).value().bStr()));            
            
                _AssetledgerAccounts.BookId             = Cells.item(i, 2).value().bStr();
                info(strFmt("%1 %2", _AssetledgerAccounts.BookId, Cells.item(i, 2).value().bStr()));

                switch (Cells.item(i, 3).value().bStr())
                {
                case 'Table'    : _AssetledgerAccounts.AccountCode = TablegroupAll::Table; break;
                case 'GroupId'  : _AssetledgerAccounts.AccountCode = TableGroupAll::GroupId; break;
                case 'All'      : _AssetledgerAccounts.AccountCode = TableGroupAll::All; break;
                default         : break;
                }
                info(strfmt("%1 %2",_AssetledgerAccounts.AccountCode, Cells.item(i, 3).value().bStr()));

               // _AssetledgerAccounts.AccountRelation       = Cells.item(i, 4).value().bStr();
               // info(strFmt("%1 %2", _AssetledgerAccounts.AccountRelation , Cells.item(i, 4).value().bStr()));
                _AssetledgerAccounts.LedgerDimension       = Cells.item(i, 4).value().double();
                info(strFmt("%1 %2", _AssetledgerAccounts.LedgerDimension, Cells.item(i, 4).value().double()));
                _AssetledgerAccounts.OffsetLedgerDimension       = Cells.item(i, 5).value().double();
                info(strFmt("%1 %2", _AssetledgerAccounts.OffsetLedgerDimension, Cells.item(i, 5).value().double()));

                    if(_AssetledgerAccounts.BookId != "")
                    {
                        _AssetledgerAccounts.insert();
                        i++;
                    }
         }
         info ("Success");}
}

0 comments:

A financial dimension value is based on the LAND-00013 record and has been used on a transaction. You cannot delete the LAND-00013 record AX 2012

 A financial dimension value is based on the LAND-00013 record and has been used on a  transaction. You cannot delete the LAND-00013 record ...