Wednesday, 25 April 2018







The default report Server Configuration ID could not be Found in the SRSServers Table in AX 2012

Hello, some time when we restore the DB we forget to note down Reporting services URL, from report server in setup of system administrator , and when we generate report we get this error.
It means you report server configuration is not valid



Then go to System Administration -> setup -> Business intelligence ->Reporting Services ->Report Servers



Now open the  : Reporting Services Configuration Manager from Program Files



for 1 and 2 :Here you will get web server URL and Report Manager URL , copy URL and Put in report server configuration form like above given.

for 3 :And for server name  -> system admin -> inquery -> Database -> database information and copy logon server name and fill server name in first form.

for 4: And then select you AOS name . and then Validate.
And run the report.


Thanks
Akshay

Friday, 20 April 2018





Export Data in .txt form without  Double Quotes(" ") string Value in ax 2012 x++



for this TextIO class is very important

static void Job29(Args _args)
{

    container c;
    TextIO myfile;

    FileIoPermission perm;
    str message;

    #define.ExampleFile(@"D:\myfile.txt")
    #define.ExampleOpenMode("w")
 
   



    // Set code access permission to help protect the use
    // of CommaIO.new
    perm = new FileIoPermission(#ExampleFile, #ExampleOpenMode);
    perm.assert();

    myfile = new TextIO(#ExampleFile, #ExampleOpenMode);



    c = [1,"aks",1.324,"Last field"];
 
    myfile.outFieldDelimiter(",");
    myfile.writeExp(c);


    // Close the code access permission.
    CodeAccessPermission::revertAssert();
}

Output




Thanks
Akshay


Lookup Field using UIBuilder in SSRS report in ax 2012




Client want to see the report color wise but in report there is only item wise.
So I have  added color in selection which must be lookup





Then add one parameter to existing contract class


[
DataMemberAttribute("EcoResColorName"),
SysOperationDisplayOrderAttribute("4")

]


public EcoResColorName parmInventColorId(EcoResColorName _inventColorId = inventColorId)
{
    inventColorId = _inventColorId;

    return inventColorId;
}


For that I create UI builder class

name the class and extends SrsReportDataContractUIBuilder

public class Aks_SRCustomLookupsUIBuilder extends SrsReportDataContractUIBuilder
{

     BOMRDPContract    BOMRDPContract;
     ItemId  itemId;


}


public void build()
{
    int i;

    BOMRDPContract = this.dataContractObject();// as BOMRDPContract;
    this.addDialogField(methodStr(BOMRDPContract, paramItemId),BOMRDPContract);
    this.addDialogField(methodStr(BOMRDPContract, paramKgs),BOMRDPContract);
    this.addDialogField(methodStr(BOMRDPContract, paramQty),BOMRDPContract);

    this.addDialogField(methodStr(BOMRDPContract, parmInventColorId),BOMRDPContract);
}

public void postBuild()
{
     DialogField dlgBomid;
     DialogField dlgColorid;

    super();


    dlgColorid = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(BOMRDPContract,parmInventColorId));

    dlgColorid.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(GOD_SRCustomLookupsUIBuilder, BomIdLookUp),this);


}

private void BomIdLookUp(FormStringControl  _formStringControl)
{
    Query query = new Query();
    QueryBuildDataSource DS;
    SysTableLookup sysTablelookup;
    QueryBuildDataSource    queryBuildDataSourceLocal,queryBuildDataSourceLocal1,queryBuildDataSourceLocal2;
    //aks
    InventDimCombination inventDimCombination;
    InventDim                     inventDim;
    //aks

    //create a table lookup

   /* DS = query.addDataSource(tableNum(EcoResColor));
    sysTablelookup = SysTableLookup::newParameters(tableNum(EcoResColor), _formStringControl);
    sysTablelookup.addLookupfield(fieldNum(EcoResColor,Name));*/




    sysTablelookup = SysTableLookup::newParameters(tableNum(inventDim), _formStringControl);
    sysTablelookup.addLookupfield(fieldNum(inventDim,InventColorId));

    DS = query.addDataSource(tableNum(inventDim));
    DS = DS.addDataSource(inventDimCombination);

    DS.addLink(fieldNum(inventDim, InventDimId),fieldNum(inventDimCombination,InventDimId));

    DS.addRange(fieldNum(inventDimCombination,ItemId)).value(BOMRDPContract.paramItemId());
    //"1120132");

    //assign the query and call lookup
    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();




}





Thanks
Akshay

Thursday, 19 April 2018


Condition between Date in ax 2012 using x++ 


Transdate   testDonedateTime ;
;

 testDonedateTime = DateTimeUtil::date(purchline.createdDateTime);
           
                if(AgreementLineQuantityCommitment.EffectiveDate <                  testDonedateTime//purchline.DeliveryDate
                && AgreementLineQuantityCommitment.ExpirationDate >testDonedateTime)
{
condition.....
}



Thanks
Akshay

Monday, 9 April 2018


Inventory Transfer Journal through Excel using X++ code in ax 2012

Hi,
This code is used to import Data from Excel. you can make excel according give sequence in below in code.


static void aks_CreateTransferJournal(Args _args)
{
    Dialog                      dialog;
    Filename                    filename;
    DialogField                 dialogFilename;
    //To filter the files while selecting
    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;
        InventJournalTable      journalTable;
    InventJournalTableData  journalTableData;
    InventJournalTrans      inventJournalTrans;
    InventDim               toInventDim,frominventDim;
    TransDate                   transDate;
    InventQtyJournal            inventQtyJournal;
    InventBatchId               inventBatchId, toinventBatchId;
    InventDimId                 inventDimId;
    InventSiteId                inventSiteId,toinventSiteId;
    WMSLocationId               wMSLocationId,towMSLocationId;
    InventLocationId            inventLocationId,toinventLocationId;
    ;
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    dialog = new dialog();
    dialog.caption("select a file");
    //dialogFilename      =   dialog.addField(typeId(FilenameOpen));
    dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
    //To filter the files while selecting
    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++;
                transDate                           = cells.item(row,1).value().date();
                itemId                             = cells.item(row,2).value().bStr();
                inventQtyJournal                    = cells.item(row,3).value().double();
               
                inventSiteId=  cells.item(row,4).value().bStr();
                inventLocationId =  cells.item(row,5).value().bStr();
                inventBatchId = cells.item(row,6).value().bStr();
                wMSLocationId = cells.item(row,7).value().bStr();
               
                toinventSiteId=  cells.item(row,8).value().bStr();
                toinventLocationId = cells.item(row,9).value().bStr();
                toinventBatchId = cells.item(row,10).value().bStr();
                towMSLocationId=  cells.item(row,11).value().bStr();
               
   
            Ttsbegin;


    inventJournalTrans.clear();
    inventJournalTrans.JournalId      = 'AKS-000021';
    inventJournalTrans.JournalType    = InventJournalType::Transfer;
    inventJournalTrans.TransDate      = transDate;
    inventJournalTrans.ItemId         = itemId;
    inventJournalTrans.Qty            = inventQtyJournal ;


   
    inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId), False, False);
   // Dimensions From which the transfer performs
    frominventDim.InventSiteId = inventSiteId;
    frominventDim.InventLocationId =inventLocationId;
    frominventDim.inventBatchId = inventBatchId;
    frominventDim.wMSLocationId = wMSLocationId;
    // Dimensions To which the transfer performs
    toInventDim.inventSiteId         = toinventSiteId;
    toInventDim.InventLocationId     =  toinventLocationId;
    toInventDim.inventBatchId = toinventBatchId;
    toInventDim.wMSLocationId = towMSLocationId;
    inventJournalTrans.InventDimId = InventDim::findOrCreate(frominventDim).inventDimId;
    inventJournalTrans.ToInventDimId = InventDim::findOrCreate(toInventDim).inventDimId;
    inventJournalTrans.insert();
   
ttsCommit;
              info(strfmt("%1",inventJournalTrans.ItemId));
        type = cells.item(row+1, 1).value().variantType();
        } while(type != COMVariantType::VT_EMPTY);


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












Wednesday, 4 April 2018





Filter in form by value.


vendopentrans-> DS-> vendtransopen -> init

public void init()
{
    QueryBuildDataSource qbds;
    QueryBuildRange qbr;
    super();




    qbds = this.query().dataSourceTable(tableNum(VendTransOpen));
    qbds.sortClear();
    qbds.addSortField(fieldNum(VendTransOpen, Aks_OnHold));
    qbr = SysQuery::findOrCreateRange(qbds, fieldNum(VendTransOpen, Aks_OnHold));
    qbr.value(queryValue('No'));

}