How to create batch number for the particular item programmatically?

Hi All,

I want to create a batch number and assign to the particular item.

How to create batch number for the particular item programmatically?

Thanks in advance,

Hari

static void createBatch(Args _args)

{

InventBatch inventBatch;

InventTable inventTable;

NumberSeq numberSeq;

inventTable = InventTable::find(‘YourItem’);

ttsBegin;

inventBatch.initValue();

// you can assign your own number or use the sequence

numberSeq = NumberSeq::newGetNum(InventParameters::numRefInventBatchSerialId());

inventBatch.InventBatchId = numberSeq.num();

inventBatch.ItemId = inventTable.ItemId;

inventBatch.prodDate = systemDateGet();

inventBatch.insert();

numberSeq.used();

ttscommit;

}

Consider updating the shelf life, best before date, if they are enabled see \Data Dictionary\Tables\InventBatch\Methods\pdsSetShelfLifeBestBeforeFields