If you were passing the table you show as the tablearea parameter to your function, it would not be printing nil. So something is going wrong outside of the code you’ve shown us. Try replacing your print statement with one that prints all the keys and values in the table, e.g.
for i,itemData in pairs(tablearea) do
print("Data for serial number:",i)
for k,v in pairs(itemData) do
print(k,"=",v)
end
print("") -- blank line
end