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

Omitting a few columns and extracting data from a file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Wed Jan 31, 2007 8:16 am
Reply with quote

I have a file which is like below :-
Code:

I - EN123456
I - EN7891011
I - EN9862454


I want to extract the records omitting "I -" i.e the output file should be like below :-

Code:
EN123456
EN7891011
EN9862454


Is there any way to do it... please let me know.
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Wed Jan 31, 2007 8:33 am
Reply with quote

Using JCL Sort this can be done easily. Search the forum you get answer
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Wed Jan 31, 2007 8:42 am
Reply with quote

I have searched, but there isnt any requirement as simple as this. Since I am not too sure how to go about this, I have asked it againg.

Would be glad if someone can help ...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 31, 2007 8:55 am
Reply with quote

Hello,

You can use the DFSORT OUTREC statement to do what you want.
Code:
  OUTREC FIELDS=(5,length)


The above says to create the output record starting in byte 5 of the input/sort data for the number of bytes specified. If your records are 100 bytes long, this value will be 96 (i.e. 4 less than the record length).
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Wed Jan 31, 2007 9:08 am
Reply with quote

The below is the JCL I already have. And the file gets created PV9793A.OUTPUT.FILE. Now should I add the Outrec along with the SORT card. I.E should the sort card be :-

Code:
SORT FIELDS=(1,2,CH,A)                 
INCLUDE COND=(6,2,CH,EQ,C'EN')       
OUTREC FIELDS=(5,length)




Code:
//PV9793AA JOB (UU506505625,NM),'WXX331.GUISE',CLASS=0,MSGCLASS=X,     
//         NOTIFY=PV9793A                                               
//*  SUBMITTED AT BROC6     7.030 AT 14:23:38 BY PV9793A  FROM W9508DAC
//*  SUBMITTED AT BROC6     7.030 AT 14:01:15 BY PV9793A  FROM W9508DAC
/*ROUTE PRINT RMT14                                                     
//*                                                                     
//SUPERC  EXEC PGM=ISRSUPC,                                             
//            PARM=(DELTAL,LINECMP,                                     
//            '',                                                       
//            '')                                                       
//NEWDD   DD DSN=CHGMAN.CRSU.#003150.DCU(RLOLKY37),                     
//           DISP=SHR                                                   
//OLDDD   DD DSN=CHGMAN.CRSU.DCU(RLOLKY37),                             
//           DISP=SHR                                                   
//OUTDD   DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE),               
//           DISP=(MOD,PASS),                                           
//           DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)                       
//STEP1   EXEC PGM=SORT                                                 
//SORTIN  DD DSN=&&T1,DISP=MOD,                                         
//           DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)                       
//SORTOUT DD DSN=PV9793A.OUTPUT.FILE,                 
//           DISP=SHR                   
//SORWK01 DD UNIT=SYSDA,                 
//           SPACE=(CYL,(1,1),RLSE)     
//SORWK02 DD UNIT=SYSDA,                 
//           SPACE=(CYL,(1,1),RLSE)     
//SYSOUT  DD SYSOUT=*                   
//SYSIN   DD *                           
  SORT FIELDS=(1,2,CH,A)                 
  INCLUDE COND=(6,2,CH,EQ,C'EN')         
/*               
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Wed Jan 31, 2007 9:15 am
Reply with quote

To be more clear, PV9793A.OUTPUT.FILE gets created, and its contents are :-


Code:
I - EN123456
I - EN7891011
I - EN9862454


But I want PV9793A.COUTPUT.FILE to have only :-

Code:
EN123456
EN7891011
EN9862454


So shall I change my original JCL's sort card to be :-

Code:
SORT FIELDS=(1,2,CH,A)                 
INCLUDE COND=(6,2,CH,EQ,C'EN')       
OUTREC FIELDS=(5,length)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 31, 2007 9:28 am
Reply with quote

Hello,

Yes, if you add the OUTREC statement after the INCLUDE you should be ok as far as reformatting the unwanted characters out of the output file.

I'm not sure why MOD is specified on the SORTIN DD - my preference would be OLD,DELETE. You also don't need the DCB info on SORTIN. It will automatically be detected up from the &&T1 input file.

From the data you posted, it appears that all of the records have the same value in pos 1&2 - sorting on those positions alone may not give the results you want. I'd recommend your sort fields be (at least) 1,13 depending on what other data mioght be in the records. It also looks like the INCLUDE is one position off - the EN appears to begin in pos 5 not 6.

DISP=SHR should not be used for output files. Is there some reason that the SORTOUT is not being created as a new file?

Give it a try and let us know how it works icon_biggrin.gif
Back to top
View user's profile Send private message
murali922

New User


Joined: 25 Jul 2005
Posts: 92
Location: India

PostPosted: Wed Jan 31, 2007 9:47 am
Reply with quote

DISP = SHR is because I want the file to be reused everytime it runs. And there might be someother job trying to get access to this file as well.

I would try as you suggested and let you know.

Many thanks for the help ! Very glad.

Cheers.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 31, 2007 8:08 pm
Reply with quote

You're welcome.

A bit of understanding appears to be missing. A job CANNOT be writing that file while another is trying to access it!

Even if it would run somehow, imagine the situation if 2 jobs were writing and one job was reading the file at the same time. None of the results would be usable.

Specifying OLD will prevent this from happening. The first job running will hold the file until it completes then the next job may allocate the dataset. Also, if the volume may change, overwriting the file will not work well for you. It should be deleted and re-allocated each job. You could add an IEFBR14 at the start of the job to MOD,DELETE that dataset, then use NEW,CATLG in the SORTOUT.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top