IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Read set of records and write to output


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Wed Dec 25, 2013 12:45 am
Reply with quote

Hi,

I have a input file with records as
02 ABCD
03 XYZ
13 hakdjl
45 jshdjf
45 ENDrecordset1
02 USA
03 jlhdfklfj
12 djhfklj
45 fjjfkljs
45 ENDRecordset2
02 UK
04 hjakldfjk
45 ENDRecordset3
:
:
I have to read the first record (02 ABCD) to until record
(45 ENDrecordset1) and process the records (write to output file). Again the next set from (02 USA) to (45 45 ENDRecordset2) and process teh records.
So basically from (02 XXX) to (45 XXX) is a set of record being considered in input file and written to output file.
Please let me know how to do this
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 25, 2013 1:16 am
Reply with quote

Store all the reocrds for your group in WORKING-STORAGE. Process them when you know you need to, clear the stored records (or ensure they will be). Continue until end-of-file.

Details depend on what you know about the file (how many records, how many different types, is the END always present, etc).
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Dec 25, 2013 2:41 am
Reply with quote

Quote:
I have to read the first record (02 ABCD) to until record
(45 ENDrecordset1) and process the records (write to output file). Again the next set from (02 USA) to (45 45 ENDRecordset2) and process teh records.


What does mean process the records?

Do you want to club record type 02 till 45 and write as one record in output file?

or

record type 02 till 45 in one output file and another set in other output file and so on ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Dec 25, 2013 3:58 am
Reply with quote

Sample expected output would go a long way for anyone to help you out.
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Wed Dec 25, 2013 10:26 pm
Reply with quote

Yes..

02 to 45 will be considered as 1 record (but stored as seperate records in file) which will be written in output KSDS file.
Then again read the 02 to 45 records from input file and then write to same KSDS file.
Please let me know the logic

The output will be similar to input

02 ABCD
13 sfkjfn
30 djfkl
45 ENdrecordset1
02 ABCD
13 sfkjfn
33 djfkl
45 ENdrecordset2
:
:
This logic is basically part of requirement to be implemented with other requirement
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Dec 26, 2013 8:07 am
Reply with quote

Unless I'm missing something, why don't you simply read input file, process the record, write output record, etc. until end of input file? If there's a need to see "previous" records while processing "current" record, do as Bill suggested. Store each group of records in a table, process them, write output records from the table, clear table, read some more.
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Thu Dec 26, 2013 8:19 pm
Reply with quote

Can anybody give logic (dont want to use table/array)
Read 1 set (02 to 45) and write to output file and then read 2nd set and write to putput file
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Dec 26, 2013 8:30 pm
Reply with quote

raviprabhu wrote:
Can anybody give logic (dont want to use table/array)

Why not?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 26, 2013 10:58 pm
Reply with quote

You'd better an example of the output you want for the input you've shown. What is the key on the KSDS?
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Dec 26, 2013 11:06 pm
Reply with quote

If you have only one of each record type per set then try this pseudo code:

Code:

Create a record layout in working storage for all record types
Initialize all Record Layouts
Read Input record
Perform until End-of-file
  Move to record layout for the record-type
  If Type-45 Then 
    Perform Write-Output-Set   
  End-if 
  Read Input record
End-Perform


Write-Output-Set
  Write 02, 13, 30(if there is one), 33(if there is one), 45
  Initialize all Record Layouts


If you have more than one of each record type per set then
you will need some sort of table/array
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 26, 2013 11:15 pm
Reply with quote

raviprabhu, you have not explained much about your "requirement" and hence it is very difficult or impossible to provide you assistance. A KSDS file has a key and so far nothing you have posted indicates anything about the key to be used for that data set. Furthermore, you have not given any reason that a straight copy from the input to the output would not accomplish your goal -- so why use COBOL at all instead of IDCAMS REPRO? Other questions that haven't been addressed include:
- are there records OTHER than the 02 / 45 END combinations in the input?
- why do you not want to use tables?
- do you need all the input records in memory at the same time -- if so, why?
- if there are records besides what you want in the input file, how will you exclude those records?
- are the input records in the correct sequence when the program starts?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top