Popular Posts

Monday 26 September 2011

Transfer Journals

Transfer Journals
Transfer the journals from one warehouse to another warehouse.


static void CreateTransferJournal(Args _args)
{
    InventJournalTable      inventJournalTable;
    InventJournalTrans      inventJournalTrans;
    InventJournalCheckPost  inventJournalCheckPost;
    NumberSeq               num;
    boolean                 _throwserror=true;
    boolean                 _showinforesult=true;
    InventDim               frominventDim,ToinventDim;
    ;
    ttsbegin;

    inventJournalTable.clear();
    num                                 =   new NumberSeq();
    num                                 =   NumberSeq::newGetNum(InventParameters::numRefTransferId());
    inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));
    inventJournalTable.Description      =   "Inventory Transfer Journal";
    inventJournalTable.SystemBlocked    =   true;
    inventJournalTable.insert();
    info("Entry Inserted");
    info(strfmt("The Voucher generated is %1",inventJournalTable.JournalId));

    inventJournalTrans.clear();
    inventJournalTrans.initFromInventJournalTable(inventJournalTable);
    inventJournalTrans.ItemId            =   "1101";
    frominventDim.InventLocationId="21";
    //frominventDim.configId        = "02";
    frominventDim.inventSiteId    ="2";
    ToinventDim.InventLocationId = "34";
    ToinventDim.InventSiteId     = "3";
   // ToinventDim.configId        =  "02";
    ToinventDim                 =  InventDim::findOrCreate(ToinventDim);


    frominventDim = InventDim::findOrCreate(frominventDim);
    inventJournalTrans.InventDimId  =   frominventDim.inventDimId;
    inventJournalTrans.initFromInventTable(InventTable::find("1101"));
    inventJournalTrans.Qty               =   10;
    inventJournalTrans.ToInventDimId     =   ToinventDim.inventDimId;
    inventJournalTrans.TransDate         =   SystemDateget();
    inventJournalTrans.insert();

    inventJournalCheckPost               =  InventJournalCheckPost::newJournalCheckPost(JournalCheckpostType::Post,inventJournalTable);
    inventJournalCheckPost.parmThrowCheckFailed(_throwserror);
    inventJournalCheckPost.parmShowInfoResult(_showinforesult);
    inventJournalCheckPost.run();

    inventJournalTable.SystemBlocked    =   false;
    inventJournalTable.update();

    ttscommit;
    }

Journals posting

Posting Journals
static void Journal_Kis(Args _args)
{
    InventJournalTable      journalTable;
    InventJournalTrans      journalTrans;
    InventJournalTableData  journalTableData;
    InventJournalTransData  journalTransData;
    InventTable             inventTable;
    InventDim               inventDim;
    Counter                 cnt;
    InventJournalCheckPost journalCheckPost = new InventJournalCheckPost();
    ;

    journalTableData = JournalTableData::newTable(journalTable);
    journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
    // Init JournalTable

    journalTable.clear();

    journalTable.JournalId = journalTableData.nextJournalId();
    journalTable.JournalType = InventJournalType::LossProfit;//Movement;
    journalTable.JournalNameId =    journalTableData.journalStatic().standardJournalNameId(journalTable.JournalType);

    journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));

    // Init JournalTrans
    select firstonly inventTable where inventTable.ItemId == 'item12';
//   for(cnt=1;cnt<10;cnt++)
//   {
        journalTrans.clear();
        journalTransData.initFromJournalTable();

        journalTrans.TransDate = systemdateget() + 1 div 2;
        journalTrans.ItemId = inventTable.ItemId;
        journalTrans.Qty = 100;

        journalTrans.CostAmount = 100;

        // Dimension details

        inventDim.InventLocationId = '11';
        inventDim.InventSiteId   = '1';
        journalTrans.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;

        journalTransData.create();

  //  }

    journalTable.insert();

    // Call the static method to post the journal
    if(InventJournalCheckPost::newPostJournal(journalTable).validate())
    InventJournalCheckPost::newPostJournal(journalTable).run();

}

Monday 22 August 2011

Port Numbers in ax

AOS port numbers are essentially TCP/IP port numbers.  TCP/IP port numbers have a range from 1024 to 49151.  So in theory, you should be able to use port numbers from this range.

Another type of Ax Application Backup


There is no auto backup of application option in Dynamics AX.
In the past, I used DOS command script to do the following in the mid night when it was acceptable for AOS to be unavailable -
1) Stop the AOS
2) Delete .aoi file
3) Used Robocopy script to backup the application layer.
4) Restart AOS.
The beauty with Robocopy is - it is intelligent enough so that only those files which had its timestamp changed would be backed up.

Upgrading Ax4.0 to Ax2009 Bom error

I upgrade ax 4.0 to ax 2009.I saw item master ItemType field shows only Item,Service.But i saw in base enums itemType shows Item,Bom,Service.what should i do visible BOM on itemType lookup in item master?
Soloved This Problem
Manufacturing is a generic term for all production elements. Actually having opened it the BOM configuration is under logistics. If this is selected you should be able to see the BOM option on the item master and in inventory management. If it is selected and you still cannot see it you would need to trouble shoot the upgrade procedure as this is where the issue will lie.

Sending Mail Through X++

static void Email(Args _args)
{
    CustTable                   custTable;
    System.Text.StringBuilder   htmlTable;
    SysMailer                   mailer;
    ;

    htmlTable   = new System.Text.StringBuilder();
    htmlTable.Append(@"<Caption>Blue Company Customers");
    htmlTable.Append(@"</Caption></br>");
    htmlTable.Append("<TableBorder = 1>");
   
    while select custTable where custTable.CustGroup == '10'
    {
        htmlTable.Append("<TR ALIGN='CENTER'>");
        htmlTable.Append("<TD>");
        htmlTable.Append(custTable.AccountNum);
        htmlTable.Append("</TD>");
        htmlTable.Append("<TD>");
        htmlTable.Append(custTable.NameAlias);
        htmlTable.Append("</TD>");
        htmlTable.Append("</TR>");
    }
   
    htmlTable.Append("</TABLE>");

    mailer  = new SysMailer();
    mailer.htmlBody(htmlTable.ToString());
    mailer.subject("Automated Mail - Customers");
    mailer.fromAddress("kishorem@b2bsoftech.local");
    mailer.tos().appendAddress("chakradhar@b2bsoftech.local");
    mailer.SMTPRelayServer("192.168.4.67",87,"AXMail","1234",false);
    mailer.sendMail();
}