The COBOL programming language’s capital backbone is its adeptness to address a advanced array of abstracts files advantageous for baby business, including Microsoft Excel. Organizing the book as a comma-separated value, or CSV, simplifies the programming task. With CSV, you set up a basal book anatomy in the Book Area of your COBOL program’s Abstracts Division, again move ethics into the anatomy in the Procedure Division. Excel opens this book as a basal workbook absolute simple rows and columns.
Create a Select access in the Input-Output area of your COBOL program’s Environment Division. This is the file’s name and area you appetite it amid in your adamantine drive’s book directory. The afterward COBOL illustrates the Select statement:
ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT EXCEL-OUTPUT-FILE ASSIGN TO “C:WORKSHEET.CSV” ORGANIZATION IS LINE SEQUENTIAL.
Define a almanac in the Abstracts Division’s Book Area as a placeholder accepting the admeasurement of the row you appetite for the spreadsheet. Set up the spreadsheet’s cavalcade ethics in the Abstracts Division’s Working-Storage Area as affectation abstracts types afar by commas. End anniversary almanac with carriage-return and band augment characters as in the afterward example:
DATA DIVISION. FILE SECTION. FD EXCEL-OUTPUT-FILE DATA-RECORD IS SPREADSHEET-RECORD. 01 SPREADSHEET-RECORD PIC X(14).
WORKING-STORAGE SECTION. 01 WS-SPREADSHEET-ROW. 05 WS-SALES-AMOUNT PIC 999.99. 05 FILLER PIC X VALUE ‘,’. 05 WS-SALES-QTY PIC 99999. 05 FILLER PIC XX VALUE X’0D25’.
Note that X’0D25’ represents a carriage-return, band augment in hexadecimal. These two characters mark the end of every almanac in a CSV file.
Move abstracts into the 05-level working-storage abstracts elements, again move the 01-level alive accumulator characterization into your achievement book in your program’s Procedure Division. Address the almanac you created in the book definition, or FD. The COBOL cipher that follows creates and writes a distinct row to your CSV achievement file:
PROCEDURE DIVISION. OPEN OUTPUT EXCEL-OUTPUT-FILE. MOVE SALES-VALUE TO WS-SALES-AMOUNT. MOVE SALES-QTY TO WS-SALES-QTY. MOVE WS-SPREADSHEET-ROW TO SPREADSHEET-RECORD. WRITE SPREADSHEET-RECORD. CLOSE EXCEL-OUTPUT-FILE.
References
Tips
Writer Bio
Chicago built-in John Papiewski has a physics amount and has been autograph back 1991. He has contributed to “Foresight Update,” a nanotechnology newsletter from the Foresight Institute. He additionally contributed to the book, “Nanotechnology: Molecular Speculations on Global Abundance.”
How To Write To A File – How To Write To A File
| Pleasant to my own website, in this particular time I will explain to you in relation to How To Factory Reset Dell Laptop. Now, this can be a very first picture:
How about graphic preceding? can be of which wonderful???. if you’re more dedicated and so, I’l m teach you several graphic once more below:
So, if you’d like to get the incredible graphics about (How To Write To A File), press save button to download the pictures to your laptop. They are ready for obtain, if you’d rather and want to grab it, simply click save badge on the page, and it will be immediately saved in your notebook computer.} Lastly if you want to gain new and recent image related to (How To Write To A File), please follow us on google plus or bookmark the site, we attempt our best to provide regular up grade with all new and fresh photos. Hope you love staying here. For most upgrades and recent news about (How To Write To A File) pics, please kindly follow us on tweets, path, Instagram and google plus, or you mark this page on bookmark area, We try to present you up grade periodically with fresh and new graphics, love your browsing, and find the best for you.
Thanks for visiting our website, contentabove (How To Write To A File) published . Today we’re excited to announce we have discovered an extremelyinteresting contentto be reviewed, namely (How To Write To A File) Many people trying to find info about(How To Write To A File) and of course one of them is you, is not it?