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
 

 

JCL sort to Skip n records based on the condition.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Thu Aug 25, 2011 3:27 pm    Post subject: JCL sort to Skip n records based on the condition.
Reply with quote

Hello,

I have a file which i want to copy to new file based on a condition.

i'm try to illustrate with an example lets say that i have a file of length 20 bytes, i should start copying the file to output file sequentially, when the input value in the first 5 byts is 12345 then i should skip 3 records form that line. copy form the 4th record from there.

Input file:
abcde abcdefghijklm1
abcde abcdefghijklm2
12345 dfdfsdfdfd
sdfdsds
dsfdsfdf
abcde abcdefghijklm3
abcde abcdefghijklm4
abcde abcdefghijklm5
abcde abcdefghijklm6
12345 dfdfsdfdfd
sdfdsds
dsfdsfdf
abcde abcdefghijklm7
abcde abcdefghijklm9
abcde abcdefghijklm9

output file:
abcde abcdefghijklm1
abcde abcdefghijklm2
abcde abcdefghijklm3
abcde abcdefghijklm4
abcde abcdefghijklm5
abcde abcdefghijklm6
abcde abcdefghijklm7
abcde abcdefghijklm9
abcde abcdefghijklm9

Can we achive this using sort ?

Thanks in Advance!!!!
Srinath D
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Aug 25, 2011 3:35 pm    Post subject:
Reply with quote

Hi Srinath, Below SORTSTEP will give you desired result.
Input:
Code:
ABCDE ABCDEFGHIJKLM1
ABCDE ABCDEFGHIJKLM2
12345 DFDFSDFDFD   
SDFDSDS             
DSFDSFDF           
ABCDE ABCDEFGHIJKLM3
ABCDE ABCDEFGHIJKLM4
ABCDE ABCDEFGHIJKLM5
ABCDE ABCDEFGHIJKLM6
12345 DFDFSDFDFD   
SDFDSDS             
DSFDSFDF           
ABCDE ABCDEFGHIJKLM7
ABCDE ABCDEFGHIJKLM9
ABCDE ABCDEFGHIJKLM9

SORTSTEP:
Code:

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD DSN=yourinputfilehere,LRECL=20 
//SORTOUT  DD DSN=youroutputfilehere,LRECL=20                                 
//SYSIN    DD *                                         
 OPTION COPY,EQUALS                                     
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'12345'),   
 RECORDS=3,PUSH=(21:SEQ=1))                             
 OUTFIL INCLUDE=(21,1,CH,EQ,C' '),BUILD=(1,20)           
/*                                                       

Output:
Code:

ABCDE ABCDEFGHIJKLM1
ABCDE ABCDEFGHIJKLM2
ABCDE ABCDEFGHIJKLM3
ABCDE ABCDEFGHIJKLM4
ABCDE ABCDEFGHIJKLM5
ABCDE ABCDEFGHIJKLM6
ABCDE ABCDEFGHIJKLM7
ABCDE ABCDEFGHIJKLM9
ABCDE ABCDEFGHIJKLM9
Code:
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Thu Aug 25, 2011 4:09 pm    Post subject:
Reply with quote

Thank you Sambhaji.. it worked.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am


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