Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Reading a file and writing to O/P file...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
sant532

New User


Joined: 02 Jun 2008
Posts: 17
Location: India

PostPosted: Sun Oct 05, 2008 8:01 pm    Post subject: Reading a file and writing to O/P file...
Reply with quote

I have an input file with hundreds of thousands of records. The file contains records that starts with number 1 and ends with 9.
eg:
1safs 0000 25278 djhdld
2gdtyd 87380 0000 87833 hd
3gjdf kjsjf kjfsj sdjkl
3jhjhfddhjk 868373
4gjkhd kjk7j l7776 001 10111
4jhjfd 000111 kjkj
4jhdh 878 gdkjhd
5hjxhkl 790010101
6uhds
7gkjd
8jhl
9tye00
this same structure repeats in the input file.
In that structure first(1) and last(9) records are unique that means from 2 to 8 may repeat many times with in that structure (like 3 is repeated 2 times and 4 is repeated 3 times with different data).
Now I want to read input file and based upon the some condition (that condition will be checked with 5 record), if that 5 record value satisfies the condition then I need to write the record from 1 to 9 into output file.
Back to top
View user's profile Send private message
References
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 1639
Location: germany

PostPosted: Sun Oct 05, 2008 8:36 pm    Post subject:
Reply with quote

you want to write selected groups of records 1 thru 9 when record 5 has a code that indicates that this group of 9 records should be output.

other than having to deal with a chance that there are not 9 records between two 1 records, suggest that you declare in internal cobol table to store the 9 records. After you have read and stored a 9 record - or end of file, check the 5 record (5th item) code and write all 9 records from the table, clear your table (a counter) then read and load another 9 records into your internal cobol table.
Back to top
View user's profile Send private message
sant532

New User


Joined: 02 Jun 2008
Posts: 17
Location: India

PostPosted: Sun Oct 05, 2008 8:43 pm    Post subject: Reply to: Reading a file and writing to O/P file...
Reply with quote

hi,
in between 1 and 9 there may be many records (some times 100 records)with same number like 3 and 4 in the previous example.
Back to top
View user's profile Send private message
sant532

New User


Joined: 02 Jun 2008
Posts: 17
Location: India

PostPosted: Sun Oct 05, 2008 8:45 pm    Post subject: Reply to: Reading a file and writing to O/P file...
Reply with quote

I don't know how to code a cobol internal table.
Back to top
View user's profile Send private message
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 8733
Location: 221 B Baker St

PostPosted: Sun Oct 05, 2008 9:24 pm    Post subject:
Reply with quote

Hello,

Quote:
I don't know how to code a cobol internal table.
Then this would be a good time to learn icon_smile.gif Many, many requirements are met using some internal table. Look here:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3pg20/1.4?

If you read something that is not clear, post what you read and what is not clear. Someone will be able to clarify.

Your code would read your input file and copy the records from "1" to "9" into the array/table. When you reached the "9", you would look at the "5" and decide whether to copy the records from the table to the output file.

When the records are copied (or not), move spaces to the array and continue thru the input file.
Back to top
View user's profile Send private message
sant532

New User


Joined: 02 Jun 2008
Posts: 17
Location: India

PostPosted: Sun Oct 05, 2008 9:28 pm    Post subject: Reply to: Reading a file and writing to O/P file...
Reply with quote

Thanks A lot...now i got the idea to code the total logic.
Back to top
View user's profile Send private message
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 8733
Location: 221 B Baker St

PostPosted: Sun Oct 05, 2008 9:42 pm    Post subject: Reply to: Reading a file and writing to O/P file...
Reply with quote

You're welcome - someone will be here if questions arise icon_smile.gif

d
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1