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

Truncate/Rounding using Syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Mon May 24, 2010 2:29 pm
Reply with quote

Hi All,

I have a file of LRECL=80 & RECFM=80, it has 10 fields of length 11 bytes starting from position 1.

The requirement is to,

1. Divide each field by 30 and check the remainder as below
2. If less that 5 truncate decimal value
3. Else add 1 to integer value

I wrote the code as below (This is written only for first 2 fields)

Code:
INREC OVERLAY=1:((1,11,ZD,MUL,+10),DIV,+30),EDIT=(TTTTTTTTTTT))
*
SORT FIELDS=COPY
*
OUTREC IFTHEN=(WHEN=(11,1,ZD,LT,+5),             
                           OVERLAY=(1:C'0',1,10),HIT=NEXT),
       IFTHEN=(WHEN=(11,1,ZD,GE,+5),             
                           OVERLAY=(1:C'0',1,10,ZD,ADD,+1,
                           EDIT=(TTTTTTTTTT),HIT=NEXT),
       IFTHEN=(WHEN=(22,1,ZD,LT,+5),             
                           OVERLAY=(12:C'0',22,10),HIT=NEXT),
       IFTHEN=(WHEN=(22,1,ZD,GE,+5),             
                           OVERLAY=(12:C'0',12,10,ZD,ADD,+1,
                           EDIT=(TTTTTTTTTT)))


For few outputs of INREC function, both <+5 & >=+5 calculations are performed, E.g: 5.3 (First got truncated to 5 and then into 1 by >=+5 IFTHEN)

Please advice a solution...

Thanks in advance!

Regards,
Ramanan R
Back to top
View user's profile Send private message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Mon May 24, 2010 2:45 pm
Reply with quote

Sorry, here is the corrected code... above code will throw error...

Code:
  INREC OVERLAY=(01:((01,11,ZD,MUL,+10),DIV,+30),EDIT=(TTTTTTTTTTT),
                 12:((12,11,ZD,MUL,+10),DIV,+30),EDIT=(TTTTTTTTTTT))
*                                                                   
  SORT FIELDS=COPY                                                 
*                                                                   
  OUTREC IFTHEN=(WHEN=(11,1,ZD,LT,+5),                             
                       OVERLAY=(1:C'0',1,10),HIT=NEXT),             
         IFTHEN=(WHEN=(11,1,ZD,GE,+5),                             
                       OVERLAY=(1:C'0',1,10,ZD,ADD,+1,             
                       EDIT=(TTTTTTTTTT)),HIT=NEXT),               
         IFTHEN=(WHEN=(22,1,ZD,LT,+5),                             
                       OVERLAY=(12:C'0',12,10),HIT=NEXT),           
         IFTHEN=(WHEN=(22,1,ZD,GE,+5),                             
                       OVERLAY=(12:C'0',12,10,ZD,ADD,+1,           
                       EDIT=(TTTTTTTTTT)))


Input File:
Code:
 =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ****** ***************************** Top of Data ******************************
 000000 0000000016000000000120                                                 
 ****** **************************** Bottom of Data ****************************


Output:
Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000000 0000000000100000000004                                                 
****** **************************** Bottom of Data ****************************


Thanks!
Ramanan R
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon May 24, 2010 4:57 pm
Reply with quote

Quote:
I have a file of LRECL=80 & RECFM=80, it has 10 fields of length 11 bytes starting from position 1.
Record format may be fixed, variable, or undefined and blocked or not and have carriage control or not -- but it will not ever, under any circumstances, be a numeric value.

10 fields of 11 bytes apiece is 110 bytes -- how did you squeeze 110 bytes into an 80-byte record?
Back to top
View user's profile Send private message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Mon May 24, 2010 5:20 pm
Reply with quote

Hi Robert,

Sorry RECFM=FB & LRECL=133...
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Thu May 27, 2010 9:55 pm
Reply with quote

Hello Ramanan R.

If you are just trying to round the numbers after dividing by 30, then try this:
Code:

//STEP1 EXEC PGM=SORT                                             
//SORTIN  DD *                                                     
0000000016000000000120                                             
//SORTOUT DD SYSOUT=*                                             
//SYSOUT  DD SYSOUT=*                                             
//SYSIN   DD *                                                       
  INREC OVERLAY=(1:((((01,11,ZD,MUL,+10),DIV,+30),ADD,+5),DIV,+10),
        EDIT=(TTTTTTTTTTT),                                         
        12:((((12,11,ZD,MUL,+10),DIV,+30),ADD,+5),DIV,+10),         
        EDIT=(TTTTTTTTTTT))                                         
  SORT FIELDS=COPY
/*         
 


Here is the output produced:
Code:
0000000000500000000004
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts DFSORT/SYNCSORT/ICETOOL JCL & VSAM 8
No new posts Syncsort "Y2C" Function SYNCSORT 1
No new posts Arithmetic division using Syncsort SYNCSORT 6
Search our Forums:

Back to Top