MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sum the amount based on credit/debit indicator

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Thu Nov 20, 2014 5:11 pm    Post subject: Sum the amount based on credit/debit indicator Reply with quote

Hi All,

My input file is VB, LRECL=227

In the following sort step I am able to do the following things.

I want to add the amount in the column 76 if the account number is 235120 or 235010 and the credit/debit indicator is "C" (C- credit, D- Debit) at column 75.

I want to subtract the amount in the column 76 if the account number is 235120 or 235010 and the credit/debit indicator is "D" (C- credit, D- Debit) at column 75.

I want to add one more condition to the include/IFTHEN statement as follows (This is exactly opposite to the above conditions)

I want to add the amount in the column 76 if the account number is 235020 and the credit/debit indicator is "D" (C- credit, D- Debit) at column 75.

I want to subtract the amount in the column 76 if the account number is 235020 and the credit/debit indicator is "C" (C- credit, D- Debit) at column 75.
Code:

//STEP001  EXEC PGM=SORT
//SORTIN   DD *
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8---
00026260                                                            235120C
FFFFFFFF444444444444444444444444444444444444444444444444444444444444FFFFFFC00000200
0002626000000000000000000000000000000000000000000000000000000000000023512030000070C
----------------------------------------------------------------------------------
00026260                                                            235120D
FFFFFFFF444444444444444444444444444444444444444444444444444444444444FFFFFFC00000200
0002626000000000000000000000000000000000000000000000000000000000000023512040000080C
----------------------------------------------------------------------------------
00026260                                                            235010C      Íð
FFFFFFFF444444444444444444444444444444444444444444444444444444444444FFFFFFC00000078
0002626000000000000000000000000000000000000000000000000000000000000023501030000035C
----------------------------------------------------------------------------------
00026260                                                            235010D       æ
FFFFFFFF444444444444444444444444444444444444444444444444444444444444FFFFFFC00000029
0002626000000000000000000000000000000000000000000000000000000000000023501040000077C
----------------------------------------------------------------------------------
00026260                                                            235020D       æ
FFFFFFFF444444444444444444444444444444444444444444444444444444444444FFFFFFC00000029
0002626000000000000000000000000000000000000000000000000000000000000023502040000067C

//SORTOUT  DD DSN=TS.MY.OUT.PUT,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(CYL,(1,1)),
//            DCB=(RECFM=VB,LRECL=227,BLKSIZE=0)
//SYSUDUMP DD SYSOUT=W
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
  INCLUDE COND=(73,6,CH,EQ,C'235120',OR,73,6,CH,EQ,C'235010')
  SORT FIELDS=(4,15,CH,A)
  INREC IFTHEN=(WHEN=(79,1,CH,EQ,C'D'),
              OVERLAY=(80:+0,SUB,80,8,PD,PD,LENGTH=8))
  SUM  FIELDS=(80,8,PD)
/*
//*

_________________
Regards,
Chandra
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2014 6:54 pm    Post subject: Reply with quote

Chandra,

If I understand your question correctly then you can use the following control cards

or
Code:

//SYSIN    DD *
  INCLUDE COND=(73,6,SS,EQ,C'235010,235020,235120') 

  INREC IFTHEN=(WHEN=(73,7,SS,EQ,C'235010D,235020C,235120D'),
         OVERLAY=(80:+0,SUB,80,8,PD,PD,LENGTH=8))           

  SORT FIELDS=(4,15,CH,A)

  SUM  FIELDS=(80,8,PD)

//*   

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Fri Nov 21, 2014 6:50 am    Post subject: Reply with quote

chandra,

You are specifying DCB info on your SORTOUT. Not necessary, SORT will handle it, and may at some point in the future if the LRECL changes, you have two places to change it. If the RECFM changes, you have two places.

Are you SORTing just to allow the use of SUM? If the file is already in sequence, that is a waste and it can be done another way.
Back to top
View user's profile Send private message
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Fri Nov 21, 2014 11:02 am    Post subject: Reply with quote

Thank You Kolusu.

William - I will remove the DCB statement from my SORTOUT statement. The records are not in sorting order in my example I am showing in sorting order for simplicity.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group