8 Kasım 2019 Cuma

Satınalma siparişlerini toplu aktarma | Sipariş başlığı, Dynamics Ax

Satınalma siparişleri toplu aktarma

Siparişlerin başlıklarını toplu aktarmak için aşağıdaki kodu kullanabilirsiniz.

  void MAA_Excel_PurchTable() // DRT_PasswordTable
{
    #Excel
    #AviFiles

    Dialog              dialog = new Dialog("Veri Aktarma");
    DialogField         dialogPath;
    FilenameFilter      filter = ['Excel files 2010','*.xlsx','Excel files 2003', '*.xls' ];
    FilenameOpen        filePath;
    SysExcelApplication application;
    SysExcelWorkBooks   workBooks;
    SysExcelWorkBook    workBook;
    SysExcelWorkSheets  workSheets;
    SysExcelWorkSheet   workSheet;
    SysExcelCells       cells;
    SysOperationProgress progress;
    Int                 NoofSheet,i,lastRow,sn;

    PurchTable            PurchTable;

    SysExcelRange range;

    void findLastRow(SysExcelWorkSheet _workSheet)
    {
        #define.Star('*')
        #define.Space(' ')

        ;

        range = _workSheet.cells().range(#ExcelTotalRange);

        try
        {
            range = range.find(#Star, null, #xlFormulas, #xlWhole, #xlByRows, #xlPrevious);
        }
        catch (Exception::Error)
        {
            error("@SYS59926");
        }

        if (range)
        {
            lastRow = range.row();
        }
        else
        {
            lastRow = 0;
        }
    }
    ;

    dialog.filenameLookupFilter(filter);
    dialogPath  = dialog.addField(typeid(FilenameOpen));


    if (dialog.run())
    {
        if(dialog.closedOk())
        {
            filePath            = dialogPath.value();
            application         = SysExcelApplication::construct();
            application.visible(false);
            workBooks           = application.workbooks();
            workBooks.open(filePath,0,true);

            workSheets          = workBooks.item(1).worksheets();
            noOfSheet           = worksheets.count();
            progress = new SysOperationProgress();
            progress.setCaption("Vendor Importing");
            progress.setTotal(lastRow);
            progress.setAnimation(#AviTransfer);
            setprefix("Vendor Import");

            try
            {
                For( i = 1; i <= noOfSheet; i++)
                {
                    workSheet       = workSheets.itemFromNum(i);
                    if(workSheet)
                    {
                        findLastRow(workSheet);
                        for(sn = 2;sn <= lastrow;sn++)
                        {
                            ttsbegin;
                            cells                   = workSheet.cells();
                            cells = workSheet.cells();


                            PurchTable.PurchId                 = cells.item(sn,1).value().bStr();
                            PurchTable.OrderAccount            = cells.item(sn,2).value().bStr();
                            PurchTable.InvoiceAccount          = cells.item(sn,4).value().bStr();
                            PurchTable.CurrencyCode            = cells.item(sn,5).value().bStr();
                            PurchTable.PaymMode                = cells.item(sn,10).value().bStr();
                            PurchTable.FixedDueDate            = cells.item(sn,9).value().date();
                            PurchTable.PostingProfile          = "320";
                            PurchTable.PurchPlacer             = "2524";
                            PurchTable.PurchName               = VendTable::find(PurchTable.OrderAccount).Name;
                            PurchTable.VendGroup               = VendTable::find(PurchTable.OrderAccount).VendGroup;
                            PurchTable.InventSiteId            = VendTable::find(PurchTable.OrderAccount).InventSiteId;
                            PurchTable.InventLocationId        = VendTable::find(PurchTable.OrderAccount).InventLocation;
                            PurchTable.PurchaseType            = PurchaseType::Purch;
                            PurchTable.DlvCountryRegionId      = VendTable::find(PurchTable.OrderAccount).CountryRegionId;
                            PurchTable.TaxGroup                = VendTable::find(PurchTable.OrderAccount).TaxGroup;
                            PurchTable.DeliveryAddress         = VendTable::find(PurchTable.OrderAccount).Address;
                            PurchTable.Email                   = VendTable::find(PurchTable.OrderAccount).Email;
                            PurchTable.LanguageId              = VendTable::find(PurchTable.OrderAccount).LanguageId;
                            PurchTable.DlvState                = VendTable::find(PurchTable.OrderAccount).State;
                            PurchTable.VATNum                  = VendTable::find(PurchTable.OrderAccount).VATNum;

                            PurchTable.insert();
                            info("Aktarma tamamlandı");

                            ttscommit;
                        }
                    }
                }
            }
            catch
            {
                ttsabort;
                application.quit();
            }
        }
    }
}     

Kullandığım exel şablonunu inceleyebilirsiniz. Excel Şablonu
Satırların aktarımı için bu yazıyı inceleybilirsiniz.

Hiç yorum yok:

Yorum Gönder

Total ciro

static void MAA_SalesTableTotal(Args _args) { SalesTable SalesTable; utcDateTime dateTime; dateTime ...