Code Comments
Programming Forum and web based access to our favorite programming groups.Hi All, We have file containing n*Records without any Line seperator. This implies complete file will be in one line: Now, How do we read this one line (nRecords with no seperator) in Cobol? No. of Records in the file can vary from 2000-15000 and each record is of size 60 bytes. Would it be possible to read a file for X bytes without knowing the complete length? Can someone help me please ! -Vijay
Post Follow-up to this message> We have file containing n*Records without any Line seperator. > This implies complete file will be in one line: No, it does not imply that at all. Not in Cobol, nor in any language. The file is most likely in fixed length segments, the length of which is known to be program. The program just reads one chunk of n bytes and then the next chunk of n bytes. > No. of Records in the file can vary from 2000-15000 and > each record is of size 60 bytes. Exactly. The program knows it is 60 byte records so the first read just reads bytes 1 - 60 and advances the file pointer to 61. The next read gets bytes 61-120 and so on.
Post Follow-up to this message- posted and emailed - In article <1103237938.139278.319220@z14g2000cwz.googlegroups.com>, <svaranas@hotmail.com> wrote: >Hi All, >We have file containing n*Records without any Line seperator. [snip] >Can someone help me please ! This might be possible... but it would be good not to duplicate your own efforts; please post what you have coded so far for a solution. DD
Post Follow-up to this messagesvaranas@hotmail.com wrote:
> Hi All,
> We have file containing n*Records without any Line seperator.
> This implies complete file will be in one line: Now, How do we read
> this one line (nRecords with no seperator) in Cobol?
>
> No. of Records in the file can vary from 2000-15000 and each record is
> of size 60 bytes.
>
> Would it be possible to read a file for X bytes without knowing the
> complete length?
>
> Can someone help me please !
Allow me to rephrase: You have an indeterminate number of fixed-length
60-byte records. Yes?
COBOL generally admits of two types of text files:
LINE SEQUENTIAL where the record is delimited by a carriage-return and the
unused bytes of the FD are blank-filled on input and
SEQUENTIAL where the record is defined as the length specified in the FD.
Point being, there are TWO types of sequential files native to COBOL; you
want the other one.
In your case:
SELECT IN-FILE ASSIGN TO {something}
ORGANIZATION IS SEQUENTIAL (or whatever your compiler uses)
..
FD IN-FILE.
01 IN-REC PIC X(60).
There is another way. Don't use it if you want the results before next
Wednesday.
FD IN-FILE.
01 IN-REC PIC X.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 60
READ IN-FILE
END-PERFORM.
This last example burns CPU cycles like witches in Salem, but may sometimes
be necessary if the record delimited is something goofy (like "?").
Post Follow-up to this messageOn 16 Dec 2004 14:58:58 -0800, svaranas@hotmail.com wrote: >Hi All, >We have file containing n*Records without any Line seperator. >This implies complete file will be in one line: Now, How do we read >this one line (nRecords with no seperator) in Cobol? > >No. of Records in the file can vary from 2000-15000 and each record is >of size 60 bytes. > >Would it be possible to read a file for X bytes without knowing the >complete length? > >Can someone help me please ! It's normal for 'Cobol files' to not have a line seperator. Define it as ORGANIZATION [RECORD] SEQUENTIAL with a record length (in the FD) of 60 bytes.
Post Follow-up to this messageOn 16 Dec 2004 14:58:58 -0800, svaranas@hotmail.com wrote: >Hi All, >We have file containing n*Records without any Line seperator. >This implies complete file will be in one line: Now, How do we read >this one line (nRecords with no seperator) in Cobol? > >No. of Records in the file can vary from 2000-15000 and each record is >of size 60 bytes. > >Would it be possible to read a file for X bytes without knowing the >complete length? > >Can someone help me please ! It's normal for 'Cobol files' to not have a line seperator. Define it as ORGANIZATION [RECORD] SEQUENTIAL with a record length (in the FD) of 60 bytes.
Post Follow-up to this message- posted and emailed - In article <1103237938.139278.319220@z14g2000cwz.googlegroups.com>, <svaranas@hotmail.com> wrote: >Hi All, >We have file containing n*Records without any Line seperator. [snip] >Can someone help me please ! This might be possible... but it would be good not to duplicate your own efforts; please post what you have coded so far for a solution. DD
Post Follow-up to this messagesvaranas@hotmail.com wrote:
> Hi All,
> We have file containing n*Records without any Line seperator.
> This implies complete file will be in one line: Now, How do we read
> this one line (nRecords with no seperator) in Cobol?
>
> No. of Records in the file can vary from 2000-15000 and each record is
> of size 60 bytes.
>
> Would it be possible to read a file for X bytes without knowing the
> complete length?
>
> Can someone help me please !
Allow me to rephrase: You have an indeterminate number of fixed-length
60-byte records. Yes?
COBOL generally admits of two types of text files:
LINE SEQUENTIAL where the record is delimited by a carriage-return and the
unused bytes of the FD are blank-filled on input and
SEQUENTIAL where the record is defined as the length specified in the FD.
Point being, there are TWO types of sequential files native to COBOL; you
want the other one.
In your case:
SELECT IN-FILE ASSIGN TO {something}
ORGANIZATION IS SEQUENTIAL (or whatever your compiler uses)
..
FD IN-FILE.
01 IN-REC PIC X(60).
There is another way. Don't use it if you want the results before next
Wednesday.
FD IN-FILE.
01 IN-REC PIC X.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 60
READ IN-FILE
END-PERFORM.
This last example burns CPU cycles like witches in Salem, but may sometimes
be necessary if the record delimited is something goofy (like "?").
Post Follow-up to this messageOn 16 Dec 2004 14:58:58 -0800, svaranas@hotmail.com wrote: >Hi All, >We have file containing n*Records without any Line seperator. >This implies complete file will be in one line: Now, How do we read >this one line (nRecords with no seperator) in Cobol? > >No. of Records in the file can vary from 2000-15000 and each record is >of size 60 bytes. > >Would it be possible to read a file for X bytes without knowing the >complete length? > >Can someone help me please ! It's normal for 'Cobol files' to not have a line seperator. Define it as ORGANIZATION [RECORD] SEQUENTIAL with a record length (in the FD) of 60 bytes.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.