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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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