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

Need a better approach to perform sum and total using sort


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

New User


Joined: 28 Sep 2010
Posts: 7
Location: Chennai

PostPosted: Fri Nov 26, 2010 7:47 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Nov 30, 2010 2:16 am
Reply with quote

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
View user's profile Send private message
vasanthavijayan

New User


Joined: 28 Sep 2010
Posts: 7
Location: Chennai

PostPosted: Tue Nov 30, 2010 11:27 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Nov 30, 2010 11:32 am
Reply with quote

Hello,

Is this now working or is there still a question/problem?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Dec 01, 2010 2:43 am
Reply with quote

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
View user's profile Send private message
vasanthavijayan

New User


Joined: 28 Sep 2010
Posts: 7
Location: Chennai

PostPosted: Thu Dec 02, 2010 12:59 pm
Reply with quote

It worked. icon_biggrin.gif
Thanks everyone for your time and help..Esp Kolusu and Frank.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top