I'm not sure where this came from - as I don't see history. If you already have a thread on the topic in the community, next time it's best to find it and stick with one thread.
With a personnel action, it will generate the new personnel number after the first infotype you save, you just have to download it. Like this - I added their name and clicked SAVE and it moved me to the next one - see the personnel number filled in?
Since it's read only, you have to enable it.
Then search for PERNR, and see where it has a value
You can also add it manually to your script and choose download instead of upload. Just make sure it's after the first save.
In this script I created back in 2011, I downloaded it at the very end when I exited out of the transaction.
Hope that helps.