![]() The INITIALIZE statement causes it to be set to zero. In this example, the data item, RECORD-COUNTER, is defined as numeric. The following examples illustrate the simple form of INITIALIZE: 05 RECORD-COUNTER PIC 9 (5) The INITIALIZE statement offers an alternative to the MOVE statement in initializing data items to fixed values. INITIALIZE identifier-1 REPLACING data-type BY identifier-2 These sales figures are referenced via the subscript called MSF-SALES-SUB. The Master Store File record description would also contain a table definition for the 12 occurrences of the monthly sales figure. You can see from this example that the Store Table has 2 subscripts, which must be defined in Working-Storage: one to reference the different stores (ST-SUBSCRIPT) and one to access the monthly sales for the store (ST-SALES-SUB). TO STORE-SALES (ST-SUBSCRIPT, ST-SALES-SUB). MOVE MSF-ST-SUFF TO STORE-SUFF (ST-SUBSCRIPT). MOVE MSF-ST-NO TO STORE-NO (ST-SUBSCRIPT). PERFORM LOAD-STORE-TABLE VARYING ST-SUBSCRIPT The file would be read, one record at a time, and entries made in the table for each store. statement.įor Example, The Store Table described above may be loaded from the records on the Master Store File. This will generally be done by using the PERFORM …. VALUE clauses cannot be used in table definitions so a table must be loaded with information during the run of the program. Such tables can be 2-Dimensional or 3-Dimensional in size. To create a multi-level table we have a give an OCCURS clause within another OCCURS clause. ![]() ![]() COBOL also supports the Multi-Level table. It can be used only with level numbers starting from 02 to 49. Occurs clause indicates the repetition of the data-name definition. The table is declared in the Data Division. With table we use the contents of some input field to “look up” the required data in the table. Defining a table in WORKING-STORAGE to be accessed by each input record.Defining a series of totals in WORKING-STORAGE to which amounts are added after all data is accumulated, the totals can be printed.Defining a series of input or output fields, each with the same format. ![]() ![]() The primary uses of arrays are to define: Each data item in the array is referenced by the name of the array and its position in the array given by a subscript or index contained in parentheses following the array name. An array can contain any number of data items of identical type and size. Arrays are data structures that are used to simplify coding and improve processing efficiency. It is a linear data structure and is a collection of individual data items of the same type.ĭata items of a table array are internally sorted. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |