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

i need following using JCL --SORT UTILITY.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ravikumarreddy
Warnings : 1

New User


Joined: 29 Jul 2005
Posts: 23

PostPosted: Fri Mar 10, 2006 12:16 pm
Reply with quote

HI,
here i have a question which is suppose to answer thru JCL.

MY FILE LIKE FOLLOWING:

Code:

 PRC-NB     COUNT
  101         20
  101         30
  102         40
  102         50
  103         60
  103         70

--------------------------------------------------------------
OUT PUT NEEDS LIKE FOLLOWING

Code:

 PRC-NB     COUNT
  101         50
  102         90
  103        130

******************************************
I NEED ABOVE THRU JCL.....
Back to top
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Fri Mar 10, 2006 3:56 pm
Reply with quote

HI,

Code:

//JOB CARD...
//STEP1 EXEC PGM=SORT
//SORTIN      DD DSN=INPUT FILE
//SORTXSUM DD DSN=OUTPUT FILE
//SYSIN DD *
 SORTFIELDS=(1,3,CH,A)
 SUMFIELDS=(5,2,CH)
/*
//


CORRECTIONS WELCOMED

Thanks,
Rajesh
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Fri Mar 10, 2006 5:23 pm
Reply with quote

Hi,

The about jcl is correct but i doubt about
Quote:
SUMFIELDS=(5,2,CH)

I think the the SUM FIELDS needs to be numeric

should be
Code:
SUMFIELDS=(5,2,ZD)


This will do i hope..

Regards,
Back to top
View user's profile Send private message
Mane Sagar

New User


Joined: 12 Jul 2005
Posts: 41
Location: mumbai

PostPosted: Fri Mar 10, 2006 6:53 pm
Reply with quote

Hi,

fixdoubts is very right.

It has to be
Code:
SUM FIELDS=(5,2,ZD)

Regards,
Sagar.
Back to top
View user's profile Send private message
manyone

New User


Joined: 09 Mar 2006
Posts: 9

PostPosted: Fri Mar 10, 2006 10:21 pm
Reply with quote

however the sum will be truncated if it's 100 or over because it's too short. to fix it, you need

INREC FIELDS=(1,3,X,C'0000',5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,6,ZD)

if you want record count too (here, i made it packed) , try this

INREC FIELDS=(1,3,X,X'00001C',X,C'0000',5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,PD,9,6,ZD)
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 10, 2006 10:48 pm
Reply with quote

Since your records are already in sorted order, you can avoid a sort, and use copy or merge which are more efficient.

Here are two ways to do this with DFSORT:

Method 1: COPY with SECTIONS and TRAILER1

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
  101         20
  101         30
  102         40
  102         50
  103         60
  103         70
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(3,3,
      TRAILER3=(1,11,TOT=(12,5,FS,TO=FS,LENGTH=5)))
/*


Method 2: MERGE with SUM

Code:

//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD *
  101         20
  101         30
  102         40
  102         50
  103         60
  103         70
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION ZDPRINT
  MERGE FIELDS=(3,3,CH,A)
  SUM FIELDS=(12,5,ZD)
/*
Back to top
View user's profile Send private message
vin78dotcom
Warnings : 2

New User


Joined: 06 Dec 2005
Posts: 7
Location: pune

PostPosted: Tue Nov 20, 2007 4:02 pm
Reply with quote

hello,
thanks for the different methods of sort and sums..
it worked for me ...but can you please let me know how to remove leading zeroes from the output summations.
e.g my output sum is coming as:000001
and i wanted just: 1 where zeroes should be replaced by spaces.
I used the COPY with SECTIONS and TRAILER1 techniques.

thnks
vinay
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 Nov 20, 2007 9:28 pm
Reply with quote

With DFSORT, TO=FS does remove the leading zeros. The output would be:

Code:

  101         50
  102         90
  103        130


Perhaps you're not using DFSORT. Check the //SYSOUT messages. If they start with ICE (e.g. ICE000I), then you're using DFSORT. If you are using DFSORT, then post your control statements and //SYSOUT messages and the output you're getting. If you're not using DFSORT, then I can't help you.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
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 JCL sort card - get first day and las... JCL & VSAM 9
No new posts REASON 00D70014 in load utility DB2 6
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top