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

can this be done using DFSORT


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

New User


Joined: 06 Jan 2008
Posts: 11
Location: India

PostPosted: Mon May 31, 2010 10:17 am
Reply with quote

Hi,

I have a requirement lik this.

I/P File:
Code:
F1  F2    F3    F4    F5   F6
B  100  100  150  200 
B  120  140  200  220  30
B  150  110  210  120  30
K  000  000  000  000  30
B  180  100  210  130  55
B  050  210  130  170  55
K  000  000  000  000  55

where
F1 => rec type
F2, F3, F4, F5 => Amount fields
F6 => State code

O/P File:

Code:
B  100  100  150  200 
B  120  140  200  220  30
B  150  110  210  120  30
K  270  250  410  340  30
B  180  100  210  130  55
B  050  210  130  170  55
K  230  310  340  300  55


When Record type "B" has same state code, then the amount values from the Fields F2, F3, F4 and F5 should be added and replaced in the K record.

can this be done using DFSORT?
Thanks for your help
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon May 31, 2010 10:48 am
Reply with quote

Hi,

First record with record type B in the input is not added in your output shown.
Code:
B  100  100  150  200
This means that if you don't have F6 in your input we should not add it in the output? Instead it should be a separate record.

Or provide us the rules to derive the output.

Provide LRECL and RECFM of your input and output file.
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon May 31, 2010 11:00 am
Reply with quote

Also Provide us the offset and length of each field.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon May 31, 2010 11:23 am
Reply with quote

What is LRECL\RECFM of the input and output files?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon May 31, 2010 11:28 am
Reply with quote

nelson.pandian wrote:
This means that if you don't have F6 in your input we should not add it in the output? Instead it should be a separate record.

B records should be considered for addition only if it's State code matches with State code of K record...
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon May 31, 2010 12:28 pm
Reply with quote

Thanks Sambhaji for clearing my doubt. Now i got it icon_biggrin.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon May 31, 2010 12:54 pm
Reply with quote

Deepa Natarajan

If order of B records within block is not a concern then below sortstep will give you desired result.

I have assumed RECFM=FB and LRECL=80
Code:

//S1    EXEC  PGM=SORT                                                 
//SYSOUT    DD  SYSOUT=*                                               
//SORTIN DD *                                                         
B  100  100  150  200                                                 
B  120  140  200  220  30                                             
B  150  110  210  120  30                                             
K  000  000  000  000  30                                             
B  180  100  210  130  55                                             
B  050  210  130  170  55                                             
K  000  000  000  000  55                                             
/*                                                                     
//SORTOUT DD SYSOUT=*                                                 
//SYSIN    DD    *                                                     
 INREC IFTHEN=(WHEN=GROUP,END=(1,1,CH,EQ,C'K'),PUSH=(81:ID=8,89:SEQ=8))
 SORT FIELDS=(81,8,ZD,A,89,8,ZD,D)                                     
 OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'K'),PUSH=(97:24,2)),     
        IFTHEN=(WHEN=(24,2,CH,EQ,97,2,CH),OVERLAY=(99:4,18))           
 OUTFIL REMOVECC,OMIT=(1,1,CH,EQ,C'K'),                               
 SECTIONS=(81,8,                                                       
 TRAILER3=(1:C'K',4:TOT=(99,3,ZD,EDIT=(TTT)),2X,             
                    TOT=(104,3,ZD,EDIT=(TTT)),2X,           
                    TOT=(109,3,ZD,EDIT=(TTT)),2X,           
                    TOT=(114,3,ZD,EDIT=(TTT)),2X,97,2)),     
 BUILD=(1,80)                                               
/*   

Output will be:
Code:

B  150  110  210  120  30
B  120  140  200  220  30
B  100  100  150  200   
K  270  250  410  340  30
B  050  210  130  170  55
B  180  100  210  130  55
K  230  310  340  300  55


If you want output in the same order as input you need one more sortstep which can do so. Let us know if it suits your requirement...
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts DFSORT - VB file RDW getting overridden DFSORT/ICETOOL 3
Search our Forums:

Back to Top