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
 
Write 10 characters of each record starting from substring

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Write 10 characters of each record starting from substring
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    Post subject: Reply to: Write 10 characters of each record starting from s
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Nov 23, 2012 12:43 pm    Post subject: Reply to: Write 10 characters of each record starting from s
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    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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 3 Sat Oct 14, 2017 2:29 am
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

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