Pages

Banner 468 x 60px

 

Wednesday, November 22, 2017

Inventdim (findORCreate) using x++

1 comments
Inventdim (findORCreate) using x++ :

private void createJournalLine(InventJournalTable inventJournalTable,TIDMaterialSupportLines _TIDMaterialSupportLines)
{
        InventJournalTrans              inventJournalTrans;
        InventJournalNameId             inventJournalName;
        InventDim                            inventDim;

        //Below code creates journal lines
        inventJournalTrans.clear();
        inventJournalTrans.initFromInventJournalTable(inventJournalTable);
        inventJournalTrans.TransDate        = systemDateGet();
        inventJournalTrans.ItemId           = _TIDMaterialSupportLines.ItemId;
        inventJournalTrans.initFromInventTable(InventTable::find(_TIDMaterialSupportLines.ItemId));
        inventJournalTrans.Qty              = _TIDMaterialSupportLines.Qty * -1;
        // inventJournalTrans.InventDimId      = _TIDMaterialSupportLines.inventDimId; // Remark By Randa
        // Add By Randa
        inventDim.InventLocationId      = _TIDMaterialSupportLines.InventLocationId;
        inventDim.InventSiteId          = InventLocation::find(_TIDMaterialSupportLines.InventLocationId).InventSiteId;
        inventDim                       = InventDim::findOrCreate(inventDim);
        inventJournalTrans.InventDimId  = inventDim.inventDimId;
        // End Added By Randa

        inventJournalTrans.insert();

        //Below code for update material status lines
        _TIDMaterialSupportLines.selectForUpdate();
        // _TIDMaterialSupportLines.DocRefNumber                   = inventJournalTrans.JournalId; // Remark By Randa
        _TIDMaterialSupportLines.JournalRefNumber               = inventJournalTrans.JournalId; // Add By Randa
        //_TIDMaterialSupportLines.TIDMaterialSupportLineStatus   = TIDMaterialSupportLineStatus::Partial; // Remark By Randa
        _TIDMaterialSupportLines.DocRefRecId                    = inventJournalTrans.RecId;
        _TIDMaterialSupportLines.update();




        info(strFmt('Create journal line for item %1 ',inventJournalTrans.ItemId));
}

1 comments:

Anonymous said...

I always spent my half an hour to read this weblog's articles all the time along with a mug of coffee.

A financial dimension value is based on the record and has been used on a transaction. You cannot delete the record

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH