Are you having trouble in the layout field or the portal fields?
You script does not have any portal navigation (GoToPortalRow [Last]). You might try adding an object name to the PN field and using Go To Object rather than Go To Field.
The Field it keeps going to is in the portal. I tried naming the input field and then "Go To Object" and the same thing. The "INPUT PN" field is in the main layout and the field it always goes to is the "QNTY TOTAL"
What it appears to be doing is running the Script and then performing the TAB function But I have tried making it go to the object before the input field and that way it would then tab into the input field but that did not work as well. I also Tried making The Preceding object and giving it a name and Performing the go to Object and still it goes to the first object inside the portal
Go To Object should reliably go the that specific object on the layout. Hard to say what is wrong without seeing exactly what you have going on. It sounds like it should be working.
Are you committing the records as they are created?