Monday, 29 May 2017

import fixed assets through X++

Import Fixed Assets From Excel(with duplicate location, bookid, assetgroup) To AX

static void importAsset2(Args _args)
{
    Dialog                      dialog;
    Dialogfield                 dialogfield;

    SysExcelApplication         application;
    SysExcelWorkbooks           workBooks;
    SysExcelWorkbook            workBook;
    SysExcelWorksheets          workSheets;
    SysExcelWorksheet           workSheet;
    SysExcelCells               cells;

    AssetLocation               assetLocation;
    AssetGroup                  assetGroup;
    AssetTable                  assetTable;
    AssetBook                   assetBook;
    AssetBookTable              assetBookTable;

    AssetLocationId             location;
    AssetGroupId                assetGrp;
    AssetBookId                 assetBkId;
    AssetId                     assetId;
    Name                        name;
    AssetAcquisitionDate        assetAcqDate;
    AssetAcquisitionPrice       assetAcqPrice;
    AssetDepreciate             assetDepreciate;
    AssetServiceLife            assetServiceLife;
    AssetPostingProfile         assetPostingProfile;
    AssetStatus                 assetStatus;

    Filename                    fileName;
    COMVariantType              type;
    int                         row = 1   ;
    int                         recordcnt;
    str COMVariant2Str(COMVariant _cv, int _decimals = 0,int _characters = 0,int _separator1 = 0,int _separator2 = 0)
       {
            switch(_cv.variantType())
            {
                case (COMVariantType::VT_BSTR):
                    return _cv.bStr();
                case (COMVariantType::VT_R4):
                    return num2str(_cv.float(),_characters,_decimals, _separator1,_separator2);
                case (COMVariantType::VT_R8):
                    return num2str(_cv.double(),_characters,_decimals,_separator1,_separator2);
                case (COMVariantType::VT_DECIMAL):
                    return num2str(_cv.decimal(),_characters,_decimals, _separator1, _separator2);
                case (COMVariantType::VT_DATE):
                    return date2str(_cv.date(),123,2,1,2, 1,4);
                case (COMVariantType::VT_EMPTY):
                    return "";
                default:
                    throw error(strfmt("@SYS26908",_cv.variantType()));
            }
            return "";
        }

    application =   SysExcelApplication::construct();
    workBooks   =   application.workbooks();
    dialog      = new Dialog("FileOpen");
    dialogfield = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
    dialog.run();

    if (dialog.run())
    {
    filename = (dialogfield.value());
    }

    //fileName    =   @"C:\Users\Sandeep.Madupu\Desktop\Mine.xlsx";
    try
    {
        workBooks.open(fileName);
    }
    catch (Exception::Error)
    {
        throw error("File Cannot be opened");
    }

    workBook    =   workBooks.item(1);
    workSheets  =   workBook.worksheets();
    workSheet   =   workSheets.itemFromNum(1);
    cells       =   workSheet.cells();

    //try
    //{
    do
    {

        row++;
        location    = cells.item(row, 11).value().bStr();
        assetGrp    = cells.item(row, 1).value().bStr();
        assetBkId   = cells.item(row, 3).value().bStr();
        assetId     = cells.item(row, 2).value().bStr();
        name        = cells.item(row, 4).value().bStr();
        assetAcqDate = cells.item(row, 6).value().date();
        assetDepreciate = str2enum(assetDepreciate,cells.item(row, 10).value().bStr());
        assetStatus = str2enum(assetStatus,cells.item(row, 9).value().bstr());
        assetPostingProfile = cells.item(row, 7).value().bstr();
        assetServiceLife = cells.item(row, 8).value().double();
        assetAcqPrice   =  cells.item(row, 5).value().double();

        ttsBegin;


        select assetLocation where assetLocation.Location == location;


        select assetGroup where assetGroup.GroupId == assetGrp;


        select assetBookTable where assetBookTable.BookId == assetBkId;


        select assetTable where assetTable.AssetId == assetId;

        select assetBook where assetBook.BookId == assetBkId;



        if(assetLocation.Location)
        {
            select forupdate assetlocation where assetLocation.Location ==  location;
            ttsbegin;
            assetlocation.location = location;
            assetlocation.name     = location;
            assetlocation.Update();
            ttscommit;

        }

        else
        {
            assetlocation.clear();
            assetLocation.initValue();
            assetLocation.Location = location;
            assetLocation.Name     = location;
            assetLocation.insert();
        }
            //assetTable.Location   = assetLocation.Location;


        if(assetGroup.GroupId)
        {
            select forUpdate assetGroup where assetGroup.GroupId == assetGrp;
            ttsBegin;
            assetGroup.GroupId  =   assetGrp;
            assetGroup.Name     =   assetGrp;
            assetGroup.Location =   assetLocation.Location;
            assetGroup.Update();
            ttsCommit;

        }

        else
        {
            assetGroup.clear();
            assetGroup.initValue();
            assetGroup.GroupId  =   assetGrp;
            assetGroup.Name     =   assetGrp;
            assetGroup.Location =   assetLocation.Location;
            assetGroup.insert();

        }

        if(assetTable.AssetId)
        {

            select forUpdate assetTable where  assetTable.AssetId    == assetId;

            ttsBegin;
            assetTable.initValue();
            assetTable.AssetId  =   assetId;
            assetTable.Name     =   name;
            assetTable.AssetGroup = assetGroup.GroupId;
            assetTable.Location   = location;
            assetTable.Update();
            ttsCommit;
        }

        else
        {
            assetTable.clear();
            assetTable.initValue();
            assetTable.AssetId  =   assetId;
            assetTable.Name     =   name;
            assetTable.AssetGroup = assetGroup.GroupId;
            assetTable.Location   = location;
            assetTable.insert();
        }



        if(assetBookTable.BookId)
        {
            select forUpdate assetBookTable where assetBookTable.BookId == assetBkId;
            ttsBegin;
            assetBookTable.initValue();
            assetBookTable.BookId = assetBkId;
            assetBookTable.Description = assetBkId;
            assetBookTable.Update();
            ttsCommit;

        }
        else
        {
            assetBookTable.clear();
            assetBookTable.initValue();
            assetBookTable.BookId = assetBkId;
            assetBookTable.Description = assetBkId;
            assetBookTable.insert();
        }





       select forupdate assetBook join  assetTable  where assetBook.AssetId == assetTable.AssetId
                                                            && assetTable.AssetId == assetId
                                                            && assetBook.BookId   == assetBkId;



        if(assetBook.BookId)
        {

            ttsBegin;
            assetBook.BookId    =   assetBookTable.BookId;
            assetBook.AcquisitionDate = assetAcqDate;
            assetBook.AcquisitionPrice = assetAcqPrice;
            assetBook.ServiceLife      = assetServiceLife;
            assetBook.PostingProfile   = assetPostingProfile;
            assetBook.Status           = assetStatus;
            assetBook.Depreciation     = assetDepreciate;
            assetBook.AssetId          = assetTable.AssetId;
            //assetBook.selectForUpdate(true);
            assetBook.Update();
            ttsCommit;

    }

        else
        {
            assetBook.clear();
            select assetBookTable where assetBookTable.BookId == assetBkId;

            select assetTable where assetTable.AssetId == assetId;

            assetBook.initValue();
            assetBook.BookId    =   assetBookTable.BookId;
            assetBook.AcquisitionDate = assetAcqDate;
            assetBook.AcquisitionPrice = assetAcqPrice;
            assetBook.ServiceLife      = assetServiceLife;
            assetBook.PostingProfile   = assetPostingProfile;
            assetBook.Status           = assetStatus;
            assetBook.Depreciation     = assetDepreciate;
            assetBook.AssetId          = assetTable.AssetId;
            assetBook.insert();
        }



        ttsCommit;

        type = cells.item(row+1, 1).value().variantType();

    }
    while (type != COMVariantType::VT_EMPTY);

        application.quit();
        workbooks.close();
        info("Done");
    }



Important Links


importing general journal using DIXF
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
https://blogs.msdn.microsoft.com/axsupport/2014/07/17/importing-a-general-journal-using-data-importexport-framework-ax-2012/


TFS
--------------------------------------
https://blogs.msdn.microsoft.com/axinthefield/why-you-should-be-using-team-foundation-server-for-dynamics-ax-lifecycle-management/


Rfresh,re-read,re search
-------------------------------------------------------------------------------------------------------------------------
https://community.dynamics.com/ax/b/mafsarkhan/archive/2010/05/26/refresh-reread-research-executequery-which-one-to-use


diff between VIEW and table
-------------------------------------------------------------------------------------------------------
http://www.geekinterview.com/question_details/29308


dmf in R2 and R3
-----------------------------------------------------------------------------------------
https://us.hitachi-solutions.com/blog/data-migration-microsoft-dynamics-ax-2012-r2-r3/



dmf/dixf
--------------------------------------------------------------
http://ax2012dixf.blogspot.com/




X++ code to Read/Write Dynamics Ax data to excel
--------------------------------------------------------------------------------------------
http://learnax.blogspot.com/2010/01/x-code-to-readwrite-dynamics-ax-data-to.html

https://dynamicsaxinsight.wordpress.com/2015/03/25/ax-2012-off-the-shelf-excel-reader/



dynamicsw 365
================================================
http://axguide.blogspot.in/


Dialog Runbase Example in AX 2012
------------------------------------------------------------------------------
http://axhelper.blogspot.com/2014/02/dialog-runbase-example-in-ax-2012.html


interview questios
------------------------------------------------------------------------
http://arsalanax.blogspot.com/2012/01/dynamics-ax-technical-consultant.html



Custom AIF Service in Dynamics Ax 2012 R3 from Scratch.
--------------------------------------------------------------------------------------
http://www.tech.alirazazaidi.com/custom-aif-service-in-dynamics-ax-2012-r3-from-scratch/





How to make Relation in Extended Data Type and add 'View Details' for field on a form in AX 2012
------------------------------------------------------------------------------------------------------------------------------
http://axvuongbao.blogspot.in/2013/09/how-to-make-relation-in-extended-data_19.html




Run, Save and Email Purchase order report through X++ code
=======================================================================
http://theaxapta.blogspot.in/2015/01/run-save-and-email-purchase-order.html



passing parameters between forms in AX
-------------------------------------------------------------------------
https://calebmsdax.wordpress.com/2013/02/22/passing-parameters-between-forms-in-ax/



Add Controls to the Filter Pane
-------------------------------------------
https://msdn.microsoft.com/en-us/library/cc577231.aspx



workflow
---------------------------
http://dynamicsaxforum.blogspot.in/2014_07_01_archive.html


Custom Workflow from scratch, Dynamics Ax 2012
------------------------------------------------------
http://www.tech.alirazazaidi.com/custom-workflow-from-scratch-dynamics-ax-2012/



SSRS Reports
------------------------------------------------------------------------------------------------------
https://stoneridgesoftware.com/report-parameters-in-dynamics-ax-2012-ssrs-reports/

https://axssrsguide.wordpress.com/

https://ax2012anant.blogspot.com/2015/02/developing-ssrs-report-using-report.html

https://community.dynamics.com/ax/b/dynamics101trainingcenterax/archive/2013/09/16/developing-a-ssrs-report-using-the-report-data-provider-in-microsoft-dynamics-ax-2012

http://dynamics-resources.com/ssrs-tutorial-2/

https://community.dynamics.com/ax/b/faisalfareedaxlibrary/archive/2014/12/27/rdp-contract-ui-builder-and-controller-classes-for-ssrs-report-development







Friday, 3 February 2017

validations for date ranges(fromdate and todate) in ssrs report

validations for date ranges(fromdate and todate) in ssrs report .That date ranges are

report parameters and we will give the dates dynamically. So I want to do like this,

"fromdate "  should be less than "todate" and "todate" should be greater than

"fromdate".




 Create Contract class

[

DataContractAttribute,

SysOperationContractProcessingAttribute(classStr(SL_SimpleDateLookUIBuilder),

SysOperationDataContractProcessingMode::CreateUIBuilderForRootContractOnly),

]

class SL_SimpleDateLookContract  implements SysOperationValidatable

{

StartDate                   startDate;

EndDate                     endDate;

}

we need to create the parm method in the contract class.

2: Create parmStartDate Method

[

DataMemberAttribute(‘startDate’),

]

public StartDate parmStartDate(StartDate _fromDate = startDate)

{

startDate = _fromDate;

return startDate;

}

3: Create parmEndDate Method

[

DataMemberAttribute(‘endDate’),

]

public EndDate parmEndDate(EndDate _toDate = endDate)

{

endDate = _toDate;

return endDate;

}

4: Create Validate method

validation for check correct date

/// <summary>

/// Validates the SSRS report parameters.

/// </summary>

/// <returns>

/// true if successful; otherwise, false.

/// </returns>

public boolean validate()

{

boolean ret = true;

if (startDate && endDate

&& (startDate > endDate))

{

ret = checkFailed(“@SYS16982”);

}

return ret;

}
remove UI builder code

Wednesday, 18 January 2017

Job for List of classes which extends salesformletter

Job for List of classes which extends salesformletter:-
==================================================================================================
static void listofclasses_salesformletter(Args _args)
{
    treeNode childNode;
    treenodeIterator it;
    str properties;
    str className;
    str extend;
    str searchType = "Salesformletter";
    int x;
    treeNode t  = TreeNode::findNode('\\Classes');
    ;

    it = t.AOTiterator();
    childNode= it.next();
    while (childNode)
    {
        className = childNode.treeNodeName();
        properties = childNode.AOTgetProperties();
        extend = findProperty(properties, "Extends");

        if (extend == searchType)
        {
            info(strfmt("%1 – ExtendedDataType: %2", className,extend));
        }

        childNode= it.next();
    }

Financial Dimensions Lookup

Financial Dimensions Lookup:-
===========================================================================================


in this article, giving an example for defining the lookup for dimensions in simple way.

This example will cover only for user Defined dimensions.


For this

1)      Created a form and added two string controls.

2)      Named as

        Control: Name: Dimensionlist, Auto declaration – Yes

        Control: Name: DimValues



=============================================================================================
3)      Override the lookup method for Dimensionlist

public void lookup()

{

Query           query;

SysTableLookup  sysTableLookup;

super();

sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionAttribute), this);

sysTableLookup.addLookupfield(fieldNum(DimensionAttribute, Name));

query = new Query();

query.addDataSource(tableNum(DimensionAttribute)).

addRange(fieldNum(DimensionAttribute, Type)).

value(queryValue(DimensionAttributeType::CustomList));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

=============================================================================================

4)      Override the lookup method for DimValues

   public void lookup()

 {

   DimensionAttribute                  dimensionAttribute;

   DimensionAttributeDirCategory       dimAttributeDirCategory;

   Query                               query = new Query();

   SysTableLookup                      sysTableLookup;

   dimensionAttribute = DimensionAttribute::findByName(Dimensionlist.text());

   super();

  // Only user defined dimensions will have a financial tag category

  if (dimensionAttribute.Type == DimensionAttributeType::CustomList)

  {

  select firstonly DirCategory from dimAttributeDirCategory where   dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;

  sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), this);

  // Add name field to be shown in the lookup form.

  sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));

  sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));

  query = new Query();

  query.addDataSource(tableNum(DimensionFinancialTag)).

  addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).

  value(queryValue(dimAttributeDirCategory.DirCategory));

  sysTableLookup.parmQuery(query);

  // Perform the lookup.

  sysTableLookup.performFormLookup();

  }

  }

X++ Code to Hcm Worker Enquiry

X++ Code to Hcm Worker Enquiry


void clicked()
{
    Query                       query;
    QueryRun                    QueryRun;
    QueryBuildRange             qbr,qbr1,qbr2,qbr3,qbr4;
    QueryBuildDataSource        qbds,qbds1,qbds2,qbds3;
    HcmWorker                   hcmWorker;
    HcmEmployment               hcmEmployment;
    DirPartyTable               dirPartyTable;
    HcmPosition                 hcmPosition;
    HcmPositionDetail           hcmPositionDetail;
    HcmWorkerTitle              hcmWorkerTitle;
    HcmTitle                    hcmTitle;
    HcmWorkerDetailsView        hcmview;
    HcmEmploymentValidFrom      validFrom;
    HcmEmploymentValidTo        validto;
    ;
    super();
    delete_from DIPL_WorkerDetailsTmp;

    query = new query();
    qbds = query.addDataSource(tableNum(HcmWorker));
    qbr = qbds.addRange(fieldNum(HcmWorker,PersonnelNumber));
    qbr.value(EmployeeId.valueStr());

    qbds3 = qbds.addDataSource(tableNum(HcmEmployment));
    qbds3.relations(true);

    qbr2=qbds3.addrange(fieldnum(hcmemployment,validfrom));
    //qbr2.value(StartDate.valueStr());
    qbr2.value(queryRange(startdate.valuestr(),EndDate.valueStr()));

    qbr3 = qbds3.addrange(fieldnum(hcmemployment,employmenttype));
    qbr3.value(employmenttype.valuestr());

    qbds1 = qbds3.addDataSource(tableNum(HcmWorkerTitle));
    qbds1.relations(true);
    qbds1.addLink(fieldNum(HcmEmployment,worker),fieldNum(HcmWorkerTitle,worker));

    qbds2 = qbds1.addDataSource(tableNum(HcmTitle));
    qbds2.relations(true);
    qbr1=qbds2.addRange(fieldNum(HcmTitle,TitleId));
    qbr1.value(Designation.valueStr());

    QueryRun = new QueryRun(query);
    while(QueryRun.next())
    {
        hcmWorker       = QueryRun.get(tableNum(HcmWorker));
        hcmTitle        = QueryRun.get(tableNum(HcmTitle));
        hcmWorkerTitle  = QueryRun.get(tableNum(HcmWorkerTitle));
        hcmEmployment   = QueryRun.get(tableNum(HcmEmployment));

        DIPL_WorkerDetailsTmp.EmployeeId        = HcmWorker.PersonnelNumber;
        DIPL_WorkerDetailsTmp.Designation       = HcmTitle.TitleId;
        DIPL_WorkerDetailsTmp.Name              = HcmWorker.name();
        DIPL_WorkerDetailsTmp.EmployeeStartDate = HcmEmployment.ValidFrom;
        DIPL_WorkerDetailsTmp.EmployeeEndDate   = HcmEmployment.ValidTo;
        DIPL_WorkerDetailsTmp.WorkerType        = HcmEmployment.EmploymentType;
        DIPL_WorkerDetailsTmp.insert();
    }
    //info(strFmt("%1  %2", HcmEmployment.ValidFrom, HcmWorker.PersonnelNumber ));
        DIPL_WorkerDetailsTmp_ds.refresh();
        DIPL_WorkerDetailsTmp_ds.research();
}

X++ code to import Budget Registry entries from Excel

X++ code to import Budget Registry entries from Excel

Create a button budget transaction Line Form 

Path:-
Budgeting>>common>>Budget register entries>>All Budget register entries>>Create New Buget Reg Entry

Create a button on budget transaction Line Form

then create a class :-
class SKS_BudgetEtry
        {
     
        }

then create following methods in that Class:-

defaultDimension method:- // to get dimensions in Excel

        public DimensionDynamicAccount defaultDimension(Name  _Dim1,Name  _Dim2,Name  _Dim3,Name  _Dim4,Name  _Dim5,Name  _Dim6, MainAccountNum _mainAccountNum)
                                                     
        {
            Struct        struct = new Struct();
            container                  defDimensionCon;
            DimensionDefault           dimensionDefault=0;
            DimensionAttributeSetItem  dimAttrSetItem;
            DimensionAttribute         dimAttribute;
            int                        i;
            LedgerDimensionAccount     LedgerDim;
            ;
            if(_Dim1)
            {
                struct.add("Department", _Dim1);
            }
            if(_Dim2)
            {
                struct.add("Region", _Dim2);
            }
            if(_Dim3)
            {
                struct.add("Purpose", _Dim3);
            }
            if(_Dim4)
            {
     
                struct.add("AccountingRegion", _Dim4);
            }
            if(_Dim5)
            {
                struct.add("Product", _Dim5);
            }
              if(_Dim6)
            {
                struct.add("Vendor", _Dim6);
            }
            defDimensionCon += struct.fields();
            for (i = 1; i <= struct.fields(); i++)
            {
                defDimensionCon += struct.fieldName(i);
                defDimensionCon += struct.valueIndex(i);
            }
            if (struct.fields() &&(_Dim1||_Dim2||_Dim3||_Dim4||_Dim5||_Dim6))
            {
                dimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(defDimensionCon);
            }
            else
            {
                dimensionDefault =0;
            }
            if(_mainAccountNum)
            {
                ledgerDim         = DimensionDefaultingService::serviceCreateLedgerDimension(DimensionStorage::getDefaultAccountForMainAccountNum (_mainAccountNum), dimensionDefault);
                dimensionDefault  = DimensionAttributeValueCombination::find(ledgerDim).Recid;
            }
            return dimensionDefault;
        }


Openpath Method:- // To Open the dialog when button clicked

  public void Openpath()
        {
            Dialog dialog;
            DialogField dialogField;
            str fileName;
            dialog = new Dialog("Select file…..");
            dialogField = dialog.addField(extendedTypeStr("FileNameOpen"),"Source File");
            if (dialog.run())
            {
                fileName = dialogField.value();
            }

===================================================================
then write the below code in button clicked method:-


void clicked()
{

    #OCCRetryCount
    #AviFiles
    SysOperationProgress progress = new SysOperationProgress();
    int i;
    SysExcelApplication ExcelApplication;
    SysExcelWorkbooks workBooks;
    SysExcelWorkbook workBook;
    SysExcelWorksheets workSheets;
    SysExcelWorksheet workSheet;
    SysExcelCells cells;
    SysExcelcell cell;
    COMVariantType type;
    int row,column;
    int64 countervalue;
    Dialog dialog;
    DialogField dialogField;
    str fileName,s;
    BudgetTransactionLine budgetTransactionLineType;
    Name   AccName;

    BudgetType budgetType1;
    LedgerDimensionBudget ledgerDimensionBudget;

    BudgetTransactionLine budgetTransactionLine1,BudgetTransactionLinecount ;

    SKS_BudgetEtry       BudgetEtry =new SKS_BudgetEtry();
    SKS_ledgerMapping    ledgerMapping = new SKS_ledgerMapping();
    DimensionDynamicAccount    defaultdimension;
    SKS_BudgetEtry       budgetentry1 =new SKS_BudgetEtry();

    dialog = new Dialog("Select file…..");
    dialogField = dialog.addField(extendedTypeStr("FileNameOpen"),"Source File");
    if (dialog.run())
    {
        fileName = dialogField.value();
    }

    if (fileName)
    {
        ExcelApplication = SysExcelApplication::construct();
        workBooks = ExcelApplication.workbooks();
        try
        {
            workBooks.open(fileName);
            workBook = workBooks.item(1);
            workSheets = workBook.worksheets();
            workSheet = workSheets.itemFromNum(1);
            row = 1;

            progress.setCaption("Progress bar example…");
            progress.setAnimation(#AviUpdate);
            progress.setTotal(292);

            cells = workSheet.cells();
            type = cells.item(row+1,1).value().variantType();

            select count(RecId) from BudgetTransactionLinecount where BudgetTransactionLinecount.BudgetTransactionHeader == BudgetTransactionHeader.RecId;
            if(BudgetTransactionLinecount.RecId)
            {
                countervalue = BudgetTransactionLinecount.RecId;
            }

            while(type != COMVariantType::VT_EMPTY)
            {
                ttsBegin;
                row++;
                countervalue++;
                //info(strFmt("re%1----ved%2---cur%3",cells.item(row,4).value().bStr(),cells.item(row,5).value().bStr(),cells.item(row,6).value().double()));
                budgetTransactionLine1.clear();
                budgetTransactionLine1.Date     = cells.item(row,1).value().date();
                BudgetTransactionLine_ds.editAccountStructure(false, BudgetTransactionLine, cells.item(row,2).value().bStr());
                if(cells.item(row,2).value().bStr() =="BFIL BS")
                {
                    defaultdimension =  budgetentry1.defaultDimension("",cells.item(row,4).value().bStr(),"","","","",cells.item(row,3).value().bStr());
                }
                else
                {
                    defaultdimension =  budgetentry1.defaultDimension("",cells.item(row,4).value().bStr(),"","","",cells.item(row,5).value().bStr(),cells.item(row,3).value().bStr());
                }
                budgetTransactionLine1.LedgerDimension  = defaultdimension;
                budgetTransactionLine1.TransactionCurrencyAmount = cells.item(row,6).value().double();
                budgetTransactionLine1.BudgetType = str2enum(BudgetType,cells.item(row,7).value().bStr());
                budgetTransactionLine1.TransactionCurrency       = cells.item(row,8).value().bstr();
                budgetTransactionLine1.BudgetTransactionHeader   = BudgetTransactionHeader.RecId;
                budgetTransactionLine1.LineNumber                = int642int(countervalue);
                budgetTransactionLine1.insert();


                ttsCommit;
                progress.setText(strfmt("The value of i is %1", i));
                progress.setCount(i, 1);

                type = cells.item(row+1, 1).value().variantType();
            }

            workBooks.close();
            ExcelApplication.quit();
        }
        catch(Exception::Error)
        {
            ttsabort;
            workBooks.close();
            ExcelApplication.quit();
            throw error("File cannot be opened");
        }
    }
    else
    {
        info("File must be selected");
    }
    budgetTransactionLine_ds.executeQuery();
}


==================================================================

Note:-give the Data in excel like below

Date AccountStructure Dimension main account Values Dimension region Values DimensionVendor Values Amount Amount Type Currency
1/17/2017  BFIL BS '11101010 RO11 20,000  Expense INR
1/17/2017  BFIL BS '11101004 RO14 10,000  Revenue INR
1/17/2017  BFIL PL '41100002 RO16 '1004 30,000  Expense INR
1/17/2017  BFIL PL '41100004 RO12 '1013 30,000  Revenue INR