View previous topic :: View next topic
|
Author |
Message |
raviprabhu
New User
Joined: 20 Oct 2006 Posts: 29
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Sample expected output would go a long way for anyone to help you out. |
|
Back to top |
|
|
raviprabhu
New User
Joined: 20 Oct 2006 Posts: 29
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
raviprabhu
New User
Joined: 20 Oct 2006 Posts: 29
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
raviprabhu wrote: |
Can anybody give logic (dont want to use table/array) |
Why not? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|