800-WRITECSV

Name

800-WRITECSV-<FileName>

Description

On the first call, this API opens the file for output if it is not already open. If it has a header, it formats and writes the header, and determines from the use flags the order the fields are to be written (for information, see Use Flag (UF) Fields).

Note: the first write to an unopened file cannot occur within a transaction state.

On subsequent calls, it formats and writes a record with data from working storage (REC area), writing only those fields with use flags on.

Return Values

One record is written in the CSV work file.

Programming Example: Writing to a CSV File

           PERFORM 800-OPENOUTPUTCSV-CSVOUT1.    
           PERFORM 800-ALLUSEDCSV-CSVOUT1.    

           MOVE WS-TRUE                TO CVO-COMPANY-UF
                                          CVO-PROC-LEVEL-UF
                                          CVO-AMOUNT-UF
                                          CVO-DATE-UF.      

           MOVE "COMPANY"     TO CVOINFO-NEW-FLD-NAME.
           MOVE "Warehouse"   TO CVOINFO-NEW-FLD-NAME.
           MOVE "numeric"     TO CVOINFO-NEW-FLD-TYPE.
           PERFORM 800-OVRDESCCSV-CSVOUT1.

           PERFORM 1000-WRITE-CSV-LOOP
           THRU    1000-LOOP-END
           UNTIL   .....

           PERFORM 800-CLOSECSV-CSVOUT1
           STOP RUN.

       100-END.
             .
             .
       1000-WRITE-CSV-LOOP.

           MOVE API-COMPANY            TO CVO-COMPANY.
           MOVE API-PROC-LEVEL         TO CVO-PROC-LEVEL.
           MOVE API-INVOICE-AMT        TO CVO-AMOUNT.
           MOVE API-INVOICE-DATE       TO CVO-DATE.

           PERFORM 800-WRITECSV-CSVOUT1.
             .
             .
             .
           1000-WRITE-LOOP-END.