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 

Adding values using sort

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


Joined: 18 Nov 2008
Posts: 33
Topics: 14

PostPosted: Thu Jul 29, 2010 10:16 am    Post subject: Adding values using sort Reply with quote

Hi

I have two records in a file of length 80 as follows.

Input:
Code:
 TRAILER1E*90
 TRAILER1C*90


In the above records position 8 and 9 is having numeric value which is s9(2). In positions 11 and 12 the numeric value is ZD. Value in position 10 is just a seprator. I need to add the values in both the records as follows

Output:
Code:
 TRAILER2H*180


Thanks in advance!
One.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jul 29, 2010 11:44 am    Post subject: Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
TRAILER1E*90
TRAILER1C*90
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(1,7,TOT=(8,2,ZD,TO=ZDC,LENGTH=2),10,1,
      TOT=(11,2,ZD,TO=ZD,LENGTH=3))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
oneofspace
Beginner


Joined: 18 Nov 2008
Posts: 33
Topics: 14

PostPosted: Fri Jul 30, 2010 12:33 am    Post subject: Reply with quote

Thanks Frank!
Back to top
View user's profile Send private message
oneofspace
Beginner


Joined: 18 Nov 2008
Posts: 33
Topics: 14

PostPosted: Fri Jul 30, 2010 9:41 am    Post subject: Reply with quote

Hi Frank

I have a clarification. Is it possible to reduce the total value in positions 8 and 9 by 2. means total-2. I searched in forum and manual and could not find it. If we cannot do that, then how this can be achieved?

Thanks!
One.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Jul 30, 2010 9:58 am    Post subject: Reply with quote

This should work (I'm just subtracting 2 from the value in the first record):

Code:

  OPTION COPY                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:SEQNUM,8,ZD)),     
    IFTHEN=(WHEN=(21,8,ZD,EQ,1),                         
      OVERLAY=(11:11,2,ZD,SUB,+2,TO=ZD,LENGTH=2))         
  OUTFIL REMOVECC,NODETAIL,                               
    TRAILER1=(1,7,TOT=(8,2,ZD,TO=ZDC,LENGTH=2),10,1,     
      TOT=(11,2,ZD,TO=ZD,LENGTH=3))                       

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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