I see three issues here. First, mapping between the purchase order and a warehouse shipping order. The data doesn't match up exactly, but if you assume a one-to-one relationship between a purchase order and a shipping order, then that can be overcome. I assume you can hard-code data like the warehouse id, hazardous materials codes, etc.
The second problem is do you need one-time, or occasional transformation which you will do manually, or runtime translation that you set up once and integrate into a translation system?
Third is based on that, what tool to use? Either way, I would take a good look at Stylus Studio. It has both an IDE for local testing or manual conversion, and a runtime component that you install on a server. My former company used it extensively, and it's cheaper than almost any other real-time translator (Mercator, Gentran, etc.)
To use Stylus, you'll import the source file (the 850) and create a reusable schema which can be used to parse the file into XML. Then, import an example of the output format (the 940) to create a schema which can be used to serialize the document back into X12.
From there, you can use the mapping tools to get you close, then hand-edit the XSLT for complicated logic which may need to be tweaked (loops aren't perfectly handled, for instance). Stylus Studio even allows you to create "pipelines" which can be used to chain multiple XSLT maps in a row, or pull in data from outside sources into the middle of a translation.
Then, you can wrap all that up and export it to your realtime environment. Better yet, if you're doing this manually, you can just run your files through the pipeline as you get them, and you'll be done.