how to fetch the record before the last record in a cobol
file( its a huge file and if the key field is not known)

Answer Posted / mailid

1.Read the file sequentially
2.For every successful read, move the key field to temp variable
3.when EOF is reached, A separate section should be performed in which Key field should not be moved to temp variable, Now, the temp variable will have key of the previously read record.
Using this, we can do a keyed read on the file to fetch the last but one record.

Is This Answer Correct ?    5 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are different data types in cobol?

683


How can we find that module can be called – whether DYNAMICALLY or STATICALLY?

706


What is redefines clause in COBOL?

842


What is the LINKAGE SECTION used in COBOL?

885


what happens if parmparameter passes zero bytes to the program

1653






Explain the configuration section of a cobol program with examples of syntax.

651


What is amode(31)

714


What is the difference between Structured COBOL Programming and Object Oriented COBOL programming?

670


I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?

1797


What is the usage of comp fields in cobol?

649


how do you reference the variable unblock file formats from cobol programs

738


I have a program with an Array of 5000 occurences which is being passed from 5 sub levels to the front end screen. Thess 5 programs using each 5*2 = 10 different arrays with size as 5000. This is causing the transaction to utilize more storage consupmtion. I am looking to reduce the storage consumption. As part of that initially i thought Dynamic array may solve my problem. After viewing the comments given i see its same as normal array. IS there any other way we can resolve this issue?

1224


What are literals?

622


What is the difference between comp and comp-3?

692


What is the default value(s) for an initialize? What keyword will allow for an override of the default?

651