COBOL Program to read a flat file sequentially and write it to an output file, not able to read at all loop is going infinite -


I am trying to write a COOL program so that a flat file can be read sequentially and write it into an output file Given, I'm able to read only one record at a time, not able to read the next record, what should I do?

Here's my code:

  Read-Para Thru and Para to display the process division open INPUT FILEX end of off = 'Y'. Stop FILEX Wait Wait Read-Para. Finally read the file 'Y' to display the end-of-file OFFCODE1 display AGCODA 1 Display POLNO1 Display EFFDATE1 Display Exhibit Display Ripple Display POLHOLDER1 Visit Place END-PARA. End para   

I have tried to use the scope terminator, is still not capable. I'm getting S001 ABEND here is my code:

  Identification Department Program ID easy. Environment Division Input-Output section file-control SYSUT1 FILE Select FILEX for the position FS is selected. Data Division File Section FD File 01 FILEXREC 02 OFFCODE1 PIC X (3) 02 Filler PIC X2 Agcoding 1 PIC X (3) 02 Filler PIC X2 POLNO1 PIC X (6) 02 Filler PIC X 02 EFFDT 1 PIC X (8) 02 Filler PIC X 02 XPDIT PIC X (8). 02 Filler PIC X2 Repo PIC X (1) 02 Filler PIC X 02 Pollhilder 1 PIC X (8) 02 Filler PIC X2 Place 1 PIC X (9) 02 Filler PIC X (87) Work Storage Section 77 FS PIC 9 (2) 01 WS-Indicator 10 WS-EOF-IND PIC X (01) VALUE 'N' 88 WS-And-of-File Value 'Y' Process Division Open-on-the-pub end-of- Up to parse WS-and-off-file. Stop FILEX Wait Wait Read-Para. Send WS-EOF-IND to 'Y' at the end. Display OFFCODE1 Display AGCODE1 Display POLNO1 Display EFFDATE1 Display Exhibit Display Display Display to display POLHOLDER1 Place if WS-END-OFF-FILE go to cross-end. End para Go out.   

Another way I tried even for a record in this work, then after getting the code, getting the S001bind is getting. Here's the code:

  Identification Division Program ID. ASSIGNMENT. Environment Division Input-Output section file-control Select FILEX for SYSUT1 data division. File section FD file label record is the standard record that contains 140 characters blocks, which have 200 records. 01 FILEXREC 02 OFFCODE1 PIC 9 (3) 02 Filler PIC X2 Agcoding 1 PIC X (3) 02 Filler PIC X2 POLNO1 PIC X (6) 02 Filler PIC X 02 EFFDT 1 PIC X (8) 02 Filler PIC X 02 XPDT 1 PIC X (8) 02 Filler PIC X 02 Repeed 1 PIC X (1) 02 Filler PIC X 02 Polohahider 1 PIC X (8) 02 Filler PIC X2 Place 1 PIC X (9) 02 Filler PIC X (26) Work-Storage Section 01 WS-Indicator 10 WS- EOF-IND PIC X (01) VALUE 'N' 88 WS-And-of-File Value 'Y' 01 PM 1 02 OFFCODE2 PIC 9 (3). 02 Filler PIC X2 Agcoding 2 PIC X (3) 02 Filler PIC X2 POLNO2 PIC X (6) 02 Filler PIC X2 EFFDT 2 PIC X (8) 02 Filler PIC X 02 XPDT 2 PIC X (8). 02 Filler PIC X 02 repoded 2 pic x (1). 02 Filler PIC X2 Pollhilder 2 PIC X (8). 02 Filler PIC X2 Position 2 PIC X (9). 02 Filler PIC X (26) Process Division Open INPUT FILEX WS-And-Off-File Up-to-Through-Ports Through-Pairs Stop FILEX Wait Wait Read-Para. Read the file in TEMP1 and finally run 'Wi' to VICE-EOF-IND. Display OFFCODE1 Display AGCODE1 Display POLNO1 Display EFFDATE1 Display EXPDATE1 Display REPCODE1 Display POLHOLDER1 Display Locations 1 If WS-And-Off-File is to go to end-to-end. End para Go out.    

You should use your END-terminators ... end-performance, end - if, end-read, etc.

For your problem, if I was guessed, then I would say that you are not just reading the first record, you are reading all the records and only the last one. In your READ statement there is an AT, where everything has been done, but it does not tell what to do with records that it is read successfully, I usually give my read statement as a code :

  Reed file on the set file at the end - Correct display process to correct EOD - Record end read   

Wrap that way in the display And it works very well It is true:

  set-to-file is not correct to execute the file until the end file FILE-EOF is not true for reading - in the end performance process - end-reading records Display   

Good luck, hope that it will work for you. Concrete coob writing can be very difficult.

Comments