Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Split 1 file into 10 output Files - Syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
Prasanth Kumar

New User


Joined: 22 Apr 2011
Posts: 3
Location: India

PostPosted: Sat Sep 16, 2017 12:02 am    Post subject: Split 1 file into 10 output Files - Syncsort
Reply with quote

Hi All,
I am using Syncsort Z/OS 2.1.3 and my requirement is to split 1 input file into 10 output files based on certain conditions:

Input file is a Flat File (FB) of 32127 length can have thousands of records and this count can vary each day. This file has trades and markers and trades and markers.

Total number of o/p files to be written are 10.

On the position 221 and for length 1 if the character is X or Y or Z or P or R or D then write this record to Output File 1 as this is a Trade.

Trades:
INCLUDE=(221,1,CH,EQ,C'X',OR,
221,1,CH,EQ,C'Y',OR,
221,1,CH,EQ,C'Z',OR,
221,1,CH,EQ,C'P',OR,
221,1,CH,EQ,C'R',OR,
221,1,CH,EQ,C'D')

Markers:
INCLUDE=(221,1,CH,EQ,C'7',OR,
221,1,CH,EQ,C'8',OR,
221,1,CH,EQ,C'M',OR,
221,1,CH,EQ,C'C',OR,
221,1,CH,EQ,C'O')

My requirement is i will keep reading the file, writing all the trades to o/p file 1, the moment I hit marker i have to write this another new o/p file 2. Again keep reading and write the trades after the marker to o/p file 3 and so on.

So finally, i should have
File 1 - trades
file 2 - marker
file 3 - trades
file 4 - marker
file 5 - trades
file 6 - marker
.....
file 10 - trades

I need to distribute into 10 files with no duplicates. trades before marker goes to a file, marker goes to another file, again the next set of trades goes to another file and then the next marker goes to another file and so on.

Please help, thank you.

Thanks,
Prasad.
Back to top
View user's profile Send private message

sergeyken

Active User


Joined: 29 Apr 2008
Posts: 175
Location: Maryland

PostPosted: Sat Sep 16, 2017 1:15 am    Post subject:
Reply with quote

I always suggest first of all:
1) RTFM,
2) run simplified test to understand the idea(s) of required operations,
3) update the successful test to the original task



It takes no more than 1 hour as first-time-job, and no more than 10 minutes for others:
Code:
//MARKERS  EXEC PGM=SYNCSORT
//SYSOUT   DD  SYSOUT=*     
//*                         
//SORTIN   DD  *             
X-----TRADES1------         
Y-----TRADES1------         
Z-----TRADES1------         
P-----TRADES1------         
R-----TRADES1------         
D-----TRADES1------         
7-----MARKERS2-----         
8-----MARKERS2-----         
M-----MARKERS2-----         
C-----MARKERS2-----         
O-----MARKERS2-----         
X-----TRADES3------         
Y-----TRADES3------         
Z-----TRADES3------         
P-----TRADES3------         
R-----TRADES3------         
D-----TRADES3------     
7-----MARKERS4-----     
8-----MARKERS4-----     
M-----MARKERS4-----     
C-----MARKERS4-----     
O-----MARKERS4-----     
X-----TRADES5------     
Y-----TRADES5------     
Z-----TRADES5------     
P-----TRADES5------     
R-----TRADES5------     
D-----TRADES5------     
7-----MARKERS6-----     
8-----MARKERS6-----     
M-----MARKERS6-----     
C-----MARKERS6-----     
O-----MARKERS6-----     
X-----TRADES7------     
Y-----TRADES7------     
Z-----TRADES7------     
P-----TRADES7------ 
R-----TRADES7------ 
D-----TRADES7------ 
7-----MARKERS8----- 
8-----MARKERS8----- 
M-----MARKERS8----- 
C-----MARKERS8----- 
O-----MARKERS8----- 
X-----TRADES9------ 
Y-----TRADES9------ 
Z-----TRADES9------ 
P-----TRADES9------ 
R-----TRADES9------ 
D-----TRADES9------ 
7-----MARKERS10---- 
8-----MARKERS10---- 
M-----MARKERS10---- 
C-----MARKERS10---- 
O-----MARKERS10---- 
//*                 
//SORTOUT  DD  SYSOUT=*     DEBUGGING ONLY     
//*                                           
//TRADES1  DD  SYSOUT=*                       
//MARKER2  DD  SYSOUT=*                       
//TRADES3  DD  SYSOUT=*                       
//MARKER4  DD  SYSOUT=*                       
//TRADES5  DD  SYSOUT=*                       
//MARKER6  DD  SYSOUT=*                       
//TRADES7  DD  SYSOUT=*                       
//MARKER8  DD  SYSOUT=*                       
//TRADES9  DD  SYSOUT=*                       
//MARKER10 DD  SYSOUT=*                       
//*                                           
//SYSIN    DD  *                               
 INREC IFTHEN=(WHEN=(1,1,SS,EQ,C'XYZPRD'),     
               BUILD=(1,80,C'T')),             
       IFTHEN=(WHEN=(1,1,SS,EQ,C'78MCO'),     
               BUILD=(1,80,C'M'))             
*                                             
 SORT FIELDS=COPY                             
 OUTREC IFTHEN=(WHEN=GROUP,                                       
                KEYBEGIN=(81,1),                                   
                PUSH=(82:ID=2))                                   
*                                                                 
 OUTFIL FNAMES=TRADES1,INCLUDE=(81,3,CH,EQ,C'T01'),BUILD=(1,80)   
 OUTFIL FNAMES=MARKER2,INCLUDE=(81,3,CH,EQ,C'M02'),BUILD=(1,80)   
 OUTFIL FNAMES=TRADES3,INCLUDE=(81,3,CH,EQ,C'T03'),BUILD=(1,80)   
 OUTFIL FNAMES=MARKER4,INCLUDE=(81,3,CH,EQ,C'M04'),BUILD=(1,80)   
 OUTFIL FNAMES=TRADES5,INCLUDE=(81,3,CH,EQ,C'T05'),BUILD=(1,80)   
 OUTFIL FNAMES=MARKER6,INCLUDE=(81,3,CH,EQ,C'M06'),BUILD=(1,80)   
 OUTFIL FNAMES=TRADES7,INCLUDE=(81,3,CH,EQ,C'T07'),BUILD=(1,80)   
 OUTFIL FNAMES=MARKER8,INCLUDE=(81,3,CH,EQ,C'M08'),BUILD=(1,80)   
 OUTFIL FNAMES=TRADES9,INCLUDE=(81,3,CH,EQ,C'T09'),BUILD=(1,80)   
 OUTFIL FNAMES=MARKER10,INCLUDE=(81,3,CH,EQ,C'M10'),BUILD=(1,80)   
*                                                                 
 END                                                               
//*


I hope, the rest of your job should be clear, isn't it?
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 202
Location: Chennai

PostPosted: Sun Sep 17, 2017 10:03 am    Post subject:
Reply with quote

sergeyken,

OP specified the LRECL=32127 and also condition is @ offset 221,1

Prasanth Kumar wrote:

Input file is a Flat File (FB) of 32127 length can have thousands of records and this count can vary each day. This file has trades and markers and trades and markers.

Total number of o/p files to be written are 10.

On the position 221 and for length 1 if the character is X or Y or Z or P or R or D then write this record to Output File 1 as this is a Trade.


sergeyken wrote:

Code:

 INREC IFTHEN=(WHEN=(1,1,SS,EQ,C'XYZPRD'),     
               BUILD=(1,80,C'T')),             
       IFTHEN=(WHEN=(1,1,SS,EQ,C'78MCO'),     
               BUILD=(1,80,C'M'))



BUILD is unnecessary here and waste of resources, we can use OVERLAY instead

UNTESTED code

Code:

//*                 
//SORTOUT  DD  SYSOUT=*     DEBUGGING ONLY     
//*                                           
//TRADES1  DD  SYSOUT=*                       
//MARKER2  DD  SYSOUT=*                       
//TRADES3  DD  SYSOUT=*                       
//MARKER4  DD  SYSOUT=*                       
//TRADES5  DD  SYSOUT=*                       
//MARKER6  DD  SYSOUT=*                       
//TRADES7  DD  SYSOUT=*                       
//MARKER8  DD  SYSOUT=*                       
//TRADES9  DD  SYSOUT=*                       
//MARKER10 DD  SYSOUT=*
//REST     DD  SYSOUT=*                       
//*                                           
//SYSIN    DD  *
  OPTION COPY
  INREC IFTHEN=(WHEN=(221,1,SS,EQ,C'X,Y,Z,P,R,D'),     
                OVERLAY=(32128:C'T')),             
        IFTHEN=(WHEN=(221,1,SS,EQ,C'7,8,M,C,O'),     
                OVERLAY=(32128:C'M')) 
 
  OUTREC IFTHEN=(WHEN=GROUP,                                       
                KEYBEGIN=(32128,1),                                   
                PUSH=(32129:ID=2))

  OUTFIL FNAMES=TRADES1,INCLUDE=(32128,3,CH,EQ,C'T01'),BUILD=(1,32127)   
  OUTFIL FNAMES=MARKER2,INCLUDE=(32128,3,CH,EQ,C'M02'),BUILD=(1,32127)   
  OUTFIL FNAMES=TRADES3,INCLUDE=(32128,3,CH,EQ,C'T03'),BUILD=(1,32127)   
  OUTFIL FNAMES=MARKER4,INCLUDE=(32128,3,CH,EQ,C'M04'),BUILD=(1,32127)   
  OUTFIL FNAMES=TRADES5,INCLUDE=(32128,3,CH,EQ,C'T05'),BUILD=(1,32127)   
  OUTFIL FNAMES=MARKER6,INCLUDE=(32128,3,CH,EQ,C'M06'),BUILD=(1,32127)   
  OUTFIL FNAMES=TRADES7,INCLUDE=(32128,3,CH,EQ,C'T07'),BUILD=(1,32127)   
  OUTFIL FNAMES=MARKER8,INCLUDE=(32128,3,CH,EQ,C'M08'),BUILD=(1,32127)   
  OUTFIL FNAMES=TRADES9,INCLUDE=(32128,3,CH,EQ,C'T09'),BUILD=(1,32127)   
  OUTFIL FNAMES=MARKER10,INCLUDE=(32128,3,CH,EQ,C'M10'),BUILD=(1,32127)
  OUTFIL FNAMES=REST,SAVE 


Corrected as requested
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 175
Location: Maryland

PostPosted: Mon Sep 18, 2017 6:25 pm    Post subject:
Reply with quote

magesh23586 wrote:
BUILD is unnecessary here and waste of resources, we can use OVERLAY instead

Waste of resources with BUILD???!!!
OMG, what you are talking about...
magesh23586 wrote:

UNTESTED code

Code:

  INREC IFTHEN=(WHEN=(221,1,SS,EQ,C'X,Y,Z,P,R,D'),     

Using WHEN=(221,1,SS,EQ,C'X,Y,Z,P,R,D') - is a bad idea in general case. The character "comma" (C',') when appeared by a chance will also mark the new group.
What would be a benefit of replacing the correct value C'XYZPRD' with half-correct one C'X,Y,Z,P,R,D'?

In general, I would call all the suggested last updates as "nit-picking"
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 202
Location: Chennai

PostPosted: Mon Sep 18, 2017 9:50 pm    Post subject: Reply to: Split 1 file into 10 output Files - Syncsort
Reply with quote

sergeyken wrote:

Waste of resources with BUILD???!!!
OMG, what you are talking about...


Build - you are rebuilding the entire record again.

Overlay - just overlay the record @ last position.

Building an entire record again is a waste of resources.

The OVERLAY parameter enables you to change particular columns and add fields to the end of a record without rebuilding the entire record. When using the OVERLAY parameter you only need to specify the columns you want to change. The rest of the input record remains unchanged.


sergeyken wrote:

Using WHEN=(221,1,SS,EQ,C'X,Y,Z,P,R,D') - is a bad idea in general case. The character "comma" (C',') when appeared by a chance will also mark the new group.
What would be a benefit of replacing the correct value C'XYZPRD' with half-correct one C'X,Y,Z,P,R,D'?


If ",' is there in the input, it should be avoided, it is just for clarity.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 175
Location: Maryland

PostPosted: Tue Sep 19, 2017 1:10 am    Post subject: Re: Reply to: Split 1 file into 10 output Files - Syncsort
Reply with quote

magesh23586 wrote:
Building an entire record again is a waste of resources.

If ",' is there in the input, it should be avoided, it is just for clarity.


The record (physically) is re-built exactly in the same manner, either with BUILD, or with OVERLAY. I implemented similar operations in Assembler myself; the difference in syntax doesn't matter.
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 8 Fri Sep 22, 2017 11:35 pm
No new posts Comparing 2 Files using Current time arunsoods DFSORT/ICETOOL 5 Fri Sep 22, 2017 6:00 pm
No new posts it is possible output a SET value fro... Martylin JCL & VSAM 5 Fri Sep 22, 2017 7:08 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Hardcoded negative sign value in output scdinesh SYNCSORT 8 Fri Sep 08, 2017 5:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us