Sunday, March 2, 2014

X++ code to create Production Report as finished Journal in AX 2012

static void ProductionReportAsFinishedJournal(Args _args)
{
    Struct struct = new Struct();
    DimensionDefault    DimensionDefault;
    container  ledgerDimensions;
    DimensionDynamicAccount     offsetDimensions;
    Args    args;
    container ledgerDimension;
    InventDim   inventDim;
    ProdJournalRoute    prodJOurnalRoute;
    AxProdJournalTable  header = new axProdJournalTable();
    ProdJournalProd prodJournalProd;
    ProdRoute       prodRoute;
    ProdRouteJob    prodRouteJob;
    ProdBOM         prodBom;
    ProdTable       prodTable;
    InventTable     inventTable;

    header.parmprodId("PRD_00004667");
    header.parmJournalNameId("Finish");
    header.save();

    prodJournalProd.JournalId = header.prodJournalTable().JournalId;
    prodJournalProd.ProdId = "PRD_00004667";
    prodJournalProd.QtyGood = 2;
    prodJournalProd.QtyError = 1;
    prodJournalProd.ErrorCause = ProdErrorCause::Machine;
    prodJournalProd.TransDate = today();
    select prodTable where prodTable.ProdId == "PRD_00004667"
        join prodBom where prodbom.ProdId == prodTable.ProdId
        join inventTable where inventTable.ItemId == prodTable.ItemId;
    prodJournalProd.InventTransId = prodBom.InventTransId;
    prodJournalProd.ItemId = prodTable.ItemId;
    prodJournalProd.InventDimId = prodTable.InventDimId;
    prodJournalProd.PmfProductType = inventTable.PmfProductType;
    prodJournalProd.insert();


}

6 comments:

  1. Seems not function, I can't view the journal in the form.

    ReplyDelete
    Replies
    1. Can you sent corrected code

      Delete
    2. hello,
      journal not showing in the form and a number sequence error is being triggered when I try to access the lines.

      Delete
    3. Is there any code snippet to complete the cycle?
      Create Picking List (Without Posting)
      Create Report as Finished Journal and Route Card
      Post Report As Finished Journal

      Thank you

      Delete
  2. can you have code for complete the cycle?
    Create Picking List (Without Posting)
    Create Report as Finished Journal and Route Card
    Post Report As Finished Journal

    please send .
    Thank you

    ReplyDelete