Hi Sri,
One simle method i would suggest is in the forground method try to understand how the spool number is geneerated through debugging, through that you can find the missing parameter for spool generation.
May you would be missing something in background, please try through debugging.
Regards,
Satish