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

Sum fields by using sortcard


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Asha chowdary

New User


Joined: 20 Mar 2015
Posts: 5
Location: Bangalore

PostPosted: Mon Mar 23, 2015 11:11 am
Reply with quote

Hi,

I want to learn sort card for sum the different fields.
I have two different types of amounts in my input file.

Amount field format is WS-RPT-ACCUM-AMT PIC -ZZZ,ZZZ,ZZZ,ZZ9.99.

Ex: Type of amount total amount

A 100
B 50
A 200
B 70

I want to add 'A' type of amount and 'B' type of amount.and in output file i need to get

A 300
B 120.


Can any body guide me how to code for this?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7311
Location: Inside the Matrix

PostPosted: Mon Mar 23, 2015 1:49 pm
Reply with quote

You'll need to define your source field as SFF and convert it. Assuming you are going for odd/even record numbers, you can use a sequence number and various means to find that out, and put zero in one place value in another when "even", and value in one place zero in another when "odd" then SUM on the two fields.
Back to top
View user's profile Send private message
Asha chowdary

New User


Joined: 20 Mar 2015
Posts: 5
Location: Bangalore

PostPosted: Mon Mar 23, 2015 3:58 pm
Reply with quote

Hi,

I have developed the sort card like below

SORT FIELDS=(23,9,CH,D,33,2,CH,D,108,3,CH,D)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(23,9,33,2,
TRAILER3=(1,117,
118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT),SIGNS=(,-)), TOTAL/CONVERT
135:34X))
TRAILER1=('TOTAL AMOUNT: ',
118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT),SIGNS=(,-)), TOTAL/CONVERT
135:34X)),
OUTREC=(1:2,170,171:9X)


While adding total amount to trailer after every record, I am unable to code exactly.Can anyone suggest me how can i add total amount to trailer? [/img][/code]
Back to top
View user's profile Send private message
Asha chowdary

New User


Joined: 20 Mar 2015
Posts: 5
Location: Bangalore

PostPosted: Mon Mar 23, 2015 5:50 pm
Reply with quote

Hi,

I am getting User abend 0016.Can anybody help me to out?

Code:
CTL1CNTL :                                                           
  SORT FIELDS=(23,9,CH,D,33,2,CH,D,108,3,CH,D)                       
  OUTFIL REMOVECC,NODETAIL,                                           
  HEADER1=(1:C'RUN DATE : ',DATE,                                     
           55:C'ANTHEM BLUE CROSS AND BLUE SHIELD',88:C' ',           
           160:C'PAGE:',&PAGE,/,                                     
           1:C'RUN TIME : ',TIME,                                     
           51:C'HIX SATURDAY RUN IMPACT AT MEMBER LEVEL ',/,         
           1:179C'-',/,                                               
           1:C'HCID',22:C'CONTRACT',32:C'DEPEND',39:C'MEMBER',       
           55:C'CLAIM ',80:C'GENDER',87:C'NTWRK',93:'PRODUCT',       
           101:C'ROUTE',107:C'ACCUMS',123:C'ACCUMS',134:C'REMARKS',/,
           1:C'NUMBER',22:C'ID',32:C'NUMBER',39:C'F-NAME',           
           55:C'NUMBER',87:C'TYPE',93:'TYPE',                         
           101:C'CODE',107:C'TYPE',117:C'TOTAL AMOUNT',/,             
           1:179C'-'),                                               
  SECTIONS=(23,9,33,2,108,3,                                         
  TRAILER3=(1,117,                                                   
    118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT),SIGNS=(,-)), TOTAL/CONVERT 
    135:34X))                                                         
 TRAILER1=('TOTAL NUMBER OF UPDATED RECORDS: ',                     
  *                                                                   
                COUNT=(M10,LENGTH=10),                               
                *                                                     
             55:C'TOTAL ACCUMS AMOUNT: ',                             
             *                                                       
             118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT))),                 
             *                                                       
  OUTREC=(1:2,170,171:9X)                                             
        *     

Code:
WER428I  CALLER-PROVIDED IDENTIFIER IS "0001"                         
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT                       
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT                       
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT                       
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT                       
WER268A  OUTREC STATEMENT  : SYNTAX ERROR                             
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                         
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE           


Facing issue at trailer only.
Thanks in advance.

Code'd
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7311
Location: Inside the Matrix

PostPosted: Mon Mar 23, 2015 6:54 pm
Reply with quote

Please use the Code tags to preserve spacing.

You have a comma missing at the end of your TRAILER3.
Back to top
View user's profile Send private message
Asha chowdary

New User


Joined: 20 Mar 2015
Posts: 5
Location: Bangalore

PostPosted: Tue Mar 24, 2015 11:22 am
Reply with quote

Thanks Bill Woodger..

I have corrected my code.but still i am getting OUT1 has incompatible LRECL.
I have given same LRECL for input file and output file.

Code:
//IN1      DD DSN=CHIPST.DVC1094.ACCUMS.RPT.COMBINED.SRT.INPUT,DISP=SHR
//*        DD DSN=CHIPST.DVC1094.ACCUMS.RPT.SAT#1.SRT.D0318,DISP=SHR   
//*                                                                   
//OUT1     DD DSN=CHIPST.DVC1094.ACCUMS.RPT.SRT.OUTPUT,               
//            DISP=(NEW,CATLG,CATLG),                                 
//            UNIT=(DISK,10),SPACE=(CYL,(150,50),RLSE),               
//            DCB=(RECFM=FBA,LRECL=180,BLKSIZE=0)                     
//*                                                                   
//TOOLIN   DD DSN=CHIPST.PKOG.UTILDATA.SRT(SORT1),DISP=SHR             
//CTL1CNTL DD *                                                       
  SORT FIELDS=(23,9,CH,D,33,2,CH,D,108,3,CH,D)                         
  OUTFIL REMOVECC,NODETAIL,                                           
  HEADER1=(1:C'RUN DATE : ',DATE,                                     
           55:C'ANTHEM BLUE CROSS AND BLUE SHIELD',88:C' ',           
           160:C'PAGE:',&PAGE,/,                                       
           1:C'RUN TIME : ',TIME,                                     
           51:C'HIX SATURDAY RUN IMPACT AT MEMBER LEVEL ',/,           
           1:179C'-',/,                                               
           1:C'HCID',22:C'CONTRACT',32:C'DEPEND',39:C'MEMBER',         
           55:C'CLAIM ',80:C'GENDER',87:C'NTWRK',93:'PRODUCT',         
           101:C'ROUTE',107:C'ACCUMS',123:C'ACCUMS',134:C'REMARKS',/, 
           1:C'NUMBER',22:C'ID',32:C'NUMBER',39:C'F-NAME',             
           55:C'NUMBER',87:C'TYPE',93:'TYPE',                         
           101:C'CODE',107:C'TYPE',117:C'TOTAL AMOUNT',/,             
           1:179C'-'),                                                 
  SECTIONS=(23,9,33,2,108,3,                                           
  TRAILER3=(1,117,                                                     
    118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT),SIGNS=(,-)), TOTAL/CONVERT   
    135:34X)),                                                         
  TRAILER1=('TOTAL NUMBER OF UPDATED RECORDS: ',COUNT=(M10,LENGTH=10),
             55:C'TOTAL ACCUMS AMOUNT: ',                             
             118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT))),                 
  OUTREC=(1:2,170,171:9X)                                             
/*                                                                     


Input file Properties:
Code:
Data Set Name . . . . : CHIPST.
                               
General Data                   
 Management class . . : MCTEST
 Storage class  . . . : SCTEST
  Volume serial . . . : SM2019
  Device type . . . . : 3390   
 Data class . . . . . : DCPS   
  Organization  . . . : PS     
  Record format . . . : FBA   
  Record length . . . : 180   
  Block size  . . . . : 27900 
  1st extent cylinders: 10     
  Secondary cylinders : 50     
  Data set name type  :       
  SMS Compressible. . : NO     
                               


Am getting U0016 abend:

Code:
              118:TOT=(118,17,SFF,EDIT=(STTTTTT.TT))),                         
   OUTREC=(1:2,170,171:9X)                                                     
 PARMLIST :                                                                     
 OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=IN1,SORTOUT=OUT1,SORTDD=CTL1,DYN
 LLOC                                                                           
 WER428I  CALLER-PROVIDED IDENTIFIER IS "0001"                                 
 WER276B  SYSDIAG= 2750792, 3625838, 3625838, 2468025                           
 WER164B  16,964K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,           
 WER164B     0 BYTES RESERVE REQUESTED, 2,016K BYTES USED                       
 WER146B  32K BYTES OF EMERGENCY SPACE ALLOCATED                               
 WER108I  IN1      : RECFM=FBA  ; LRECL=   180; BLKSIZE= 27900                 
 WER073I  IN1      : DSNAME=CHIPST.DVC1094.ACCUMS.RPT.COMBINED.SRT.INPUT       
 WER110I  OUT1     : RECFM=FBA  ; LRECL=   180; BLKSIZE= 27900                 
 WER074I  OUT1     : DSNAME=CHIPST.DVC1094.ACCUMS.RPT.SRT.OUTPUT               
 WER247A  OUT1     HAS INCOMPATIBLE LRECL                                       
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
******************************** BOTTOM OF DATA ********************************
                                                                               
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7311
Location: Inside the Matrix

PostPosted: Tue Mar 24, 2015 1:51 pm
Reply with quote

That A at the end of your RECFM indicates that the first byte of a record is an ANSI printer carriage-control byte. Your LRECL says 180, but you can only have 179 bytes of data. You use 180 bytes of data in OUTFIL OUTREC (which you should change to BUILD anyway, see here)
Back to top
View user's profile Send private message
Asha chowdary

New User


Joined: 20 Mar 2015
Posts: 5
Location: Bangalore

PostPosted: Tue Mar 24, 2015 3:26 pm
Reply with quote

Thanks much Bill Woodger. icon_smile.gif
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 -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. how to extract a portion (e.g. fields... SYNCSORT 8
No new posts Break a record into fields, each fiel... SYNCSORT 2
No new posts FIELDS OVERLAPPING WITH MODE = IN OR ... CICS 3
No new posts Sort on different fields, removing du... SYNCSORT 8
No new posts Please help - SORT with SUM fields an... DFSORT/ICETOOL 6
Search our Forums:

Back to Top