Tuesday, 21 May 2013

AX2012 R2 : X++ code to create and post Inventory Movement Journal

Below is X++ code which is good to keep handy. It can be used to create and post inventory movement journals in AX 2012 R2. I have use hard coded values for illustration purpose:


        InventJournalTable              inventJournalTable;
        InventJournalTrans              inventJournalTrans;
        InventJournalNameId             inventJournalName;
        InventDim                            inventDim;
        JournalCheckPost               journalCheckPost;

        //Below code creates journal header        
        inventJournalTable.clear();
        inventJournalName =  InventJournalName::standardJournalName(InventJournalType::Movement);
        inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalName ));
        inventJournalTable.insert();

        //Below code creates journal lines
        inventJournalTrans.clear();
        inventJournalTrans.initFromInventJournalTable(inventJournalTable);
        inventJournalTrans.TransDate = systemDateGet();
        inventJournalTrans.ItemId = "MDJ0001";
        inventJournalTrans.initFromInventTable(InventTable::find("MDJ0001"));
        inventJournalTrans.Qty = 2500;
        inventDim.InventSiteId  = '12';
        inventDim.InventLocationId = '1201';
        inventDim.wMSLocationId = 'BULK-001';
        inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
        inventJournalTrans.insert();


        //The below code posts the journal
        journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
        journalCheckPost.run();





9 comments:

  1. Hi, this is great information. I do have a project that involves customizing the production picking process. We've added a new table/form to identify the production line and picking location to be used to execute the production order. What we would like to do is only pick from the designated picking location for that particular production line. Can you provide some insight?

    ReplyDelete
  2. nice,it works

    also you need to specified inventjournaltable.JournalNameId = "MJ"; otherwise it will blank thanks

    ReplyDelete
  3. can't post, error: "Items must be registered first:

    ReplyDelete
  4. My name is Leah Brown, I'm a happy woman today? I told myself that any loan lender that could change my life and that of my family after having been scammed separately by these online loan lenders, I will refer to anyone who is looking for loan for them. It gave me and my family happiness, although at first I had a hard time trusting him because of my experiences with past loan lenders, I needed a loan of $300,000.00 to start my life everywhere as single mother with 2 children, I met this honest and God fearing online loan lender Gain Credit Loan who helped me with a $300,000.00 loan, working with a loan company Good reputation. If you are in need of a loan and you are 100% sure of paying the loan please contact (gaincreditloan1@gmail.com) You can also whatsApp them at: at +44-75967-81743 (WhatsApp Only) .. and inform them Leah Brown addressed to you ..

    ReplyDelete
  5. My name is Mr. Klaus Dieter, I work for the French financial institution Crédit Mutuel with the partnership of the bank BNP Paribas, we offer you offers at an interest rate of 3% per year, to start with new projects:
    - You have unpaid debt.
    - Buying a new house.
    - buy a new car.
    - Buying a new apartment or property.
    Get personal loans, business loans.
    If you would like loans for setting up your business and project, do not hesitate to send us an email:
    bnpfinanzenhilfe@gmail.com

    Whatsapp: +4917694954827

    ReplyDelete
  6. I was searching for loan to sort out my bills& debts, then i saw comments about Blank ATM Credit Card that can be hacked to withdraw money from any ATM machines around you . I doubted thus but decided to give it a try by contacting (smithhackingcompanyltd@gmail.com} they responded with their guidelines on how the card works. I was assured that the card can withdraw $5,000 instant per day & was credited with$50,000,000.00 so i requested for one & paid the delivery fee to obtain the card, after 24 hours later, i was shock to see the UPS agent in my resident with a parcel{card} i signed and went back inside and confirmed the card work's after the agent left. This is no doubts because i have the card & has made used of the card. This hackers are USA based hackers set out to help people with financial freedom!! Contact these email if you wants to get rich with this Via: smithhackingcompanyltd@gmail.com or WhatsApp +1(360)6370612

    ReplyDelete
  7. Dear Sir / Madam

    Do you need funds to start up your own business? Do you need loan to settle your debt or pay off your bills or start a nice business? Do you need funds to finance your project? We Offers guaranteed loan services of any amount and to any part of the world for (Individuals, Companies, Realtor and Corporate Bodies) interest rate of 2% within 1 year to 50 years repayment duration period to any part of the world. We give out loans within the range of $1,000 to $100,000,000 USD. Our loans are well insured for maximum security is our priority.

    For application and more information send replies to the following

    Lender's Name: Scott Tucker
    Lender's Email: scotttuckerloanfund@gmail.com
    What app Number: +16182279611

    ReplyDelete
  8. How To Play Blackjack & Casino Site | Lucky Club Live
    Play Blackjack and Casino luckyclub.live with Lucky Club Live casino for free or real money with the biggest bonuses, biggest promotions and most important promotions of

    ReplyDelete