Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SORT requirement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SORT requirement
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 Moderator


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

PostPosted: Fri Jan 25, 2008 10:55 pm    Post subject:
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    Post subject: Reply to: SORT requirement
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. Mainframe Developer requirement in Ku... capricorn Mainframe Jobs 0 Sun Oct 23, 2016 3:49 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us