Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Truncate/Rounding using Syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Truncate/Rounding using Syncsort
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    Post subject:
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: 7996
Location: Bellevue, IA

PostPosted: Mon May 24, 2010 4:57 pm    Post subject:
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    Post subject:
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: 500
Location: USA

PostPosted: Thu May 27, 2010 9:55 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 7 Sat Jan 21, 2017 4:02 am
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts Syncsort - NULL in Integer field chec... nartcr SYNCSORT 4 Thu Oct 06, 2016 6:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us