fp=open(%addr(xml_file): oflag: sflag: 819); <—– No file being created here
What is the value of fp at this point?
// close it; ready to work with now
fp should be non-negative before you can do anything with it. If it's -1, you should get the errno and handle any conditions.
Can you show an example of the value in xml_file? There were some minor changes in open() for i 6.1 that could be affected by the path, though I wouldn't expect it.
If at all possible, you should get rid of o_codepage and use O_CCSID instead. Use a CCSID conversion ID rather than a code page. That should have been done before V5R3, though it also should still work in i 6.1.
What is your QCCSID system value?
Since you a re creating a XML file, you probably also should consider opening it as a text file. Include O_TEXTDATA as one of your oflags. If the file is expected to be readable as text, you should be better off in the long term creating it as text.
Any errno on the creation, the path to the XML file and the system QCCSID value could all lead to some useful answer.