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

Arithmetic division using Syncsort


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Divya Prakash

New User


Joined: 11 Aug 2021
Posts: 1
Location: India

PostPosted: Wed Aug 11, 2021 11:35 am
Reply with quote

Hi,

I am facing difficulties regarding one of sort requirement. Below is the requirement -

I have a PS file with records ( could have 1 or many records) where i am dividing the records count with 4 and then splitting the PS file records in 4 different files.

my requirement is to write the records in 4 files only if division result greater than or equal to 1. If not I want to write the records in 1 file and remaining 3 files should be empty. Need help on this. Thanks!
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Wed Aug 11, 2021 12:34 pm
Reply with quote

You have tried what? Use code tags when showing ..
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Fri Aug 13, 2021 3:32 am
Reply with quote

Code:
//WHATEVER EXEC PGM=SORT                                       
//F1       DD *                                               
01                                                             
02                                                             
03                                                             
04                                                             
05                                                             
06                                                             
07                                                             
/*                                                             
//F2       DD * <* this is identical to DD:F1 input
:
/*                                                             
//SYSOUT   DD SYSOUT=*                                         
//SORTOUT  DD DUMMY                                           
//#1       DD SYSOUT=*                                         
//#2       DD SYSOUT=*                                         
//#3       DD SYSOUT=*                                         
//#4       DD SYSOUT=*                                         
//SYSIN    DD *                                               
  OPTION COPY                                                 
  JOINKEYS F1=F1,FIELDS=(81,1,A)                               
  JOINKEYS F2=F2,FIELDS=(81,1,A)                               
  REFORMAT FIELDS=(F1:1,80,F2:82,4,F1:86,4)                   
  OUTFIL FNAMES=(#1),SAVE                                     
  OUTFIL FNAMES=(#2),INCLUDE=(81,4,ZD,GT,+3,AND,85,4,ZD,EQ,+1)
  OUTFIL FNAMES=(#3),INCLUDE=(81,4,ZD,GT,+3,AND,85,4,ZD,EQ,+2)
  OUTFIL FNAMES=(#4),INCLUDE=(81,4,ZD,GT,+3,AND,85,4,ZD,EQ,+3)
  END                                                         
/*                                                             
//JNF1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,                                 
    OVERLAY=(81:C'X',SEQNUM,4,ZD,START=0,                   
             82,4,ZD,MOD,+4,TO=ZD,LENGTH=4))               
  END                                                       
/*                                                         
//JNF2CNTL DD *                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'X',+1,ZD,LENGTH=4))
  SUM FIELDS=(82,4,ZD)                                     
  END                                                       
/*


Ouput w/ seven lines of Input:
Code:
NP   DDNAME   StepName ProcStep DSID Owner    C Dest               Rec-Cnt
     #1       WHATEVER           107 <me>     V LOCAL                    2
     #2       WHATEVER           108 <me>     V LOCAL                    2
     #3       WHATEVER           109 <me>     V LOCAL                    2
     #4       WHATEVER           110 <me>     V LOCAL                    1

*******************
01                   
05                   
02                   
06                   
03                   
07                   
04                   
*******************


Ouput w/ three lines of Input:
Code:
NP   DDNAME   StepName ProcStep DSID Owner    C Dest               Rec-Cnt
     #1       WHATEVER           107 <me>     V LOCAL                    3

*******************
01                 
02                 
03                 
*******************
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Aug 13, 2021 5:24 am
Reply with quote

Welcome!
Not sure if SPLITBY is supported by SYNCSORT but you can give a try.
I found working solution to the same problem as yours.
ibmmainframes.com/about10081.html
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Fri Aug 13, 2021 9:45 am
Reply with quote

Rohit Umarjikar wrote:
I found working solution to the same problem as yours.
ibmmainframes.com/about10081.html

Not really. icon_neutral.gif
Divya Prakash wrote:
my requirement is to write the records in 4 files only if division result greater than or equal to 1. If not I want to write the records in 1 file and remaining 3 files should be empty.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Fri Aug 13, 2021 3:11 pm
Reply with quote

If it is not of interest and the records can be split in groups, use SPLITBY.
Code:
//WHATEVER EXEC PGM=SORT                 
//SORTIN   DD *                           
01                                       
02                                       
03                                       
04                                       
05                                       
06                                       
07                                       
/*                                       
//SYSOUT   DD SYSOUT=*                   
//SORTOUT  DD DUMMY                       
//#1       DD SYSOUT=*                   
//#2       DD SYSOUT=*                   
//#3       DD SYSOUT=*                   
//#4       DD SYSOUT=*                   
//SYSIN    DD *                           
  OPTION COPY                             
  OUTFIL FNAMES(#1,#2,#3,#4),SPLITBY=3   
  END                                     
/*
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Aug 13, 2021 4:52 pm
Reply with quote

Joerg.Findeisen wrote:
Rohit Umarjikar wrote:
I found working solution to the same problem as yours.
ibmmainframes.com/about10081.html

Not really. icon_neutral.gif
Divya Prakash wrote:
my requirement is to write the records in 4 files only if division result greater than or equal to 1. If not I want to write the records in 1 file and remaining 3 files should be empty.

But if there is only 1 record then anyways other 3 will be empty since SPLITBY will not find any to write after 1( which was I would think) If there are 5 then first data set will have 2 now, it’s round robin. Use SPLITBY=1
Code:
//PS001   EXEC PGM=SORT               
//SORTIN   DD *                       
01                                   
02                                   
03                                   
04                                                                     
/*                                   
//SYSOUT   DD SYSOUT=*               
//SORTOUT  DD DUMMY                   
//#1       DD SYSOUT=*               
//#2       DD SYSOUT=*               
//#3       DD SYSOUT=*               
//#4       DD SYSOUT=*               
//SYSIN    DD *                       
  OPTION COPY                         
  OUTFIL FNAMES(#1,#2,#3,#4),SPLITBY=1
  END                                 
/*                                   

Output :
#1
Code:
********************************* TOP OF DATA **********************************
01                                                                                                                                                           
******************************** BOTTOM OF DATA ********************************
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 -> SYNCSORT

 


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
This topic is locked: you cannot edit posts or make replies. SUM based on two conditions using SYN... SYNCSORT 7
Search our Forums:

Back to Top