22 Temmuz 2015 Çarşamba

20 Temmuz 2015 Pazartesi

AXAPTA - Remove or add invent reservation

You can add or remove reservation with this code which I learned from Volkan Şişman:

  
InventUpd_Reservation       invUpdReservation; 
... 
//remove 
invUpdReservation = InventUpd_Reservation::newInventDim(InventMovement::construct(invTrans,InventMovSubType::None),myInventDim,200,false);
            invUpdReservation.updateNow();

...
//add
          invUpdReservation = InventUpd_Reservation::newInventDim(InventMovement::construct(invTrans,InventMovSubType::None),myInventDim,400,false);
            invUpdReservation.updateNow();


Or:

//add
     InventUpd_Reservation::updateReserveBuffer(journalTrans, journalTrans.Qty);

//remove
     InventUpd_Reservation::updateReserveBuffer(journalTrans, abs(journalTrans.Qty)); 

Or:

//add

InventUpd_Reservation::newInventDim(InventTrans.inventMovement(true),InventTrans.inventDim(),-InventTrans.qty,true).updateNow();

AXAPTA - Post invent journal which it's form open

If you want to post a record like this, AX will not let you post, with an error about record is using by another. This code part I learned from Volkan Şişman lets to post:

InventJournalCheckPost      journalCheckPost;
JournalForm                 journalForm;

;
...
journalForm      = JournalForm::fromArgs(args);
journalCheckPost = InventJournalCheckPost::newFromForm(args,journalForm);
journalForm.runbaseMainStart();
journalCheckPost.run();
journalForm.runbaseMainEnd(journalCheckPost,false);

15 Temmuz 2015 Çarşamba

AXAPTA - Flexible joins with InventDim Table using InventDimExistsJoin macro

There is a macro to create flexible joins with InventDim table with easy:

InventDimParm       dimParm;
InventDim           dimValues,dimJoin;
;
...
//Fill fields to use join where condition
 dimvalues.wMSLocationId = inventdim.wMSLocationId;
    if (inventdim.InventSiteId)
        dimvalues.InventSiteId = inventdim.InventSiteId;
    if (inventdim.configId)
        dimvalues.configId = inventdim.configId;
 //Set
InventDimParm with fields
    dimparm.initFromInventDim(dimValues);

    while select lclInventSum
        where lclInventSum.ItemId == itemId && leftQty > 0
              #InventDimExistsJoin(lclInventSum.InventDimId,dimJoin,dimValues,dimParm)


First parameter was related InventDimId field for join tables, second is InventDim tables local alias, values go with third parameter. The last one is parameter table. There ara different usages of that table.