Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to read the last 100 records from a COBOL file. The file
contains N number of records.

Answers were Sorted based on User's Feedback



How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / santy

let consider,
First declear 2 count variables A,B.

first count all the records i.e. N and put it into A
varialbe.

compute statement B=A-100, i.e. B=N-100

now again use the read-para untill condition B=A

and in read para incrased the value of B=B+1 after each
read.

Is This Answer Correct ?    19 Yes 3 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / mobi and remya

PROCEDURE DIVISION.
PARA.
OPEN INPUT STUDFILE.
PERFORM PARA1 UNTIL EOF = 1.
DISPLAY 'TOTAL NO:OF RECORDS ' A.
COMPUTE B = A - 100.
MOVE 0 TO EOF.
CLOSE STUDFILE.
OPEN INPUT STUDFILE.
PERFORM PARA2 UNTIL EOF = 1.
CLOSE STUDFILE.
STOP RUN.
PARA1.
READ STUDFILE AT END MOVE 1 TO EOF.
COMPUTE A = A + 1.
PARA2.
READ STUDFILE AT END MOVE 1 TO EOF.
COMPUTE C = C + 1.
IF C >= B AND EOF NOT = 1
DISPLAY STUD-REC.

Is This Answer Correct ?    16 Yes 0 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / bibhuti swain

PROCEDURE DIVISION.
PARA.
OPEN INPUT STUDFILE.
PERFORM PARA1 UNTIL EOF = 1.
DISPLAY 'TOTAL NO:OF RECORDS ' A.
COMPUTE B = A - 100.
MOVE 0 TO EOF.
CLOSE STUDFILE.
OPEN INPUT STUDFILE.
PERFORM PARA2 UNTIL EOF = 1.
CLOSE STUDFILE.
STOP RUN.
PARA1.
READ STUDFILE AT END MOVE 1 TO EOF.
COMPUTE A = A + 1.
PARA2.
READ STUDFILE AT END MOVE 1 TO EOF.
COMPUTE C = C + 1.
IF C >= B AND EOF NOT = 1
DISPLAY STUD-REC.
If anybody doesn't understand this logic i can explain..
In PARA2 the file is read from the beginning and the moment
the value of C reaches the value of B i.e value of C = B
and then it will satisfy the condition IF C >= B and from
there it will start displaying the records till end.

Is This Answer Correct ?    14 Yes 1 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / m.rajasekaran

Hi Mobi and Remya,

logic is correct

But in PARA2 u have coded that COMPUTE C = C + 1, How it
will work?

You should have moved B to C after calculating the value
of B in PARA1.Then only this code will work.

Let me know if any mistake in my answer.

Is This Answer Correct ?    6 Yes 2 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / giri12

Hi Santy in ur answer u mentioned that..
read-para untill condition B=A

Can you please explain it. Coz B=900 and A=1000(assume)
then how will be 900=1000?

Is This Answer Correct ?    3 Yes 1 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / venkat

in my view if it is a ksds cluster file use organization as
dynamic and accept the related value start reading the file
and write it..i think this will display the last hundred
records..
correct me..
venkat

Is This Answer Correct ?    2 Yes 0 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / guest

First move HIGH-VALUES to the key field and then read the
file.It will read the last record then put READ PREV in
loop 100 times to get the last 100 records.

Is This Answer Correct ?    4 Yes 4 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / heeraj r

Pls post the correct question. I am not sure what you mean
by COBOL file, is it PS or VSAM or Tape etc etc? If you
want last 100 records of a file use below SORT JCL, and if
required that output file can be read in your COBOL.

//S1 EXEC
PGM=ICETOOL
//TOOLMSG DD
SYSOUT=*
//DFSMSG DD
SYSOUT=*
//IN DD DSN=... input
file
//OUT DD DSN=... output file
//TOOLIN DD
*
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST(100)
/*

Is This Answer Correct ?    1 Yes 1 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / kingmanish

question is ambiguous.
Could you please explain what do u mean by cobol file?

PLease specify what type of file??? Flat file? VSAM ??

Is This Answer Correct ?    0 Yes 0 No

How to read the last 100 records from a COBOL file. The file contains N number of records...

Answer / kk

Hi,
u declare two count variable.first count all the
records.then using compute statement count - 100.now move
the count no to second one.now again use read at end.now
give the condition grater than count-2 display rec.

Is This Answer Correct ?    4 Yes 8 No

Post New Answer

More COBOL Interview Questions

I am sending values a and b with pic x(10) and pic x(10) by using call statement. In linkage section, I am receiving values with pic x(10) and pic x(11). Will my program fail? will it be compile error or run time abend?

3 Answers  


what is jcl approach for programming?

4 Answers   IBM,


What are options have been removed in COBOL 11?

1 Answers  


what is the purpose of linkage section?

10 Answers  


I've one string with spaces ( I N D I A ). My question is I want remove the spaces & combine in to single string without space (INDIA).How we can write the cobol program & wich options we need to use. Please let me know.

10 Answers   Mascon,


What is 66 level number and where it is used in real time by software developers?

2 Answers   ITC Indian Tobacco Company, TCS,


Write down the divisions of cobol program?

0 Answers  


Scenario: I have 3 Input Files.Read the first i/p file and depending on certain business logic, I want to read wither i/p file-2 or i/p file-3.Now, depending on certain business logic applied to the record read from either file-2 or file-3, I decide to write them to either output file-2 or output file-2. Question: How many job steps are necessary to implement a solution for the above.

2 Answers   TCS,


How do u sort the table for Search ALL? Is it only using ASCENDING KEY IS statement in occurs clause? If the data is input in non ascending order, will the ASC KEY IS automatically sort the data? or will it throw compile time error?

1 Answers   CTS,


can i give 9(10) in comp 3 instead of s9(10) ? if i can give wht would be ths ans

2 Answers   DELL,


if a>b continue display x. dispaly y. end-if display 1 display 2. display 3. what should be my output ?

3 Answers  


Are you comfortable in cobol or jcl?

0 Answers  


Categories