简体   繁体   中英

Trying to pull records from a .DAT file but my results are blank. I think I have misunderstood how to use file management

So I am trying to pull the records from a file formatted as follows (The reason I am asking this, despite similar questions existing is because I am on a much more "beginner" level than those questions covered.)

ELF-CAL
6669
6434
6564
1032
1098
1829
2608
7322
2690
7061
1664
5769
ELF #16160
1082
3958
5272
2188
5618
3418
2302
2926
3338
1082
2024
4195
4083
ELF #13276
5581
3421
3403
4356
2989
1278
1868
3630
4702
3409
4887
2383
ELF #17104
7496
5265
8078
8788
7402
3601
2641
1252
4994
ELF #14074
7524
8889
9290
8892
5785
2163
1074
6747
ELF #17452
8006
12427
7919
4012
6850
ELF #134591
26861
ELF #113028
12695
12762
11006
15937
ELF #117218
12408
17554
11415
ELF #11118
7240
6400
3431
1032
3283
4667
6100
5076
1101
6952
3527
ELF #17633
4385
4510
4073
3052
11738
ELF #133554
ELF #13448
16054
10839
ELF #14496
2697
4731
5150
5327
4039
4004
2148
6150
4001
2882
5780
4327
ELF #14095
2064
6701
3828
2427
4775
2583
2000
1390
7391
1701
3796
ELF #110355
1262
8781
6350
ELF #111053
11527
1389
6007
12383
11033
ELF #17951
4258
9815
10061
7579
3769
11431
ELF #13597
35622
ELF #12129
2994
4260
5269
4179
1612
3509
3581
4544
3713
3202
6458
1203
1095
ELF #117196
13475
12666
ELF #13549
6432
6593
6723
1272
4023
2112
2844
5135
5103
1585
4773
5635
ELF #18731
16378
5076
2999
ELF #111136
1525
8684
9731
9753
5366
7399
ELF #18996
1483
4922
1191
2761
(It goes on and on. Each occurence of "ELF #" Is supposed to indicate a new record)

So my code looks like the following, and it just displays blank spaces when I run it. Any suggestions on why I am getting file management wrong? And how should I fix it


       IDENTIFICATION DIVISION.
       PROGRAM-ID. COBSHL03.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.

       FILE-CONTROL.
         SELECT ELF-INNPUT ASSIGN TO "C:\Users\dsdsd\Desktop\innput.DAT"
           ORGANIZATION  IS SEQUENTIAL
           ACCESS MODE IS SEQUENTIAL
           FILE STATUS IS DOING-ITS-BEST.

       DATA DIVISION.
       FILE SECTION.
        FD ELF-INNPUT.
        01 ELF-RECS.  
           05 ELF-CAL          PIC X(9).
           05 ELF-NUM          PIC X(10).

       WORKING-STORAGE SECTION.
        01 CACLULATIONS.
           03 COUNT-OF-ELF     PIC X(6).
           03 ELF-CAL-TOTAL    PIC 9(6).

        01 DOING-ITS-BEST PIC X(900).
       PROCEDURE DIVISION.
       PROGRAM-BEGIN.
        OPEN INPUT ELF-INNPUT.
        DISPLAY ELF-RECS.
        CLOSE ELF-INNPUT.
       PROGRAM-DONE.
         STOP RUN.

You OPEN and CLOSE the file, it looks like you've missed to READ it, likely in a loop checking the defined io-status (which is a PIC XX item).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM