Maybe I should have separated the coordinate part. Originally I was thinking about rewriting your DO loop with SN:G and moving it inside the function, but it didn't happen.
This should work:
So then you would call FU7800701 to convert type/subtype to id and pass it and coordinates to FU7800702.