Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Ramanan-R

New User

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

Posted: Mon May 24, 2010 2:29 pm    Post subject: Truncate/Rounding using Syncsort

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)

Regards,
Ramanan R

Ramanan-R

New User

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

Posted: Mon May 24, 2010 2:45 pm    Post subject:

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
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

Posted: Mon May 24, 2010 4:57 pm    Post subject:

 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?
Ramanan-R

New User

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

 Posted: Mon May 24, 2010 5:20 pm    Post subject: Hi Robert, Sorry RECFM=FB & LRECL=133...
Alissa Margulies

SYNCSORT Support

Joined: 25 Jul 2007
Posts: 500
Location: USA

Posted: Thu May 27, 2010 9:55 pm    Post subject:

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
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 7 Sat Jan 21, 2017 4:02 am Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us