View previous topic :: View next topic
|
Author |
Message |
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
Hi all,
I have a requirement where I need to sort group of record based on field of 1st record only.
Code: |
A1
B1xxxxxxfield3
b11
b12
b13
b14
B2xxxxxxfield2
b21
b22
b23
b24
A1
B3xxxxxxfield4
b31
b32
b33
b34
A1
B4xxxxxxfield1
b41
b42
b43
b44
|
I want output should be
Code: |
A1
B4xxxxxxfield1
b41
b42
b43
b44
A1
B2xxxxxxfield2
b21
b22
b23
b24
B1xxxxxxfield3
b11
b12
b13
b14
A1
B3xxxxxxfield4
b31
b32
b33
b34
|
Based on field can we sort and copy group of records in between ?
Thanks |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
Back to top |
|
|
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
Sorry Skolusu..
My requirement was not there in sorttrk pdf.
Among series of 5 records
based on 1st record field we need to sort
such that all other 4 records also should be copied along with 1st record.
Is that possible using dfsort/icetool ?
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
based on 1st record field we need to sort
such that all other 4 records also should be copied along with 1st record.
Is that possible using dfsort/icetool ? |
Yes, that is what WHEN=GROUP provides. . . |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
GSaikrishna,
Did you even look at the example in the Sort trick document? You provide very little information. Show us in detail , how the first record is identified and which field from the 1st record needs to be used to sort the group of records. What is the LRECL/RECFM of the input and output files? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
GSaikrishna,
Also, tell us how the A1 records fit in. They don't seem to be part of the 5 record groups so how are they to be sorted vs those groups? |
|
Back to top |
|
|
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
My file is group of cashletter.
A1 is like header for a each cashletter.
All records followed by A1 till next A1 is a bundle.
Record B* followed by field is header for bundle. field is the one which I need to sort.
For each cashletter they can be many bundles.
My file is a VB file record length is 500.
Thanks. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
GSaikrishna,
with little information you provided, here is a DFSORT JCL which will give you the desired results. I assumed that A1 record is just a header and it has nothing else on that record and we can create it by using a Header3
I also assumed that the field you want to Sort is at pos 13( inclusive of RDW) for a length of 6 bytes . The record B has 'x' at position 7 (inclusive of RDW) which has the field to be sorted
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your input VB file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,14X,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(19,2,CH,EQ,C'A1'),PUSH=(5:ID=8)),
IFTHEN=(WHEN=GROUP,BEGIN=(21,1,CH,EQ,C'X'),PUSH=(13:27,6)),
IFTHEN=(WHEN=(13,8,ZD,EQ,1),OVERLAY=(13:6X))
SORT FIELDS=(13,6,CH,A),EQUALS
OUTFIL OMIT=(19,2,CH,EQ,C'A1'),BUILD=(1,4,19),
REMOVECC,SECTIONS=(5,8,HEADER3=('A1'))
//* |
|
|
Back to top |
|
|
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
Thanks so much Skolusu.
Sorry for not making clear for you
Code: |
A2YYYY/MM/DD000
25sai000[b]004092405257[/b]
**** header for 1st bundle ***
b11
b12
b13
b14
********* end of 1st cashletter *********
A2YYYY/MM/DD000
25sai000[b]003992187702[/b]
**** header for 1st bundle ***
b21
b22
b23
b24
25sai000[b]003992187066[/b]
**** header for 2nd bundle ***
b31
b32
b33
b34
********* end of 2nd cashletter *********
|
Here based on highlighted 12 didgit number to be sorted.
The following 4 records after highlighted 12 digit number has nothing to do and just be copied along with 25 record in sort
My requirement is
all the bundles to be sorted in a cashletter
and then
all cash letters to be sorted in a file.
output should be
Code: |
A2YYYY/MM/DD000
25sai000[b]003992187066[/b]
**** header for 2nd bundle in input ***
b31
b32
b33
b34
25sai000[b]003992187702[/b]
**** header for 1st bundle in input***
b21
b22
b23
b24
********* end of 2nd cashletter in input*********
A2YYYY/MM/DD000
25sai000[b]004092405257[/b]
**** header for 1st bundle in input***
b11
b12
b13
b14
********* end of 1st cashletter in input *********
|
I tried to make it claer as much this time.
Its a complex one, trying to figure any simple way to sort it.
Thanks in advance.
Sai |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
GSaikrishna wrote: |
I tried to make it claer as much this time. Its a complex one, trying to figure any simple way to sort it. |
GSaikrishna,
You still are not clear. I think it is a simple request and only you are making it complicated.
The output you show doesn't make sense as to why this record "********* end of 2nd cashletter in input********* " is not with its group. Is it a typo?
Also you haven't answered my question of generating the A2 record dynamically. Now you show 15 bytes of data on the header. Is that the only data? or does the A2 record have full data up to 500? do you need to preserve the whole data record?
How do I recognize the start of a group? Is it the string "A2" (your first post showed "A1"). How do you identify the 12 digit number record? does it start with 25? |
|
Back to top |
|
|
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
"********* end of 2nd cashletter in input********* is just a comment you can understand. Its not in the file..
AnYYYY/MM/DD000
in A reocrd A is common always
n is number ranging 1 to 5 ( mon to friday )
n = 2 is for tuesday, it varies for day
YYYY/MM/DD is the date
Yes 15 bytes is only data for header of each cashletter
25sai is the record having 12 digit number and it is header of bundle for every cash letter
following 4 records after 25sai are 1 bundle..
I am trying it to do in easytrieve and I am finding problem there also.
Is it possible to close and open a file in easytrieve ?
Thanks |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
GSaikrishna,
The following DFSORT JCL will give you the desired results.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input VB 500 lrecl File,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,35X,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(40,1,CH,EQ,C'A'),PUSH=(5:ID=8,40,15)),
IFTHEN=(WHEN=GROUP,BEGIN=(40,5,CH,EQ,C'25SAI'),PUSH=(28:48,12))
SORT FIELDS=(28,12,CH,A),EQUALS
OUTFIL OMIT=(40,2,CH,EQ,C'A2'),BUILD=(1,4,40),
REMOVECC,SECTIONS=(5,8,HEADER3=(13,15))
//* |
GSaikrishna wrote: |
I am trying it to do in easytrieve and I am finding problem there also. Is it possible to close and open a file in easytrieve ? |
As I said earlier it is a simple request and you are just making it complicated. Why would you want to use easytrieve which does not have any Sorting algorithm built into it? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
With Easytrieve, COBOL, Assembler or any other programming language it is nearly always wrong to open and close files over and over.
Organizations that review code before turnover/promotion to Production will reject such code.
As SKolusu mentions, you are making this far too difficult (unless, we still do not understand the issue). . . |
|
Back to top |
|
|
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
I tried by extracting all 25sai records into a file in sort order and started framing the output file by easytrieve or cobol in what ever i needed format
My requirement in simple to say is
25sai record followed by 4 records will be a group. or set ( total 5 records )
my sort key is only in 25sai record which is 12 digit number.
I need to copy group of 25sai set into output based on 12 digit number.
here if I have A record before 25sai record , i need to copy it along with my set ( 6 records= 1 A record + 1 25sai record + 4 records set )
else only ( 25sai record + 4 records ) which will be 5 records.
I know I am irritating with my requests.
Thanks,
Sai |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
GSaikrishna,
Did you try running the job I provided ? |
|
Back to top |
|
|
GSaikrishna
New User
Joined: 24 May 2008 Posts: 13 Location: India
|
|
|
|
I have run your job but it throwed me syntax error.
I was using syncsort older version and it could nt have new features when=group work in my LPAR.
Thanks,
Sai |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Why did you post in the DFSORT Forum if you are using Syncsort?????
I'm locking this thread. Please post in the appropriate Forum in the future instead of wasting peoples' time! |
|
Back to top |
|
|
|