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 

add 1 to column using SORT

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


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Jan 31, 2012 1:02 pm    Post subject: add 1 to column using SORT Reply with quote

Hi, I'd like to add 1 to a numeric field in a file.
From the example below, obviously column 5 I'd like to convert
to 1, 2, 3, 4.

How can I do this with SORT ?

Code:
//SORTIN   DD *             
XXX 0 TOM                   
AAA 1 BOB                   
BBB 2 JOE                   
CCC 3 FRANK                 
/*                         
//SORTOUT  DD SYSOUT=*     
//SYSIN    DD *             
  SORT FIELDS=COPY         
  INREC ...
/*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 31, 2012 1:17 pm    Post subject: Reply with quote

tcurrier,

Assuming the field is just 1 byte use the following DFSORT JCL
Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                               
----+----1----+----2----+----3----+----4----+--
XXX 0 TOM                                     
AAA 1 BOB                                     
BBB 2 JOE                                     
CCC 3 FRANK                                   
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                               
  SORT FIELDS=COPY                             
  INREC OVERLAY=(5:+1,ADD,5,1,ZD,EDIT=(T))     
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Jan 31, 2012 7:22 pm    Post subject: Reply with quote

Thanks, Kolusu...

Pardon my ignorance, as I should be able to figure this out, but
what if the field to be added to is 5 bytes instead of 1 ?

Code:
//SORTIN   DD *   
XXX 00889 TOM     
AAA 01099 BOB     
BBB 02228 JOE     
CCC 09999 FRANK   
/*               
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 31, 2012 7:29 pm    Post subject: Reply with quote

tcurrier,

Simply change the length to 5 in the INREC statement. Assuming your data starts at pos 5 for a length of 5 use the following INREC

Code:

INREC OVERLAY=(5:+1,ADD,5,5,ZD,EDIT=(TTTTT))


Generic example
Code:


INREC OVERLAY=(P1:Constant,Function,P2,M,F,O1)

P1       = Position of the field where the result needs to be
Constant = Constant value to be added or subtracted ex: +1 or -12
Function = Function to be used (ADD, SUB, DIV, MUL ...)
P2       = Position of the input field to used with the function
M        = Length of the input field i.e. P2   
F        = Format of the input field ( ZD, PD, BI, FI, UFF, SFF ...)
O1       = Format of the output field


Back to top
View user's profile Send private message Send e-mail Visit poster's website
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Jan 31, 2012 8:31 pm    Post subject: Reply with quote

Thank you very much, Kolusu ...
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