In COBOL you must know the length of the longest record, else you will get a file status code of 44 when reading a record longer than you have specified in the FD. Of course, if you specify a maximum length that is greater than the actual longest record, there is no problem. On IBM mainframes, there is no such thing as a line sequential file, so the question does not apply, I don't know how you could read a file in any language when a record may be longer that you can anticipate.
As for finding out the langth of a record just read, if the records are specified as variable length, the LENGTH OF function will return that.