Hi,
Update is not allowed even for your UDF. Because this is a B1 system table not UDT. Stop this from now on. However, for correcting the mistake, you may revise the select to remove the last condition for itemcode matching. The last line is also wrong. No from for update script.
Always run the select query first to make sure it only return one value which is what you need.
Thanks,
Gordon