Automate Picking list Registration process

Hi All, I need to automate (code in X++) the picking list registration process. Basically I need to register the serial numbers based on the quantity of Sales line. Has anyone done it before .If so please let me know how to do it.

//try below code. If You have specific requirements, you could customize yourself by observing standard functionality.
public static void UpdateSalesOrder_PickingList(Args _args)
{
SalesFormLetter_PickingList salesFormLetterPickingList;` SalesTable salesTable = salesTable::find('SAO-12345'); ```salesFormLetterPickingList = SalesFormLetter_PickingList::newPickingList();
salesFormLetterPickingList.transDate(systemDateGet());` salesFormLetterPickingList.update(salesTable, ```systemdateget(),
SalesUpdate::All,` AccountOrder::None, ```NoYes::No,
```NoYes::No);}`