Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Read set of records and write to output

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Read set of records and write to output
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Dec 25, 2013 1:16 am    Post subject: Reply to: Read set of records and write to output
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    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Wed Dec 25, 2013 3:58 am    Post subject:
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    Post subject:
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: 1238
Location: Richfield, MN, USA

PostPosted: Thu Dec 26, 2013 8:07 am    Post subject:
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    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Thu Dec 26, 2013 8:30 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Dec 26, 2013 10:58 pm    Post subject: Reply to: Read set of records and write to output
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: 645
Location: Pennsylvania

PostPosted: Thu Dec 26, 2013 11:06 pm    Post subject:
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: 7907
Location: Bellevue, IA

PostPosted: Thu Dec 26, 2013 11:15 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us