Pages

Banner 468 x 60px

 

Thursday, June 23, 2022

Export Data AX to Excel

0 comments

 static void ExportDataGeneralJournal(Args _args)

{

    SysExcelApplication     xlsApplication;

    SysExcelWorkBooks       xlsWorkBookCollection;

    SysExcelWorkBook        xlsWorkBook;

    SysExcelWorkSheets      xlsWorkSheetCollection;

    SysExcelWorkSheet       xlsWorkSheet;

    SysExcelRange           xlsRange;


    GeneralJournalEntry         jourEntry;

    GeneralJournalAccountEntry  jourAccEntry;

    FromDate                    fromDate = mkDate(1,1,2018);

    ToDate                      toDate = mkDate(31,1,2018);


    int                     row = 1;

    str                     fileName;

    ;

    //Filename

    fileName = "Document\GeneralAccEntry.xlsx";

    //Initialize Excel instance

    xlsApplication           = SysExcelApplication::construct();

    //Open Excel document

    //xlsApplication.visible(true);

    //Create Excel WorkBook and WorkSheet

    xlsWorkBookCollection    = xlsApplication.workbooks();

    xlsWorkBook              = xlsWorkBookCollection.add();

    xlsWorkSheetCollection   = xlsWorkBook.worksheets();

    xlsWorkSheet             = xlsWorkSheetCollection.itemFromNum(1);


    //Excel columns captions

    xlsWorkSheet.cells().item(row,1).value("Date");

    xlsWorkSheet.cells().item(row,2).value("Voucher");

    xlsWorkSheet.cells().item(row,3).value("PostingType");

    xlsWorkSheet.cells().item(row,4).value("LedgerAccount");

    row++;


    while select jourEntry

        join jourAccEntry

        where jourEntry.RecId == jourAccEntry.GeneralJournalEntry

           && jourEntry.AccountingDate >= fromDate

           && jourEntry.AccountingDate <= toDate

    {

        xlsWorkSheet.cells().item(row,1).value(jourEntry.AccountingDate);

        xlsWorkSheet.cells().item(row,2).value(jourEntry.SubledgerVoucher);

        xlsWorkSheet.cells().item(row,3).value(enum2str(jourAccEntry.PostingType));

        xlsWorkSheet.cells().item(row,4).value(jourAccEntry.LedgerAccount);


        row++;

    }

    info("Done");


    //Check whether the document already exists

    if(WinApi::fileExists(fileName))

        WinApi::deleteFile(fileName);

    //Save Excel document

    xlsWorkbook.saveAs(fileName);

    //Open Excel document

    xlsApplication.visible(true);

    //Close Excel

    //xlsApplication.quit();

    //xlsApplication.finalize();

}

Read more...

Sunday, June 5, 2022

Create default from date 1 Month Ago in SSRS Expression

0 comments

 DateAdd("M", -1, Today()

Read more...

Decrease Decimal in AX 2012

0 comments

 

num2str0(amount, 0, 2, 1,0) // two decimal

num2str0(amount, 0, 0, 1,0) // without decimal 

Read more...

Saturday, June 4, 2022

Get Invent Site from WareHouse and Item by Code X++

0 comments

static void OnHandOnDate(Args _args)

{

    ItemId                      itemId;

    InventDim                   inventDimCriteria;

    InventDimParm               inventDimParm;

    InventSumDatePhysicalDim    inventSumDateDim;

    InventTable                 InventTable;

    InventLocation              Inventlocation;

    ABUSnapshot                 ABUSnapshot;

    InventSiteId                inventSiteId;

    transDate                   Dated;

    ;


    while select * from 

        InventTable 

            order by itemid

            where InventTable.itemid like 'P*'

            //where InventTable.itemid == "P000005"

    {

        

        Dated = systemDateGet();

        

        while select * from 

            Inventlocation 

                order by inventlocationid

                //where Inventlocation.InventLocationId == "CNK"

                where Inventlocation.WMSLocationIdDefaultReceipt == 'Staging'

        {

            itemId                              = InventTable.ItemId;

            inventDimCriteria.InventLocationId  = Inventlocation.InventLocationId;

            inventDimCriteria.InventStatusId    = "AVAILABLE";

    

            inventDimParm.initFromInventDim(inventDimCriteria);

            //inventSumDateDim = InventSumDatePhysicalDim::newParameters(mkdate(03,06,2022), itemId, inventDimCriteria, inventDimParm);

            // Dated

            inventSumDateDim = InventSumDatePhysicalDim::newParameters(Dated, itemId, inventDimCriteria, inventDimParm);

            info(strfmt("itemid : %1 Phs: %2 Whs : %3",itemId, inventSumDateDim.physicalQuantity(), Inventlocation.InventLocationId));

            

            ttsbegin;

            ABUSnapshot.ItemId          = itemId;

            ABUSnapshot.ProductName     = EcoResProduct::find(InventTable.Product).productName();

            ABUSnapshot.WHS             = Inventlocation.InventLocationId;

            ABUSnapshot.Site            = InventLocation::find(Inventlocation.InventLocationId).InventSite().SiteId;

            ABUSnapshot.Date            = Dated;

            ABUSnapshot.DataAreaName    = curext();

            ABUSnapshot.Qty             = inventSumDateDim.physicalQuantity();

            ABUSnapshot.insert();

            

            ttsCommit;

        }

    }


}

Read more...

Saturday, February 6, 2021

Find EventInbox throught x++

0 comments

 static void ABUFindInbox(Args _args)

{

    EventInbox      EventInbox;

    PurchReqId      PurchReqId;

    str 30           paramater;

    PurchReqTable   PurchreqTable = PurchReqTable::findPurchReqId('080743');

 

    paramater  = '*PurchreqTable.PurchReqId*';    

    PurchReqId = strFmt("%1%2%3","*", PurchreqTable.PurchReqId, "*");

    

    info(strFmt('%1', PurchReqId));

    

    select firstOnly1 * from EventInbox

        where EventInbox.AlertedFor like PurchReqId;

        //where EventInbox.AlertedFor like "*080743*";

    

    info(strFmt('%1', EventInbox.Message));    

}

Read more...

Sunday, January 3, 2021

Fixed Asset ITH-DEV-4-000672, Value model Commercial, has not been set up for depreciation.

0 comments

 Fixed Asset ITH-DEV-4-000672, Value model Commercial, has not been set up for depreciation.

Solution : Checklist Depreciation



Read more...

Saturday, August 24, 2019

Event Viewer for checking Restart Maching

0 comments
Hi bro, 

I want to share how to know your machine restart through Event Viewer (Windows Server 2014).

1. Right Click in System 
2. USER32 in Event Source
3. 1074 

Click OK


Read more...

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

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH