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

SORT requirement


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

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Fri Jan 25, 2008 12:52 pm
Reply with quote

Below is the requirement we have, please let me know how can we handle it using sort.

I have the file with following fields (lrecl = 43)

Code:

FIELD1        FIELD2         FIELD3
8/AN          15/SNUM        20/AN
--------      --------       ------
123/2345       400.00        AAA111
111/896        300.00        BBA222
111/896        250.00        BBA222
111/896       -100.00        BBA222
888/970        800.00        CDD333
888/970       -100.00        CDD333
910/999        200.00        XYX444
910/999        200.00        XYX444


We need to sort the above file using the field1 and Field3 as key fields and sum the amount for the key fields except the records with field1 value
of '888/970' has to be written in the o/p file as it is from i/p file without summation. The o/p file also need to reformatted to have the first26 bytes alone from i/p file, rest being spaces for all the records except '888/970' records.

Hence, the o/p file should look like the one below.(LRECL=43)

Code:

FIELD1        FIELD2         FIELD3
8/AN          15/SNUM        20/AN
--------      --------       ------
111/896        450.00        BBA
123/2345       400.00        AAA
888/970        800.00        CDD333
888/970       -100.00        CDD333
910/999        400.00        XYX


Thanks in advance,
Chinni.
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 Jan 25, 2008 10:55 pm
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 (FB/43)
//SORTOUT DD DSN=...  output file (FB/43)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,
    OVERLAY=(9:9,15,SFF,TO=ZD,LENGTH=15,44:8C'0')),
    IFTHEN=(WHEN=(1,8,CH,EQ,C'888/970'),OVERLAY=(44:SEQNUM,8,ZD))
  SORT FIELDS=(1,8,CH,A,24,20,CH,A,44,8,ZD,A)
  SUM FIELDS=(9,15,ZD)
  OUTREC IFOUTLEN=43,
    IFTHEN=(WHEN=INIT,
      OVERLAY=(9:9,15,ZD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-))),
    IFTHEN=(WHEN=(1,8,CH,NE,C'888/970'),BUILD=(1,26))
/*
Back to top
View user's profile Send private message
chinnielr

New User


Joined: 11 Jul 2005
Posts: 87

PostPosted: Mon Jan 28, 2008 2:16 pm
Reply with quote

Thanks Frank. It really helps us.!!! Thanks again!!!
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 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 Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top