IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort copy n records based on field of 1t record


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Tue Mar 30, 2010 11:52 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 30, 2010 11:57 pm
Reply with quote

GSaikrishna,

check out the Smart DFSORT trick "Include or omit groups of records/Sort groups of records" here

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
Back to top
View user's profile Send private message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Wed Mar 31, 2010 2:04 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Mar 31, 2010 2:27 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Mar 31, 2010 3:09 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 31, 2010 3:25 am
Reply with quote

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
View user's profile Send private message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Wed Mar 31, 2010 3:43 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Mar 31, 2010 9:48 pm
Reply with quote

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
View user's profile Send private message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Thu Apr 01, 2010 12:09 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Apr 01, 2010 1:59 am
Reply with quote

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
View user's profile Send private message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Thu Apr 01, 2010 2:35 am
Reply with quote

"********* 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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Apr 01, 2010 2:54 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu Apr 01, 2010 3:26 am
Reply with quote

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
View user's profile Send private message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Fri Apr 02, 2010 5:20 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Apr 05, 2010 8:40 pm
Reply with quote

GSaikrishna,

Did you try running the job I provided ?
Back to top
View user's profile Send private message
GSaikrishna

New User


Joined: 24 May 2008
Posts: 13
Location: India

PostPosted: Wed Apr 07, 2010 1:30 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 07, 2010 1:42 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Syncsort help SYNCSORT 3
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top