View previous topic :: View next topic
|
Author |
Message |
Deepa Natarajan
New User
Joined: 06 Jan 2008 Posts: 11 Location: India
|
|
|
|
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 |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
Hi,
First record with record type B in the input is not added in your output shown.
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 |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
Also Provide us the offset and length of each field. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
What is LRECL\RECFM of the input and output files? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
Thanks Sambhaji for clearing my doubt. Now i got it |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
|
|