Monday, November 23, 2020

PO Registration X++ D365FO

Code to do registration through X++

Note: To do reverse registration provide input qty as Negative, otherwise to add new registration then qty must be positive.

private void inventTransactionRegister( InventTransId    _inventTransId, 

                                            Qty     _qty, 

                                            InventBatchSerialId   _batchNo = '', 

                                            InventBatchSerialId   _serialNo = '') 

    {

        InventTransWMS_Register     inventTransWMS_register;

        TmpInventTransWMS           tmpInventTransWMS;

        InventDim                   inventDim;

        InventTrans                 inventTrans = InventTrans::findTransId(_inventTransId);

        boolean                     ret;

        //inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);

        inventDim               = inventTrans.inventDim();


        InventSerial    inventSerial;

        InventBatch     inventBatch;


        tmpInventTransWMS.clear();

        tmpInventTransWMS.ItemId = inventTrans.ItemId;

        tmpInventTransWMS.initFromInventTrans(inventTrans);

        tmpInventTransWMS.InventQty   = _qty;

        if(_batchNo && 

                this.checkTrackingDimensionEnabledItem(inventTrans.ItemId, fieldNum(InventDim, InventBatchId)))

        {

            inventBatch = InventBatch::findOrCreate(_batchNo, inventTrans.ItemId);

            inventDim.inventBatchId = inventBatch.inventBatchId;

        }

        if(_serialNo && 

                this.checkTrackingDimensionEnabledItem(inventTrans.ItemId, fieldNum(InventDim, InventSerialId)))

        {

            inventSerial = InventSerial::findOrCreate(_serialNo, inventTrans.ItemId);

            inventDim.inventSerialId = inventSerial.InventSerialId;

        }

        tmpInventTransWMS.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;

        tmpInventTransWMS.insert();

inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);

        ret = inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,

                                                        inventTrans,

                                                        inventTrans.inventDim());

        if(ret)

        {

            inventTransWMS_register.updateInvent(inventTrans);

        }


}

2 comments:

  1. where do this refer to in this piece of code?

    ReplyDelete
  2. Please do FIND REFERENCE for this object class " InventTransWMS_Register".

    ReplyDelete

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...