- Can I do that in COBOL on z/OS?
- If so, then what are the software requirements on z/OS?
- And what would I need to code in COBOL?
- Enterprise COBOL for z/OS Version 3 Release 3 (PID 5655-G53).
- The first thing you have to decide is if you want the entire file encoded as one XML document or each record to be one XML document. To get the entire file converted into one XML document, you could read each record into the COBOL program record description, then use the new
XML GENERATE FROMstatement to create an XML message from each record. The first step (optional) in creating the XML document is to output the XML declaration; next create the begin element for the entire file, and then you can do all the XML GENERATEs for each of the records. Something like this:
Move '<?xml version="1.0"?>' To xml-doc(1:21) Move '<File-name>' To xml-doc(22:11) Compute sp = 34 Perform Until EOF Read rec-1 At End Set EOF To True Not At End XML Generate xmldoc(sp: ) From rec-1 Count in xc Add xc To sp End-Read End-Perform Move '</File-name>' To xml-doc(sp:12)
Dig Deeper on IBM system z and mainframe systems
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.