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

Write 10 characters of each record starting from substring


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Wed Nov 21, 2012 2:47 pm
Reply with quote

Hello All,

I have the following requirement.


Sample Input File looks like as follows.
Input file is a VB file with 3 different file lengths 120, 140 and 160 characters
The substrings in these 3 records are 'BCD' starts at position 16, 'PQR' starts at position 25 and 'IJK' starts at position 39.

Code:

011891000000000BCD00201232500000000008308A377810917334176     000000000830000010
023898200000000690002012PQR00000000002608B310010304496430     000000000260000080
02784804500000069040201232500000000006IJKD310020304496430     000000000700000080
025698000510000BCD04201232400000000035845F720310783435545     000000003580000010
023445660040001468302012PQR00000000001818J334510679199437     000000000180000080
02189800000110146400201232500000000009IJKH745210679199437     000000000960000080
02233800000001111800201232500000000005IJKF853610679199437     000000000510000080
023498012314101580002012PQR00000000009724B936410997998452     000000000970000010
025493000000001BCD00201232500000000019900D312210301093149     000000001990000080


My requirement is to write the records starting with specifc sub-string and then to 10 characters.

Output file should look like
Code:

BCD0020123
BCD0420123
BCD0020123
PQR0000000
PQR0000000
PQR0000000
IJKD310020
IJKH745210
IJKF853610


I am able to do this with the following code using sort in 5 steps. Please let me know if there is any other way to get this done in one or two steps.

My code is
Code:

//SETP001  EXEC PGM=SORT                                 
//SYSPRINT DD SYSOUT=*                                   
//SYSOUT   DD SYSOUT=*                                   
//SYSUDUMP DD SYSOUT=*                                   
//REPORT1  DD SYSOUT=*                                   
//SORTIN   DD DISP=SHR,DSN=USERID.TEST.VBFILE1       
//SORTOF01 DD DSN=USERID.ABC.OUTFIL1,               
//      DISP=(,CATLG),                                   
//      SPACE=(TRK,(30,10),RLSE),                         
//      UNIT=SYSDA,                                       
//      DCB=(RECFM=FB,LRECL=120,BLKSIZE=0,DSORG=PS)       
//SORTOF02  DD DSN=USERID.ABC.OUTFIL2,               
//      DISP=(,CATLG),                                   
//      SPACE=(TRK,(30,10),RLSE),                         
//      UNIT=SYSDA,                                       
//      DCB=(RECFM=FB,LRECL=140,BLKSIZE=0,DSORG=PS)       
//SORTOF03  DD DSN=USERID.ABC.OUTFIL3,               
//      DISP=(,CATLG),                                   
//      SPACE=(TRK,(30,10),RLSE),                         
//      UNIT=SYSDA,                                       
//      DCB=(RECFM=FB,LRECL=160,BLKSIZE=0,DSORG=PS)
//SORTWK01 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK02 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK03 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SYSIN    DD *                                     
 SORT FIELDS=COPY                                   
 OUTFIL FILES=01,VTOF,                             
 INCLUDE=(20,3,CH,EQ,C'BCD')                           <<== Actual position of substring is 16
 OUTFIL FILES=02,VTOF,                             
 INCLUDE=(29,3,CH,EQ,C'PQR')                           <<== Actual position of substring is 25
 OUTFIL FILES=03,VTOF,                             
 INCLUDE=(43,3,CH,EQ,C'IJK')                           <<== Actual position of substring is 39
/*                                                 
//*                                                 
//SETP002  EXEC PGM=SORT                           
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSUDUMP DD SYSOUT=*                             
//REPORT1  DD SYSOUT=*                             
//SORTIN   DD DISP=SHR,DSN=USERID.ABC.OUTFIL1
//SORTOUT  DD DSN=USERID.ABC.SORTOUT1,       
//      DISP=(,CATLG),                             
//      SPACE=(TRK,(30,10),RLSE),                 
//      UNIT=SYSDA,                               
//      DCB=(RECFM=FB,LRECL=10,BLKSIZE=0,DSORG=PS)
//SORTWK01 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK02 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK03 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SYSIN    DD *                                   
 SORT FIELDS=COPY                                 
 OUTREC BUILD=(1:20,10)                           
/*                                                 
//SETP003  EXEC PGM=SORT                           
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSUDUMP DD SYSOUT=*                             
//REPORT1  DD SYSOUT=*                             
//SORTIN   DD DISP=SHR,DSN=USERID.ABC.OUTFIL2
//SORTOUT  DD DSN=USERID.ABC.SORTOUT2,       
//      DISP=(,CATLG),                             
//      SPACE=(TRK,(30,10),RLSE),                 
//      UNIT=SYSDA,                               
//      DCB=(RECFM=FB,LRECL=10,BLKSIZE=0,DSORG=PS)
//SORTWK01 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK02 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK03 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SYSIN    DD *                                   
 SORT FIELDS=COPY                                 
 OUTREC BUILD=(1:29,10)                           
/*                                                 
//SETP004  EXEC PGM=SORT                           
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSUDUMP DD SYSOUT=*                             
//REPORT1  DD SYSOUT=*                             
//SORTIN   DD DISP=SHR,DSN=USERID.ABC.OUTFIL3          
//SORTOUT  DD DSN=USERID.ABC.SORTOUT3,       
//      DISP=(,CATLG),                             
//      SPACE=(TRK,(30,10),RLSE),                 
//      UNIT=SYSDA,                               
//      DCB=(RECFM=FB,LRECL=10,BLKSIZE=0,DSORG=PS)
//SORTWK01 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK02 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SORTWK03 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)   
//SYSIN    DD *                                   
 SORT FIELDS=COPY                                 
 OUTREC BUILD=(1:43,10)                           
/*                                                 
//SETP005  EXEC PGM=IEBGENER                       
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSUDUMP DD SYSOUT=*                             
//REPORT1  DD SYSOUT=*                             
//SYSUT1   DD DSN=USERID.ABC.SORTOUT1,DISP=SHR         <<== File with record length of 120
//         DD DSN=USERID.ABC.SORTOUT2,DISP=SHR         <<== File with record length of 140
//         DD DSN=USERID.ABC.SORTOUT3,DISP=SHR         <<== File with Record length of 160
//SYSUT2   DD DSN=USERID.ABC.SORTOUT,                 <<== Final Output
//      DISP=(,CATLG),                           
//      SPACE=(TRK,(30,10),RLSE),                 
//      UNIT=SYSDA,                               
//      DCB=(RECFM=FB,LRECL=10,BLKSIZE=0,DSORG=PS)
//SYSIN    DD DUMMY                               
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Nov 21, 2012 8:17 pm
Reply with quote

use the following 1 step DFSORT JCL which will give you the desired results

Code:

//STEP0100  EXEC PGM=SORT                                 
//SYSOUT    DD SYSOUT=*                                   
//SORTIN    DD DISP=SHR,DSN=USERID.TEST.VBFILE1
//SORTOUT   DD DSN=USERID.ABC.SORTOUT,
//             DISP=(,CATLG),                           
//             SPACE=(TRK,(30,10),RLSE),                 
//             UNIT=SYSDA
//*
//SYSIN    DD *                                             
  OPTION COPY                                               
  INCLUDE COND=(20,3,CH,EQ,C'BCD',OR,                       
                29,3,CH,EQ,C'PQR',OR,                       
                43,3,CH,EQ,C'IJK')                           
                                                             
  INREC IFTHEN=(WHEN=(20,3,CH,EQ,C'BCD'),BUILD=(1,4,20,10)),
        IFTHEN=(WHEN=(29,3,CH,EQ,C'PQR'),BUILD=(1,4,29,10)),
        IFTHEN=(WHEN=(43,3,CH,EQ,C'IJK'),BUILD=(1,4,43,10)) 
                                                             
  OUTFIL VTOF,BUILD=(5,10)                                   
//*
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Thu Nov 22, 2012 11:33 am
Reply with quote

Hi Skolusu,

Thanks for your response. I have another question here with slight change in the scenario.

As, we can copy the records from INFILE to OUTFILE when the records contain a specific sub-string at any position in the record using the following sort card
INCLUDE COND=(1,80,SS,EQ,C'ABC')

Now current Scenario is: If there is only one substring 'ABC' (instead of multiple search strings in a file) and it may appear at any position in the record dynamically, Then, How to change the sort card using INCLUDE and INREC ?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Nov 23, 2012 12:43 pm
Reply with quote

Have you looked at PARSE?
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(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top