22 Aralık 2011 Perşembe

AXAPTA invent journal

When we were working with forms we just select InventJournalName and default parameters come. At working with code we have to put our parameters (or that is the way just I can found):

    InventJournalTrans  inventJournalTrans;
    InventJournalTable  inventJournalTable;
    InventJournalName   inventJournalName;
    InventDim toInventDim;
    InventDim tempInventDimTo; 
     ;
    // Process Journal Header
    inventJournalName   = "MyJournalName"
    inventJournalTable.initValue();
    inventJournalTable.JournalId        = NumberSeq::newGetNum(InventParameters::numRefInventJournalId()).num();
    inventJournalTable.Description      = InventJournalName.Description;
    inventJournalTable.Reservation      = ItemReservation::Automatic;
    inventJournalTable.JournalType      = inventJournalType::Transfer;

    inventJournalTable.BlockUserGroupId     = inventJournalName.BlockUserGroupId;
    inventJournalTable.JournalNameId        = inventJournalName.JournalNameId;
    inventJournalTable.ApprUserGroup        = inventJournalName.ApprUserGroup;
    inventJournalTable.ApprFromSiteId       = inventJournalName.ApprFromSiteId;
    inventJournalTable.ApprFromLocationId   = inventJournalName.ApprFromLocationId;
    inventJournalTable.ApprFromWMSLocationId= inventJournalName.ApprFromWMSLocationId;
    inventJournalTable.ApprFromBatchId      = inventJournalName.ApprFromBatchId;
    inventJournalTable.ApprToSiteId         = inventJournalName.ApprToSiteId;
    inventJournalTable.ApprToLocationId     = inventJournalName.ApprToLocationId;
    inventJournalTable.ApprToWMSLocationId  = inventJournalName.ApprToWMSLocationId;
    inventJournalTable.ApprToBatchId        = inventJournalName.ApprToBatchId;
    inventJournalTable.VoucherSeqId         = inventJournalName.VoucherSeqId;

    inventJournalTable.insert();
toInventDim.clear();
toInventDim.initValue();
toInventDim.wMSLocationId = inventJournalName.ApprtoWMSLocationId;
toInventDim.InventLocationId = inventJournalName.ApprtoLocationId;
toInventDim.InventSiteId      = inventJournalName.ApprtoSiteId;


    // Process journal lines
    inventJournalTrans.initValue();
    inventjournaltrans.initFromInventJournalTable(inventJournalTable);
    inventJournalTrans.Voucher      = NumberSeq::newGetNum(InventParameters::numRefInventJournalVoucherId()).num();
    inventJournalTrans.ItemId       = "MyItem001";
    InventJournalTrans.initFromInventTable(Inventtable::find(InventJournalTrans.ItemId));
    inventJournalTrans.TransDate    = systemDateGet();
    inventJournalTrans.Qty          = -1;
    inventJournalTrans.InventDimId = tempInventDimto.inventDimId;
    // reservation check
    if (!InventMoveMent::setAutoReserving(InventJournalTrans))
    {
        inventJournalTable.delete();
        return;
    }
    inventJournalTrans.insert();

Hiç yorum yok:

Yorum Gönder