MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting records to another file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
santa
Beginner


Joined: 16 Mar 2007
Posts: 3
Topics: 3

PostPosted: Thu Mar 22, 2007 12:00 pm    Post subject: Sorting records to another file Reply with quote

I have a file like:
Code:

header
01098009890800z1111187686876876
01453543877895z2222276868767687
01098009890800z3333387686876876
01453543877895z4444476868767687
02z1111187686876876             CAT1
02z2222276868767687             CAT2
02z3333387686876876             CAT2
02z4444476868767687             CAT1
03z11111876868768767866868686yt
03z2222276868767687hffjgfghfghfghf
03z3333387686876876jghjgfu867687
03z4444476868767687bgfyf56868971
trailer


z11111,z22222,z33333,z44444 are codes which are present in all record types i.e(01,02,03). these codes could be of CAT1 or CAT2, indicated in record 02. i am interested in extracting all records for codes which belong to CAT2.

desired output:
Code:

header
01453543877895z2222276868767687
01098009890800z3333387686876876
02z2222276868767687             CAT2
02z3333387686876876             CAT2
03z2222276868767687hffjgfghfghfghf
03z3333387686876876jghjgfu867687
trailer

the input file is expected to contain over 30L records. I have tried REXX as solution by first concatenating all CAT2 codes(total CAT2 codes around 80) in a string and then reading input file record by record and serching if code in read record is available in concatenated string. if so, write to a file. It takes a hell lot of time to process complete file Wink . can anyone suggest solution to the problem using JCL or better way of doing it using REXX Exclamation
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Mar 22, 2007 12:15 pm    Post subject: Reply with quote

santa,

Please do NOT post the same Question in multiple forums.

1. what is the LRECL and RECFM of the input?

2. What is the position and format of the codes z11111,z22222,z33333,z44444 ? for 01 records it is at a different position and for 02 records it is at different position. is that correct?

3. What is the position of the word "cat2" ?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Mar 22, 2007 12:44 pm    Post subject: Reply with quote

Do you have to extract the CAT2 codes from the input file or do you have a separate list of them? Either way, a DFSORT INCLUDE statement (hardcoded or generated) could handle 80 CAT2 strings and 3 records types.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Thu Mar 22, 2007 1:43 pm    Post subject: Reply with quote

As for rexx, searching a long string may not be the best way to store these. A stem variable may be better. something along the lines of this:

1st pass:
Code:

keys. = 0
read each record and ...
If substr(record,1,2) = "02" Then
  Do
    Parse Var record 3 key 9 . cat
    If cat = "CAT2" Then
      keys.key = 1
  End

2nd pass
Code:

start.01 = 13
start.02 = 3
start.03 = 3
read each record and...
Do
  Parse Var record rectype 3 .
  key = substr(record,start.rectype,6)
  If keys.key Then
    Say record
End


I suspect the record parsing could be tuned better but this is an idea to try if you are so inclined. Also,I didn't count characters in the strings so the numbers are probably off
Back to top
View user's profile Send private message Visit poster's website
santa
Beginner


Joined: 16 Mar 2007
Posts: 3
Topics: 3

PostPosted: Thu Mar 22, 2007 11:55 pm    Post subject: Reply with quote

kolusu wrote:
santa,

Please do NOT post the same Question in multiple forums.

1. what is the LRECL and RECFM of the input?

2. What is the position and format of the codes z11111,z22222,z33333,z44444 ? for 01 records it is at a different position and for 02 records it is at different position. is that correct?

3. What is the position of the word "cat2" ?

Kolusu



1.LRECL = 208

RECFM = FB

2. 01 record has code starting at 12th char(6 char long)
for 02, 03 rec has code at 3rd char.

3. CAT2 is present only in Record 02 at position starting at char no 205-208
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group