I want to copy the first and last record from the sequential file in efficient manner?

Showing Answers 1 - 13 of 13 Answers

Lazar Kaplansky

  • Sep 7th, 2006
 

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 

    

  Was this answer useful?  Yes

Rahul

  • Sep 8th, 2006
 

hello

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

regards,

rahul

Prashant

  • Oct 4th, 2006
 

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

  Was this answer useful?  Yes

Rajesh K

  • Oct 5th, 2006
 

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)

/*

  Was this answer useful?  Yes

Michael Kaplan

  • Nov 12th, 2006
 

  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

  Was this answer useful?  Yes

Vanita

  • Dec 14th, 2006
 

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).

  Was this answer useful?  Yes

Gurudev.k

  • Feb 14th, 2007
 

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

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions