Thread: COBOL

First KSDS program - pretty sure I am stuck in a read loop

Started by Tyler • user4 replies158 viewsLast activity 3 weeks ago
Post #1
0 votes
Tyler
Reputation
34
Posts: 5
Joined: Nov 8, 2025, 1:44 PM
Posted: Jun 19, 2026, 9:16 AM

Wrote my first COBOL program that reads a KSDS. It compiles and runs but hangs partway through. I think the READ is looping and never hitting end of file, or maybe I am not positioning right on the file.

I declared a few temp variables I have not used yet. Can someone point me at the usual mistake here? I can post code if needed.

Post #2
0 votes
Marty
Reputation
412
Posts: 15
Joined: Aug 12, 2024, 9:14 AM
Posted: Jun 19, 2026, 10:16 AM

Look at your READ ... AT END / NOT AT END logic. Beginners often forget to set a flag or keep reading past the last key.

Post #3
0 votes
Rick
Reputation
302
Posts: 6
Joined: Jun 14, 2024, 9:41 AM
Posted: Jun 19, 2026, 2:16 PM

Add a DISPLAY counter in the loop and a DISPLAY on AT END. Cheap way to see where it stops making progress. If you use RD/z you can breakpoint it but displays work everywhere.

Post #4
0 votes
Tyler
Reputation
34
Posts: 5
Joined: Nov 8, 2025, 1:44 PM
Posted: Jun 20, 2026, 11:16 AM

Found it. HIGH-VALUES on the key was wrong for how I opened the file. Works now. Thanks.

You must be signed in to reply to this thread