erwinmarinax
Erwin Marin AX
3 posts
Microsoft Dynamics on my way :)
Don't wanna be here? Send us removal request.
erwinmarinax · 7 years ago
Text
Calc currentPalletCount and FreePalletCount ax 2009 x++
The following code calc the CurrentPalletCount field and the FreePalletCount field of the Location.
static void calcCurrentFreePalletCount(Args _args) {
   Counter                 currentLoad;    Counter                 reservedLoad;    Query                   query;    QueryBuildDataSource    queryBuildDataSource;    QueryBuildRange         queryBuildRange;    Args                    args;    FormRun                 formRun;    FormDataSource          formDataSource;    WMSLocationSum          wmsLocationSum;
   while select forupdate wmsLocationSum    {
       if (wmsLocationSum.LocationType == WMSLocationType::OutputPort ||        wmsLocationSum.LocationType == WMSLocationType::ProductionInput)        {            currentLoad = 0;            reservedLoad = 0;        }        else        {            currentLoad = wmsLocationSum.currentPalletCount();            reservedLoad = wmsLocationSum.reservedPalletCountCalculated();        }
       if (wmsLocationSum.CurrentPalletCount != currentLoad || wmsLocationSum.FreePalletCount != wmsLocationSum.MaxPalletCount - currentLoad - reservedLoad)        {            args = new Args();            args.name(formstr(WMSLocation));            formRun     = classfactory.formRunClass(args);            formRun.init();            formDataSource = formRun.objectSet();            formDataSource.init();            query = formDataSource.query();            queryBuildDataSource = query.dataSourceTable(tablenum(WMSLocation));            queryBuildRange = queryBuildDataSource.addRange(fieldnum(WMSLocation, wmsLocationId));            queryBuildRange.value(queryValue(wmsLocationSum.wmsLocationId));            queryBuildRange = queryBuildDataSource.addRange(fieldnum(WMSLocation, InventLocationId));            queryBuildRange.value(queryValue(wmsLocationSum.InventLocationId));
           if (wmsLocationSum.CurrentPalletCount != currentLoad)                checkFailed(strfmt("@SYS50822", wmsLocationSum.CurrentPalletCount, currentLoad),                        '', SysInfoAction_FormrunQuery::newFormnameControlnameQuery(formstr(WMSLocation), identifierstr(currentPalletCount), query));            if (wmsLocationSum.FreePalletCount != wmsLocationSum.MaxPalletCount - currentLoad - reservedLoad)                checkFailed(strfmt("@SYS58931", wmsLocationSum.FreePalletCount, wmsLocationSum.MaxPalletCount - currentLoad - reservedLoad),                        '', SysInfoAction_FormrunQuery::newFormnameControlnameQuery(formstr(WMSLocation), identifierstr(freePalletCount), query));
           if (wmsLocationSum.CurrentPalletCount != currentLoad)            {                wmsLocationSum.CurrentPalletCount = currentLoad;            }            if (wmsLocationSum.FreePalletCount != wmsLocationSum.MaxPalletCount - currentLoad - reservedLoad)            {                wmsLocationSum.FreePalletCount    = wmsLocationSum.MaxPalletCount - currentLoad - reservedLoad;            }            ttsbegin;            wmsLocationSum.update();            ttscommit;
       }    }
}
0 notes
erwinmarinax · 7 years ago
Text
Create and post inventory Transfer journal with AxInventJournalTable and AxInventJournalTrans ax x++
The following code is a static method  what enable create and post a inventory transfer journal with the standard classes AxInventJournalTable and  AxInventJournalTrans.
I added a field in the InventParameters for set by default the journal name.
public static void createJournalTransfer(    InventSum               _inventSum,    InventDim               _inventDim,    Qty                     _qtyInput,    InventSiteId            _inventSiteIdInput,    InventLocationId        _inventLocationIdInput,    InventBatchId           _inventBatchIdInput,    WMSLocationId           _wMSLocationIdInput,    WMSPalletId             _wMSPalletIdInput) {    //by ax.erwinmarin.cl    AxInventJournalTable    AxinventJournalTable = new AxinventJournalTable();    AxInventJournalTrans    AxinventJournalTrans = new AxinventJournalTrans();    InventParameters        inventParameters;    ;
   //Below code creates journal header    inventParameters = InventParameters::find();    AxinventJournalTable.parmJournalNameId(inventParameters.EMG_DefaultJournalName);    AxinventJournalTable.parmJournalType(InventJournalType::Transfer);    AxinventJournalTable.save();
   //Below code creates journal lines    AXinventJournalTrans.inventJournalTableRecord(AxinventJournalTable.inventJournalTable());    AXinventJournalTrans.parmJournalId(AXinventJournalTable.parmJournalId());    AXinventJournalTrans.parmTransDate(systemDateGet());    AXinventJournalTrans.inventTableRecord(InventTable::find(_inventSum.ItemId));    AXinventJournalTrans.parmItemId(_inventSum.ItemId);    AxinventJournalTrans.parmQty(_qtyInput);
   AxinventJournalTrans.parmInventDimId(_inventDim.inventDimId);
   AxinventJournalTrans.axToInventDim().parmInventSiteId(_inventSiteIdInput);    AxinventJournalTrans.axToInventDim().parmInventLocationId(_inventLocationIdInput);    AxinventJournalTrans.axToInventDim().parmInventBatchId(_inventBatchIdInput);    AxinventJournalTrans.axToInventDim().parmWMSLocationId(_wMSLocationIdInput);    AxinventJournalTrans.axToInventDim().parmWMSPalletId(_wMSPalletIdInput);
   AxinventJournalTrans.save();
   //The below code posts the journal    journalCheckPost = InventJournalCheckPost::newPostJournal(AxinventJournalTable.inventJournalTable());    journalCheckPost.run();
}
0 notes
erwinmarinax · 8 years ago
Text
Calculating the RIF check digit AX 2012 x++
Tumblr media
static void RIF(Args _args)    {           int SumRIF, EntRIF, Residuo, DigiVal;        str NumRif = "V06554332";        int i;        str cadena[];           if (strLen(NumRif) == 9)        {            for (i = 1; i < 10; i++)            {                cadena[i] = substr(NumRif,i,1);            }            cadena[1] = "0";            if ((substr(NumRif,0,1) == "V")||(substr(NumRif,0,1) == "v")) cadena[1] = "1";            if ((substr(NumRif,0,1) == "E")||(substr(NumRif,0,1) =="e")) cadena[1] = "2";            if ((substr(NumRif,0,1) == "J")||(substr(NumRif,0,1) == "j")) cadena[1] = "3";            if ((substr(NumRif,0,1) == "P")||(substr(NumRif,0,1) == "p")) cadena[1] = "4";            if ((substr(NumRif,0,1) == "G")||(substr(NumRif,0,1) == "g")) cadena[1] = "5";               cadena[1] = int2str(str2int(cadena[1]) * 4);            cadena[2] = int2str(str2int(cadena[2]) * 3);            cadena[3] = int2str(str2int(cadena[3]) * 2);            cadena[4] = int2str(str2int(cadena[4]) * 7);            cadena[5] = int2str(str2int(cadena[5]) * 6);            cadena[6] = int2str(str2int(cadena[6]) * 5);            cadena[7] = int2str(str2int(cadena[7]) * 4);            cadena[8] = int2str(str2int(cadena[8]) * 3);            cadena[9] = int2str(str2int(cadena[9]) * 2);               SumRIF = str2int(cadena[1]) + str2int(cadena[2]) + str2int(cadena[3]) + str2int(cadena[4]) + str2int(cadena[5]) + str2int(cadena[6]) + str2int(cadena[7]) + str2int(cadena[8]) + str2int(cadena[9]);               EntRIF = SumRIF/11;               Residuo = SumRIF - (EntRIF * 11);               DigiVal = 11 - Residuo;               if (DigiVal > 9)            {                DigiVal = 0;            }                  info(strFmt("El digito validador es %1", DigiVal));              }          }
0 notes