View previous topic :: View next topic
|
Author |
Message |
Divya Prakash
New User
Joined: 11 Aug 2021 Posts: 1 Location: India
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
You have tried what? Use code tags when showing .. |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3099 Location: NYC,USA
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
Not really.
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3099 Location: NYC,USA
|
|
|
|
Joerg.Findeisen wrote: |
Not really.
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 |
|
 |
|
|