Also check your company codes! They don't seem to match on the header and items.
Why are you hardcoding all this stuff - currency, company codes, doc type, gl accounts etc?
That's not exactly best practice. There's also a lot of code replication.
Paul