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

JCL sort to Skip n records based on the condition.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top