Search code examples
cobolmicrofocus

Customize CSV Column Header


I am writing a program in COBOL that reads data from table and dumps it into a CSV file. My work definitions columns are defined as (for instance) FACILITYCODE. Below is the detail of of column:

Working Storage : WS-FACILITYCODE PIC X(04) VALUE "XYZ".

Program Definition: MOVE WS-FACILITYCODE TO ABI-FACILITYCODE.

When my program is written, the CSV header comes out as "Facilitycode." I want to change that to "FACILITY_CODE"

Code used to create the CSV PERFORM 800-WRITECSV-XYZINV.

A comparable exmaple in SQL world would be 'AS'.

Any suggestions please.

Thank you!


Solution

  • As everybody says, we need to know what PERFORM 800-WRITECSV-XYZINV. does...

    but I have worked in a similar solution for write CSV files

      *...
      *acces to you table and it fills the variables WS-A WS-B and WS-C
    
      *build heather
       STRING "A"  ","
              "B"  "," 
              "C"         DELIMITED BY SIZE
          INTO WS-LINE
       END-STRING
    
      * write header
       WRITE FILE  FROM WS-LINE
       ...
    

    Then for each file from the table, you can:

       INITIALIZE WS-LINE
    
      *build line whit the values
       STRING WS-A  ","
              WS-B  "," 
              WS-C         DELIMITED BY "SIZE" <-- it will print all spaces that each variable have 
          INTO WS-LINE
       END-STRING
    
      * write line
       WRITE FILE  FROM WS-LINE
       ...