Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Summing records conditional statements.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
chillmo

New User


Joined: 31 Aug 2017
Posts: 6
Location: USA

PostPosted: Wed May 15, 2019 2:12 am    Post subject: Summing records conditional statements.
Reply with quote

Hello world.

I'm trying to sum records with amounts in different positions based on the first character of the file. Can this be accomplished in SyncSort?

Input file:
134569999 <- need to sum position starting in 6 for length of 4
134568888 <- need to sum position starting in 6 for length of 4
299993332654 <- need to sum position starting in 9 for length of 4
299995448734 <- need to sum position starting in 9 for length of 4

Output file:
1 - $188.87
2 - $113.88

Also, is there a way to change the output file to reflect a more meaningful description, e.g., instead of 1 it can display "Total Charges" or instead of 2, it can display "Total Waived Charges".

Any assistance would be greatly appreciated.
Back to top
View user's profile Send private message

sergeyken

Active User


Joined: 29 Apr 2008
Posts: 440
Location: Maryland

PostPosted: Wed May 15, 2019 9:56 pm    Post subject: Re: Summing records conditional statements.
Reply with quote

chillmo wrote:
I'm trying to sum records with amounts in different positions based on the first character of the file. Can this be accomplished in SyncSort?

Input file:
134569999 <- need to sum position starting in 6 for length of 4
134568888 <- need to sum position starting in 6 for length of 4
299993332654 <- need to sum position starting in 9 for length of 4
299995448734 <- need to sum position starting in 9 for length of 4

1. If "you are trying something" then where are any results of your attempts???

2. Your "description" of input file (e.g., dataset) doesn't clarify what you really want to do.

3. How come that from 4 input positions you produced 5 output digits, plus decimal point, plus dollar sign?
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 6
Location: USA

PostPosted: Wed May 15, 2019 10:32 pm    Post subject: Reply to: Summing records conditional statements.
Reply with quote

sergeyken,

I'm trying to sum amounts in position 6 for the first two records and sum amounts in position 9 for the next two records (since they have the same character in position 1). And, would like it formatted to include a dollar sign and decimal point.

Thanks for taking the time to assist me.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 440
Location: Maryland

PostPosted: Wed May 15, 2019 11:01 pm    Post subject:
Reply with quote

I have to repeat the same (the last note):

1. If "you are trying something" then where are any results of your attempts???

2. Your "description" of input file (e.g., dataset) doesn't clarify what you really want to do.
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 6
Location: USA

PostPosted: Wed May 15, 2019 11:48 pm    Post subject: Reply to: Summing records conditional statements.
Reply with quote

NOT sure I understand you......I can't get this to work, so i don't hane any results, which is why I'm on the site. Secondly, i'm trying to sum the total amount of "Direct Charges" and "Waived Charges"....does this help you?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8445
Location: Dubuque, Iowa, USA

PostPosted: Thu May 16, 2019 1:05 am    Post subject:
Reply with quote

Quote:
I can't get this to work, so i don't hane any results,
Are you getting a JCL error? Are you not getting a JCL error but not getting any output? Are you getting SYNCSORT (WER) messages in your output? What, precisely, are you doing and what results are you getting?

If you have not yet even attempted to code and test yourself, be aware that this is a HELP forum, NOT a WRITE-THE-CODE-FOR-YOU forum. When you start posting job output and error messages, you'll get vastly better help. Until then, there's nothing more that we can do for you (this is a forum for professionals, who are supposed to know how to write sort utility statements and get output). You may be better off on Beginners and Students Forum although you will still need to code and run something to get meaningful feedback.
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 6
Location: USA

PostPosted: Thu May 16, 2019 2:00 am    Post subject: Reply to: Summing records conditional statements.
Reply with quote

Ok, thanks for the honest feedback. This is my first attempt on this website as I usually find the answers to what I need. Furthermore, below is my code, which works but doesn't give me the results I expect (see above).

Code:

 //SORTCHMO EXEC PGM=SORT                 
 //SYSPRINT DD SYSOUT=*                                       
 //SYSUDUMP DD SYSOUT=0                                       
 //SORTMSG  DD SYSOUT=*                                       
 //SYSOUT   DD SYSOUT=*                                       
 //SORTIN   DD DISP=SHR,DSN=INPUT             
 //SORTOUT  DD DSN=OUTPUT,                 
 //            DISP=(,CATLG,DELETE),                           
 //            SPACE=(CYL,(5,5),RLSE)                         
 //SYSIN DD *                                                 
   INCLUDE COND=(2,4,ZD,EQ,98)                               
   SORT FIELDS=(1,1,CH,A)                                     
   OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),                       
        OVERLAY=(1:C'WAIVED CHARGE TOTAL: ',2X,25:6,4,42X)),
          IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),                       
        OVERLAY=(1:C'SERVICE CHARGE TOTAL: ',2X,25:9,4,42X))
   SUM  FIELDS=(25,4,ZD)   
/*


Below are the results I get (it's NOT summing plus, I'm unsure how to add the mask edits to produce the dollar sign and cents):

WAIVED CHARGE TOTAL: 00000008888
WAIVED CHARGE TOTAL: 00000009999
SERVICE CHARGE TOTAL: 00000002654
SERVICE CHARGE TOTAL: 00000008734
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2151
Location: NY,USA

PostPosted: Thu May 16, 2019 4:30 am    Post subject:
Reply with quote

Use INREC instead of OUTREC and make a use of EDIT at sum.INCLUDE is wrong and why it’s there at first place ?

Think about SECTIONS.
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 6
Location: USA

PostPosted: Thu May 16, 2019 8:32 am    Post subject: Reply to: Summing records conditional statements.
Reply with quote

Rohit,

Thanks for the info...I'm a step closer when I changed OUTREC to INREC; however, I changed the SUM Fields to
SUM FIELDS=(25,11,ZD,M4)
and received a WER268A error....basically stating edit masks cannot be used in a SUM statement.

Also, I need the include clause as the records I need summed have 98 starting in position 2 (but it should be length of 2 NOT 4...sorry). I'm NOT as familiar with Sections but will read the manual and research this on the internet.

Thanks!
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2151
Location: NY,USA

PostPosted: Thu May 16, 2019 8:37 am    Post subject:
Reply with quote

Look at the input records you shared to us. Where is it showing 98 in it starting at 2 ?
If you want to use include on summed value then you need to use OUTFIL and INCLUDE. This current include will be applied prior to SUM.

You can use Edit in outrec build instead of using it in SUM FIELDS.
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 6
Location: USA

PostPosted: Thu May 16, 2019 9:12 am    Post subject: Reply to: Summing records conditional statements.
Reply with quote

Rohit,

Now I get a S0C7 when I added the following code (to add dollars and cents to my totals):

Code:

SORT FIELDS=(1,1,CH,A)                                           
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),                             
OVERLAY=(1:C'SERVICE CHARGE TOTAL: ',2X,25:34,11,ZD,             
                                 EDIT=($III,III,III.II),42X)),   
       IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),                             
OVERLAY=(1:C'GENERAL LEDGER TOTAL: ',2X,25:30,11,ZD,             
                                 EDIT=($III,III,III.II),42X))     
SUM  FIELDS=(25,11,ZD)                                           
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2151
Location: NY,USA

PostPosted: Thu May 16, 2019 9:15 am    Post subject:
Reply with quote

Instead of ZD use UFF OR SFF and you need to do that EDIT in OUTREC after SUM FIELDS and not in INREC.
INREC is only to rearrange SUM positions at same place nothing else. Do all the EDITS in OUTREC BUILD.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2151
Location: NY,USA

PostPosted: Thu May 16, 2019 8:57 pm    Post subject:
Reply with quote

Try this.
Code:
//SORTIN    DD *                                           
134569999                                                   
134568888                                                   
299993332654                                               
299995448734                                               
//SORTOUT   DD SYSOUT=*                                     
//SYSIN     DD *                                           
   OPTION COPY                                             
   INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),                     
       OVERLAY=(80:C'WAIVED CHARGE TOTAL : ',150:06,04)),   
         IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),                     
       OVERLAY=(80:C'SERVICE CHARGE TOTAL: ',150:09,04))   
    OUTFIL REMOVECC,NODETAIL,                               
    SECTIONS=(1,1,                                         
    TRAILER3=(80,21,TOT=(150,04,ZD,EDIT=($IIIIIT.TT))))       


Output:
Code:
WAIVED CHARGE TOTAL :   $188.87
SERVICE CHARGE TOTAL:   $113.88
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 440
Location: Maryland

PostPosted: Thu May 16, 2019 9:02 pm    Post subject:
Reply with quote

chillmo wrote:
Hello world.

I'm trying to sum records with amounts in different positions based on the first character of the file. Can this be accomplished in SyncSort?

OMG!!!

If you really need to summarize values within groups (are the records already grouped as needed? are there always only two groups in your data? Are there always only two records in each group?) - then you need to use the statement
OUTFIL …,SECTIONS=(…)

With the statement SUM you can only get a single sum of values through all your table/file/dataset, not separated by groups.

P.S.
Did you ever read ANY SORT manual in your life?

This topic looks like
Quote:
I'm trying to organize a mission to Mars with different equipment sent to the planet. Can this be accomplished in my company?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts count the number of records from diff... janmejay CA Products 4 Mon Mar 25, 2019 11:29 pm
No new posts Need help in adding Header to records senthamizh SYNCSORT 1 Thu Mar 07, 2019 7:55 pm
No new posts Count the records and Create Header a... thesumitk DFSORT/ICETOOL 2 Mon Mar 04, 2019 11:18 pm
No new posts Query on summing up the fields abdulrafi DFSORT/ICETOOL 10 Mon Jan 21, 2019 7:18 pm
No new posts Copy Group of Records scorp_rahul23 DFSORT/ICETOOL 1 Sun Jan 13, 2019 9:17 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us