Skip to main content

IMPORTING FUNCTIONLITY in AX 2012


static void LTWeightimport(Args _args)
{

    Dialog                      dialog;
    Filename                    filename;
    DialogField                 dialogFilename;
    container                   conFilter = ["Microsoft Excel 97-2003 Worksheet (.xls)" ,"*.xlsx"];


    SysExcelApplication                 application;
    SysExcelWorkbooks                 workbooks;
    SysExcelWorkbook                   workbook;
    SysExcelWorksheets                worksheets;
    SysExcelWorksheet                  worksheet;
    SysExcelCells                              cells;
    COMVariantType                       type;
    int                                                    row=1;

    ItemId                                 itemId;                                                                                                ---- Excell First Column
    InventTable                      inventtable;                                                                                     -----The Table Which was Related in AOT
    ItemNetWeight              ItemNetWeight;                                                                             -----  1st Name
    ItemTaraWeight             ItemTaraWeight;                                                                            -----  2nd Name


    ;
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();

    dialog = new dialog();
    dialog.caption("select a file");
    dialogFilename      =   dialog.addField(typeId(FilenameOpen));
    dialog.filenameLookupFilter(conFilter);
    dialog.run();

    if(dialog.closedOk())
    {
        filename = dialogFileName.value();
    }

    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();

    do
{


        row++;
        itemId                                        = cells.item(row,1).value().bStr();                                                                           ------Excell Sheet 1st Column
        ItemNetWeight                      = cells.item(row,2).value().double();                                                                    ------ Excell Sheet 2nd Column
        ItemTaraWeight                     = cells.item(row,3).value().double();                                                                    ------ Excell Sheet 3rd Column
        inventtable.reread();
            ttsbegin;
               select forupdate inventtable
                    where inventtable.ItemId   == itemId;                               ----------  Checking Inventtable Item id to Excel Seet Item Id.
                    if(inventtable)
                    {

                        inventtable.NetWeight = ItemNetWeight;                                                                                           ------ Insert Netweight to InventTable
                        inventtable.TaraWeight = ItemTaraWeight;                                                                                          ------  Insert TaraWeight to InventTable
                        inventtable.doUpdate();
                    }


              ttscommit;
              info(strfmt("%1",inventtable.ItemId));
        type = cells.item(row+1, 1).value().variantType();
        } while(type != COMVariantType::VT_EMPTY);


    workbooks.close();
    application.quit();
    info("Operation/Processing Completed");
}

Comments

Popular posts from this blog

D365 : ENABLE AND DISABLE IN LIST PAGE

 here i have added 4 button in salesQuotationlistpage. now i need to enable/disable button according status. so i have Extensionof  of class SalesQuotationListPageInteraction and modify setButtonEnabled method by Chain of Command //list page button enable and diable in listpage interation class [ExtensionOf(classStr(SalesQuotationListPageInteraction))] final class SQTableinimathod_Extension {     protected void setButtonEnabled()     {                SalesQuotationTable SalesQuotationTable;         CustQuotationJour   CustQuotationJour;         CustQuotationConfirmJour  CustQuotationConfirmJour;               next setButtonEnabled();         SalesQuotationTable SalesQuotationTable1 = this.listPage().activeRecord(queryDataSourceStr(SalesQuotationListPage, SalesQuotationTable));         selec...

An error occurred during report data sets execution D365 For finance and operations

  Hi all, small tip. I faced this issue, when I extend the custom report in D365 for finance and operations. During development on onebox     Solution was simple, restart IIS services Restart Reporting Services. Happy Daxing.

CODE TO PDF IN AX 2012

static void Job1(Args _args) {         PurchPackingSlipController      ssrsController = new SrsReportRunController();         TradeDocumentReportContract     purchPackingSlipContract = new TradeDocumentReportContract();         SRSPrintDestinationSettings     printerSettings;         VendPackingSlipJour             VendPackingSlipJour;         Args                            args;         //select the latest record based on create date         while select VendPackingSlipJour             order by VendPackingSlipJour.createdDateTime DESC             where VendPackingSlipJour.PackingSlipId == 'LJ-01'         ...