View previous topic :: View next topic
|
Author |
Message |
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Hi All,
I have a following requirement
File 1 RECFM=FB, LRECL=3000 --> Not in sorted order
Key position 1 to 3 and 35 to 44
File-2 --> Sorted Order and unique records<Max No of records can be 5200>
Key
1 to 3 and 5 to 14
I need to copy data from file 1 while preserving the order.Each split should contain data for only 400 policies.There will always be match for file-2 in file-1.
Can we do this using sort? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I have no idea what you want to do from your description.
Is File-2 an input file or an output file? If File-2 is an input file, how is it used?
Are you splitting to multiple output files? If so, what is the maximum number? Or do you mean something else by "split" - what?
Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
@Frank
My requirement is similar to this but not that much complicated.
File2 is input file and all the data are unique.It is a driver file.We can split that in 10 parts.
The remaining task is to match the records and preserve there order and report it to output splits.
//File1 DD DSN=file with 1300000 records.Having duplicates and unsorted.
//Driver1 DD DSN=400 keys< all unique>
//Split1 DD DSN=Data of the above 400 keys.
<Similar for other splits>
Key has 2 parts.
File1 has key at first 3 bytes and from position 35 to 10 bytes. RECFM=FB,LRECL=3000
File2 has key at first 3 bytes and from position 4 to 10 bytes.RECFM=FM,LRECL=80
Thanks. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
HI All,
I have written a sort with below sortin statement.
JOINKEYS F1=IN1,FIELDS=(4,10,A)
JOINKEYS F2=IN2,FIELDS=(41,10,A)
REFORMAT FIELDS=(F2:1,213)
OPTION COPY
The problem with the output is that it is sorted.I want to preserve the order in which they occurred in IN2.
THanks. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Use JNF2CNTL to add sequence numbers to the F2 records. Then in the main task (SYSIN), SORT by the joined records by the sequence numbers and remove the sequence numbers. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Thanks Frank.
It worked but I was not able to remove the seqnum from the output file.
Code: |
//SYSIN DD *
JOINKEYS F1=IN1,FIELDS=(4,10,A)
JOINKEYS F2=IN2,FIELDS=(41,10,A)
REFORMAT FIELDS=(F2:1,221)
SORT FIELDS=(214,8,ZD,A)
/*
//JNF2CNTL DD *
INREC OVERLAY=(214:SEQNUM,8,ZD)
/*
|
Do I need to write one more step to remove the seqnum or can we do it in same step?
Thanks. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Same pass. Just use OUTREC or OUTFIL to remove the sequence numbers.
Code: |
//SYSIN DD *
JOINKEYS F1=IN1,FIELDS=(4,10,A)
JOINKEYS F2=IN2,FIELDS=(41,10,A)
REFORMAT FIELDS=(F2:1,221)
SORT FIELDS=(214,8,ZD,A)
OUTREC BUILD=(1,213)
/*
|
|
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
I was doing OUTFIL BUILD so I was getting an error.
Thanks Frank. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
What error?
Code: |
OUTFIL BUILD=(1,213)
|
could be used instead of OUTREC. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Hi,
I was using REFORMAT FIELDS=(F2:1,213) so it was giving an error.
Is there any way that we can also specify condition for File-2.For example if the character at 35th column is '2' then only perform the join else skip the record.
Thanks. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rgupta71 wrote: |
Hi,
I was using REFORMAT FIELDS=(F2:1,213) so it was giving an error.
Is there any way that we can also specify condition for File-2.For example if the character at 35th column is '2' then only perform the join else skip the record.
Thanks. |
It would have saved a lot of your time as others time had you specified all the requirements in one go instead providing it in bits and pieces. To answer your question yes you can filter records with an INCLUDE condition
Change your JNF2CNTL to the following
Code: |
//JNF2CNTL DD *
INCLUDE COND=(35,1,CH,EQ,C'2')
INREC OVERLAY=(214:SEQNUM,8,ZD)
/* |
|
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Sorry , but this requirement was not there in the beginning.
Thanks everyone. |
|
Back to top |
|
|
|