|
View previous topic :: View next topic
|
| Author |
Message |
vasanthavijayan
New User
Joined: 28 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
Hi,
I am curious to know the other ways to do my requirement using sort.
| Code: |
Input Layout.LRECL=80,RECFM=FB
------ - -PICTURE- -NUMBER START END LENGTH
F1 S9(9) 2 1 5 5
F2 9(5) 3 6 10 5
F3 X(40) 4 11 50 40
F4 S9(17) 5 51 59 9
F5 XXX 6 60 62 3
F6 X 7 63 63 1
F7 X 8 64 64 1
F8 X 9 65 65 1
F9 X 10 66 66 1
F10 X 11 67 67 1
F11 X 12 68 68 1
F12 X 13 69 69 1
F13 S9(11)V99 14 70 76 7
F14 X 15 77 77 1
FILLER XXX 16 78 80 3
Output Layout-LRECL=35,RECFM=FB
------- -PICTURE- -NUMBER START END LENGTH
F5 XXX 2 1 3 3
F14 X 3 4 4 1
F6 X 4 5 5 1
F7 X 5 6 6 1
F8 X 6 7 7 1
F9 X 7 8 8 1
F10 X 8 9 9 1
F11 X 9 10 10 1
F12 X 10 11 11 1
F13 S9(11)V99 11 12 18 7
CNT 9(13) 12 19 31 13
FILLER X(4) 13 32 35 4 |
I have mapped the Input file fields names to Output file.
1. The input file has to sorted based on F5,F14,F6,F7,F8,F9,F10,F11,F12.
2. The F13 field value should be added for all the records which have same value in F5,F14,F6,F7,F8,F9,F10,F11,F12 fields.
3. The CNT field should have the count of records which have the same value in F5,F14,F6,F7,F8,F9,F10,F11,F12 fields.
The output file should not have any duplicates based on F5,F14,F6,F7,F8,F9,F10,F11,F12 fields.
| Code: |
Input
F1.....F5 F6 F7 F8 F9 F10 F11 F12 F13 F14
AAA N N N N N N N 234.05 0
AAA N N N N N N N 34.05 0
AAA N N N N N Y N -234.05 0
AAA N N N N N Y N 234.05 2
AAA N N Y N N N N 234.05 0
BBB N N N N N N N 234.05 5
BBB N N N N N N N 234.05 5
BBB N N N N N N N 234.05 5
Output
F5 F14 F6 F7 F8 F9 F10 F11 F12 F13 CNT
AAA 0 N N N N N N N 268.10 2
AAA 0 N N N N N Y N -234.05 1
AAA 2 N N N N N Y N 234.05 1
AAA 0 N N Y N N N N 234.05. 1
BBB 5 N N N N N N N 702.15 3
|
The sort which i have used.
| Code: |
INREC BUILD=(1:60,3,4:77,1,5:63,1,6:64,1,7:65,1,8:66,1,9:67,1,
10:68,1,11:69,1,12:70,7,X'0000000000001C')
SORT FIELDS=(1,11,CH,A)
SUM FIELDS=(12,7,PD,19,7,PD)
OUTREC BUILD=(1,18,19,7,PD,TO=ZD,LENGTH=13,4X) |
Thanks in advance. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Question:
For input, you show:
| Code: |
F13 S9(11)V99 11 12 18 7
|
which would make F13 a 13-byte ZD field, but you seem to be treating it as a 7-byte PD field (COMP-3).
Then for output, you show:
| Code: |
F13 S9(11)V99 11 12 18 7
|
which also seems to be inconsistent.
Is F13 a ZD or PD input field? How long is it? Which format do you want for output? |
|
| Back to top |
|
 |
vasanthavijayan
New User
Joined: 28 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
Input :
| Code: |
F13 PIC S9(11)V99 COMP-3 14 70 76 7.
|
Output:
Modified the length of output field(F13) as it is insufficient.
| Code: |
.
.
F13 PIC S9(15)V99 COMP-3 11 12 20 9.
CNT PIC 9(13) 12 21 33 13.
FILLER PIC X(02) 13 34 35 2.
|
Also the sort card which I used have some changes.
| Code: |
INREC BUILD=(1:60,3,4:77,1,5:63,1,6:64,1,7:65,1,8:66,1,9:67,1,
10:68,1,11:69,1,12:X'0000',14:70,7,X'0000000000001C')
SORT FIELDS=(1,11,CH,A)
SUM FIELDS=(12,9,PD,21,7,PD)
OUTREC BUILD=(1,20,21,7,PD,TO=ZD,LENGTH=13,2X)
|
|
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Is this now working or is there still a question/problem? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
vasanthavijayan,
Use the following DFSORT JCL which will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input FB 80 byte file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC BUILD=(60,03, $ F5
77,01, $ F14
63,07, $ F6,F7,F8,F9,F10,F11,F12
70,07) $ F13
SORT FIELDS=(1,11,CH,A),EQUALS
OUTFIL BUILD=(35X),REMOVECC,NODETAIL,
SECTIONS=(1,11,
TRAILER3=(1,11,TOT=(12,7,PD,PD,LENGTH=9),
COUNT=(M11,LENGTH=13)))
//* |
|
|
| Back to top |
|
 |
vasanthavijayan
New User
Joined: 28 Sep 2010 Posts: 7 Location: Chennai
|
|
|
|
It worked.
Thanks everyone for your time and help..Esp Kolusu and Frank. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|