GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Mainframe  >  COBOL
Go To First  |  Previous Question  |  Next Question 
 COBOL  |  Question 73 of 162    Print  
I want to copy the first and last record from the sequential file in efficient manner?

  
Total Answers and Comments: 7 Last Update: February 14, 2007     Asked by: Harry 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 07, 2006 15:39:58   #1  
Lazar Kaplansky        

RE: I want to copy the first and last record from the ...

You can do the following:

1. Run ICETOOL COUNT function to get total number of records

COUNT FROM(input file ddname)

2. Then run SORT utility with SKIP and STOPAFT to get first/last records


 
Is this answer useful? Yes | No
September 08, 2006 09:57:47   #2  
Rahul        

RE: I want to copy the first and last record from the ...

hello

i cant get your answer clearly can u explain with example ?

regards

rahul


 
Is this answer useful? Yes | No
October 04, 2006 00:59:20   #3  
Prashant        

RE: I want to copy the first and last record from the ...

hi

What you can do is -> first get the total number of records in the file (you may use File-aid -> Utilities - > Copy by this your file would be copied to another file giving total number of records copied). say the number of records is 100. so you need to copy only the 1st & the last record( record no 1 & 100).use following code to get the 1st & last record copied.

//STEP1 EXEC PGM IDCAMS
//DDIN01 DD DSN INPUT FILE NAME
//DDOUT01 DD DSN OUTPUT FILE NAME
//SYSPRINT DD SYSOUT *
//SYSIN DD *
REPRO -
INFILE(DDIN01) -
OUTFILE(DDOUT01) -
SKIP(1) - << THIS OPTION WILL SKIP YOUR FIRST
<< RECORD IN OUTPUT FILE AND
<< START COPYING FROM 2nd RECORD upto 99th record
COUNT(98)
/*
//


Output file will only have 1st & last record.

please let me know if you have some other tweak.

thanks

Prashant


 
Is this answer useful? Yes | No
October 05, 2006 09:24:51   #4  
Rajesh K        

RE: I want to copy the first and last record from the ...

Use IceTool To get Number of Counts.

Consider

//STep1 Exec PGM ICETOOL

//ToolMsg DD Sysout *

//inputfl dd disp fq.sq.input.file

//TOOLIN DD *

COUNT FROM(IN1)

/*


 
Is this answer useful? Yes | No
November 12, 2006 22:55:02   #5  
Michael Kaplan        

RE: I want to copy the first and last record from the ...

You can use batch fileaid. I do not remember the exact syntax.

//step1 exec pgm fileaid

$$DD01 copy out 1

//step2 exec pgm fileaid

$$DD02 copyback out 1

You can a) mod the same dataset or b) create concatenated dataset.

But that is basically it. For more info look at file-aid batch manual.

Regards

Michael


 
Is this answer useful? Yes | No
December 14, 2006 04:10:37   #6  
Vanita        

RE: I want to copy the first and last record from the ...

Count no of records.

Copy the OLD file into another NEW file using FILEAID.

At the end it will prompt no of records added. lets say 50 records added.

Then open the file in edit mode using FILEAID.

And in front of 2 records type DD48 this will delete 48 records including 2 record. So you will have only first and 50th record(last record).


 
Is this answer useful? Yes | No
February 14, 2007 03:58:25   #7  
Gurudev.k        

RE: I want to copy the first and last record from the ...
hi friend i have a solution for ur pbmplz go trg the jclfirst count the no of records for example if u have 1000 records and first u split those reccords form the input file 1)which contains the first record 2)contains the last record and concadinate those records

//TEDIACK1 JOB (AO13TSO0) 'TEDIACK1 ' MSGLEVEL (1 1) // //STEPR020 EXEC PGM SORT //*************
* //SYSOUT DD SYSOUT * //SORTIN DD
DSN IRFSD1.IGF.IRFS.OI.ALLINV.JAN0607 DISP SHR //SORTOUT DD DSN IRFSD1.IGF.IRFS.OI.ALLINV.JAN0607.BKUP2 // UNIT SYSDA SPACE (CYL (100 25) RLSE ROUND)
// DCB (LRECL 1650 BLKSIZE 23100 RECFM FB)
// DISP ( CATLG DELETE)
//SYSIN DD * SORT FIELDS COPY SKIPREC 999 (or) stopaft 001/*
skiprec will skip the 999 records and the out dataset will have only the last record stopaft 001 will have only the first record how write another step to concadinate those recordsregards Guru

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape