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

Extraction of a record from a file


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

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Jun 20, 2008 12:42 pm
Reply with quote

Hi,

We are required to extract some records (say 200) from a list of files for a particular month. These records are not related to one another except that they are for that particular month.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Jun 20, 2008 1:22 pm
Reply with quote

Hi,

If I understood correctly your question, concatenate all the files and extract required number of records using SORT.

E.g., 1. If you want to extract 1st 200 records, you can provide in control card OPTION COPY,STOPAFT=200.

2. If you want to extrct last 200 records, SKIP all the records except last 200. If you have 1000 records and want to select last 200 records, provide option OPTION COPY,SKIP=800.

KSK
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Jun 20, 2008 1:24 pm
Reply with quote

The files are neither first 200 or the last 200.

Actually the records are hapazardly located in the file. Now in this scenario can we extract them?
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Jun 20, 2008 1:31 pm
Reply with quote

If you want records which are in between you can use the combination of SKIPREC and STOPAFT.

E.g., if you want records from 300 to 500 from a particular file, provide the following option.

OPTION COPY,SKIPREC=300,STOPAFT=200. This would copy 300 to 500 records from the file.(Above I have mentioned SKIP, it is not only SKIP but SKIPREC).

If you have some other requirement, show us with Input and output.

KSK
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Jun 20, 2008 1:49 pm
Reply with quote

Let us assume the input to be

111111AAAAAAA10920190ADSJFADJFAJ54544
222222BBBBBBB54466461ASDKNCKKS54616
333333CCCCCCC10920190ADSJFADJFAJ54544
444444DDDDDDD54466461ASDKNCKKS54616
555555EEEEEEE10920190ADSJFADJFAJ54544
666666FFFFFFF54466461ASDKNCKKS54616
777777GGGGGGG10920190ADSJFADJFAJ54544
888888HHHHHHH54466461ASDKNCKKS54616
999999IIIIIII54466461ASDKNCKKS54616

We require the output as:
333333CCCCCCC10920190ADSJFADJFAJ54544
555555EEEEEEE10920190ADSJFADJFAJ54544
777777GGGGGGG10920190ADSJFADJFAJ54544
999999IIIIIII54466461ASDKNCKKS54616
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Jun 20, 2008 2:28 pm
Reply with quote

If you want to extract every 10th record or like that you can use SAMPLE option. In the example you have shown what is the creteria to extract the records?
Back to top
View user's profile Send private message
swapnadeep.ganguly

Active User


Joined: 21 Mar 2007
Posts: 203
Location: India

PostPosted: Fri Jun 20, 2008 5:37 pm
Reply with quote

The criteria is we have a fixed column position for the fields (say EEEEEEE). This field length is constant. We are provided a list of this variables. We are to extract these variables from the files and then write the same in one single file.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 20, 2008 5:50 pm
Reply with quote

swapnadeep.ganguly wrote:
The criteria is we have a fixed column position for the fields (say EEEEEEE). This field length is constant. We are provided a list of this variables. We are to extract these variables from the files and then write the same in one single file.


If you would clearly explain the criteria for extracting the records, provide the RECFM and LRECL and sample input and expected output then we could provide you with suggestion without guessing at what you want. It sounds like you want a simple INCLUDE but that is just a guess.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Jun 20, 2008 6:20 pm
Reply with quote

Using INCLUDE option we can acheive this. I am assuming your field (EEEEEEE) is of length '7' and starting at 7th position.

and I am assuming you have been provided AAAAAAA,BBBBBBB and 'EEEEEEE'
Code:

  OPTION COPY
  INCLUDE COND=(7,7,CH,EQ,C'AAAAAAA',
       OR,7,7,CH,EQ,C'BBBBBBB',OR,7,7,CH,EQ,C'EEEEEEE')
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Jun 20, 2008 6:26 pm
Reply with quote

Above solution extracts total record for the specified values.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Jun 20, 2008 8:44 pm
Reply with quote

Swapnadeep Ganguly,

If that's what you want to do, then alternatively you can use these DFSORT control statements:

Code:
                               
  OPTION COPY                                         
  INCLUDE COND=(7,7,SS,EQ,C'AAAAAAA,BBBBBBB,EEEEEEE') 


In the future, please try to explain the "rules" for what you're trying to do more clearly with examples.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
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 FTP VB File from Mainframe retaining ... JCL & VSAM 8
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