Honestly, I'm quite stumped with this. Code looks perfectly fine to me, but I encountered the same issue when running it on my platform.
While waiting for more expert opinions, you might want to let us know the SAP platform and PL number you are running this on?
Regards,
Joseph