Hi,
Have you tried simulating this in genil_bol_browser? There might be some configuration/BAdI overwriting your code. I would suggest you do the exact things you are doing in your code in the BOL browser.
Also, it is not recommended to call FMs like this from the UI, you should consider moving your code to the appropriate BAdI.
Regards,
Parul