We can use QMF to extract the data into a sequential file with column names. Below are the setps -
Step 1: Write sql query in QMF screen
Step 2: Press F2 to run the query and to see the report.
Step 3: Write 'export report to '<datasetname>' and hit enter.