Created On:  21 January 2013

Problem:

Customer is using the PREXML preprocessor in Server Express to use COBOL syntax to create XML files.
By default, these files are written as formatted XML files with CRLF following each record as well as spaces between record so XML will appear formatted when viewed as text file.

Customer would like to know if these files can be written without the formatting characters in them.

Current program looks something like the following:

       $set p(prexml) endp                                            
       id division.                                                   
       program-id. testxml.                                           
       environment division.                                          
       input-output section.                                          
       file-control.                                                  
                                                                      
           select xml-stream       assign to "myxml.xml"                         
                                            organization is xml                
                                            file status is file-status.        
                                                                      
       data division.                                                 
       file section.                                                  
       xd  xml-stream.                                                
       01  my-record identified by "my_record".                       
           02 my-customer identified by "cust_record".                
              03 my-name pic x(100) identified by "my_name".          
              03 my-company pic x(100) identified by "my_company".    
              03 my-phone   pic x(100) identified by "my_phone".      
       working-storage section.                                       
       01 file-status  pic s9(9) value 0.                             
       procedure division.                                            
                                                                      
           open output xml-stream                                     
           move "chris" to my-name                                    
           move "Micro Focus" to my-company                           
           move "603-555-1212" to my-phone                            
                                                                      
           write my-record key is all my-customer                     
           move "John" to my-name                                     
           move "Microsoft" to my-company                             
           move "800-111-2222" to my-phone                            
           write my-record key is all my-customer                     
           write my-record                                            
           close xml-stream                                           
           stop run                                                   

Resolution:

Try adding the NOT LINE ADVANCING clause to the select statement to remove formatting from the xml file.

Example:
       $set p(prexml) endp                                            
       id division.                                                   
       program-id. testxml.                                           
       environment division.                                          
       input-output section.                                          
       file-control.                                                  
                                                                      
           select xml-stream       assign to not line advancing "myxml.xml"                         
                                            organization is xml                
                                            file status is file-status.        
                                                                      
       data division.                                                 
       file section.                                                  
       xd  xml-stream.                                                
       01  my-record identified by "my_record".                       
           02 my-customer identified by "cust_record".                
              03 my-name pic x(100) identified by "my_name".          
              03 my-company pic x(100) identified by "my_company".    
              03 my-phone   pic x(100) identified by "my_phone".      
       working-storage section.                                       
       01 file-status  pic s9(9) value 0.                             
       procedure division.                                            
                                                                      
           open output xml-stream                                     
           move "chris" to my-name                                    
           move "Micro Focus" to my-company                           
           move "603-555-1212" to my-phone                            
                                                                      
           write my-record key is all my-customer                     
           move "John" to my-name                                     
           move "Microsoft" to my-company                             
           move "800-111-2222" to my-phone                            
           write my-record key is all my-customer                     
           write my-record                                            
           close xml-stream                                           
           stop run