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

Summing records using SORT


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

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Fri Mar 30, 2007 2:10 am
Reply with quote

I have a file where in there are a number of detail records(identified by '20' in the first two bytes) and a single trailer record(identified by '30' in the first two bytes). In the trailer record, I need to populate the bytes 3-7 (at position 3 of length 5 bytes) in the packed decimal format S9(9) COMP-3 that would contain the total number of type '20' records.

My file looks like:

Code:

209000001360117005       BP   YN   
205319191360115002       BP   YN   
205319390000004010       DV   NN   
205319390000001016       DV   NN   
209000001360121007       BP   YN   
30                               


How can we do this using SORT ? I do not want to use ICEMAN/ICETOOL/SYNCSORT.

Thanks in advance !
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 30, 2007 2:30 am
Reply with quote

Try COBOL, Assembler, PLI or REXX.......
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Fri Mar 30, 2007 2:39 am
Reply with quote

Using COBOL/REXX program is ruled out... looking for some way to do it only using SORT
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: Fri Mar 30, 2007 2:46 am
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  OMIT COND=(1,2,CH,EQ,C'30')
  OUTFIL REMOVECC,
    TRAILER1=('30',COUNT=(TO=PD,LENGTH=5))
/*


Quote:
How can we do this using SORT ? I do not want to use ICEMAN/ICETOOL/SYNCSORT.


Hmmm ... what exactly do you mean by "SORT"? "ICEMAN" is an alias for DFSORT, Syncsort and CA-Sort. PGM=ICEMAN is the same as PGM=SORT. DFSORT is certainly not Syncsort, but it is ICEMAN. ICETOOL is part of DFSORT.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Mar 30, 2007 2:59 am
Reply with quote

Hello,

Who makes such "rules"?

I suspect that most of the people posting topics on these forums have "programming" somewhere in their job description. How is then "ruling out" code as an alternative justified (or even tolerated)?

While i'm very much in favor of using our tools and their special features, i'm not in favor of someone handing out assignments with "Ok, Joe Programmer - here's a coding task that you are not allowed to write code for". How silly!
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Fri Mar 30, 2007 3:00 am
Reply with quote

Thanks Frank for the reply.

Is it possible to achieve the above using PGM=SORT ?
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Fri Mar 30, 2007 3:04 am
Reply with quote

Dick, your concern is very valid !

Quote:
Who makes such "rules"?
I suspect that most of the people posting topics on these forums have "programming" somewhere in their job description. How is then "ruling out" code as an alternative justified (or even tolerated)?


Its the requirements that drive such rules. Even Iam a programmer but have to follow the requirements that Iam provided with.

My intent of posting the query was to take some help from experts and not to start a chain of debates and fiery replies.

Anyways, thanks Dick for you advice !!!
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: Fri Mar 30, 2007 3:05 am
Reply with quote

Quote:
Is it possible to achieve the above using PGM=SORT ?


Just use PGM=SORT instead of PGM=ICEMAN in the job I showed ... it's the same thing!

Code:

//S1    EXEC  PGM=SORT
.... everything else is the same
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Fri Mar 30, 2007 3:06 am
Reply with quote

Thanks Frank ! Hope that helps !

Sorry for missing that part about PGM=SORT.

Thanks again !
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Mar 30, 2007 3:14 am
Reply with quote

Hello tarunbhardwajleo,

You're welcome icon_smile.gif

However, I've not yet seen a user requirement that specified that their objective must not be coded in a program icon_smile.gif

Good luck.
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Tue Apr 03, 2007 2:11 am
Reply with quote

Hi Frank,

I tried executing the SORT step as coded by you but Iam getting the following message:

Code:
SYSIN :                                               
  OPTION COPY                                         
  OMIT COND=(1,2,CH,EQ,C'30')                         
  OUTFIL REMOVECC,                                   
    TRAILER1=('30',COUNT=(TO=PD,LENGTH=5))           
                          *                           
 /*                                                   
 *                                                   
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR             
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT       
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000         


Could you pls help me out with it ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Apr 03, 2007 2:32 am
Reply with quote

Hello,

Please note that you are using Syncsort. You can tell that from the "WER" messages. At many sites, executing ICEMAN actually invokes Syncsort, not the IBM product. That appears to be what is happening with your job.

Frank's solution is for DFSORT. The control statements for both sorts are not the same.
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: Tue Apr 03, 2007 3:03 am
Reply with quote

tarunbhardwajleo,

The job runs fine with DFSORT. As Dick pointed out, the WER messages indicate you're using Syncsort, not DFSORT.

I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.

If you or anyone else on this board would like some documents prepared by the DFSORT Team that describe what we see as the advantages of DFSORT over Syncsort, as well as considersations for migrating from Syncsort to DFSORT, send me an e-mail offline (yaeger@us.ibm.com). Please put "DFSORT" somewere in your Subject line to catch my attention.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Apr 03, 2007 3:42 am
Reply with quote

Hello,

With Syncsort, this:
Code:
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*                     
//SYSPRINT DD SYSOUT=*                   
//SORTIN DD *                             
1                                         
2                                         
3                                         
4                                         
5                                         
6                                         
//SORTOUT DD SYSOUT=*                     
//SORTOUT1 DD SYSOUT=*                   
//SYSIN DD *                             
  OPTION COPY                             
  OUTFIL REMOVECC,                       
    TRAILER1=('30',COUNT)                 
/*                     


gives:
Code:
1                   
2                   
3                   
4                   
5                   
6                   
30       6           

and
Code:
SYSIN :                                                             
  OPTION COPY                                                       
  OUTFIL REMOVECC,                                                   
    TRAILER1=('30',COUNT)                                           
WER108I  SORTIN   :  RECFM=FB   ; LRECL=    80; BLKSIZE=    80       
WER110I  SORTOUT  :  RECFM=FB   ; LRECL=    80; BLKSIZE=    80       
WER405I  SORTOUT  :  DATA RECORDS OUT          6; TOTAL RECORDS OUT 
WER054I  RCD IN          6, OUT          6                           
WER169I  RELEASE 1.1D BATCH 0426 TPF LEVEL 3A                       
WER052I  END SYNCSORT - MSRDSSRT,STEP1,,DIAG=A800,EAC8,8006,244C,E0EA


If time permits later tonight, i'll try to look into making the count PD. Feel free to have a go at it yourself - other than a bit of machine time it won't cost you anything to experiment icon_smile.gif
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Tue Apr 03, 2007 9:51 pm
Reply with quote

Hi Dick,

Thanks for your assistance. Just one last query, is it possible to have COUNT in packed decimal format that start from position (after'30') and has length 5 bytes? Thats S9(9) comp-3.

Thanks in advance !
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Apr 04, 2007 12:50 am
Reply with quote

You're welcome icon_smile.gif

If Syncsort will do it, i'm not sure how to do it directly. That's what i had hoped to look into last night, but ran out of time.

While it would be tedious, additional steps could be added to separate and reformat the "trailer" so the count would be converted to packed-decimal.

After the reformat, the 2 files could then be combined putting the trailer back together with the data records.

Seems like a real waste of both people and machine resources to do it this way.

Maybe someone has experience generating a trailer with a packed-decimal count in the trailer record using Syncsort.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Apr 04, 2007 12:56 am
Reply with quote

tarunbhardwajleo wrote:
Thanks for your assistance. Just one last query, is it possible to have COUNT in packed decimal format that start from position (after'30') and has length 5 bytes? Thats S9(9) comp-3.
Have you checked your Syncsort manual?
Back to top
View user's profile Send private message
tarunbhardwajleo

New User


Joined: 23 Feb 2007
Posts: 25
Location: Dallas, TX

PostPosted: Wed Apr 04, 2007 1:11 am
Reply with quote

yeah, I checked it but couldn't get a break thru with it. COUNT is an 8 digit right justified field with leading zeros suppressed. Iam just trying to figure out a way to convert it to PD S9(9) comp-3.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Apr 04, 2007 1:36 am
Reply with quote

Hello,

Another thought that comes to mind is to run the "copy" creating only the trailer. Then, reformat the trailer from what you have to PD. Lastly combine the 2 files into one.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 1
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top