View previous topic :: View next topic
|
Author |
Message |
gpriyaeng
New User
Joined: 04 Jan 2008 Posts: 10 Location: hyderabad
|
|
|
|
Hi,
is there any difference between READ and READ INTO commands?
READ file-name
READ file-name INTO field-name
is it like for variable length files , we need go with READ INTO command and not READ? is there any difference in the processing?
i got this doubt becoz of the following scenario.
i have a variable length file of 256 bytes and when i use the READ command to read the first record in the file, it reads multiple lines from the file equal to length of 252( 4 bytes for length).....at end when i look at the variable i can see data from multiple lines in the file. this is very strange for me. when i replaced READ with READ INTO, it is reading only the first line.
Please clarify.
Thanks.
Gomathi Priya |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Gomanthi,
What do u mean by folowing?
Quote: |
i have a variable length file of 256 bytes and when i use the READ command to read the first record in the file, it reads multiple lines from the file equal to length of 252( 4 bytes for length).....at end when i look at the variable i can see data from multiple lines in the file. |
Please specify . How the variable accomdate data of multiple line.
Please provide ur code for clear undrstanding. |
|
Back to top |
|
|
gpriyaeng
New User
Joined: 04 Jan 2008 Posts: 10 Location: hyderabad
|
|
|
|
Hi ,
input file was as follows..
0234567
BRasn M M #
MRS M M BRasn
United Kingdom
.345566
bfdbd
fhfdh
hjdjs
code was
FILE SECTION.
FD CUSTOMER-FILE
LABEL RECORDS ARE STANDARD
RECORD IS VARYING IN SIZE FROM 1 TO 252 CHARACTERS
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS V
DATA RECORD IS GMS0161I-REC.
01 INPUT-REC PIC X(252).
WORKING STORAGE..
01 WS-CUST-REC PIC X(252).
READ CUSTOMER-FILE
MOVE INPUT-REC TO WS-CUST-REC
DISPLAY WS-CUST-REC
The output in spool for the display statement was as follows...
0234567.....BRasn M M #.....MRS M M BRasn.....United Kingdom....
....
in the above we see that after the first read, the output field has multiple lines read from the file.
Thanks.
Gomathi Priya |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Gomathi,
Did u intialize ur WS-CUST-REC ? |
|
Back to top |
|
|
gpriyaeng
New User
Joined: 04 Jan 2008 Posts: 10 Location: hyderabad
|
|
|
|
yes |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Gomathi,
Could u please provide the code of procedure division ? |
|
Back to top |
|
|
gpriyaeng
New User
Joined: 04 Jan 2008 Posts: 10 Location: hyderabad
|
|
|
|
code is procedure division is as follows.
INITIALIZE WS-CUST-REC
READ CUSTOMER-FILE
MOVE INPUT-REC TO WS-CUST-REC
DISPLAY WS-CUST-REC
..... |
|
Back to top |
|
|
ousep143
New User
Joined: 06 Oct 2007 Posts: 32 Location: India
|
|
|
|
Hi,
Try this one.Reply me.
FD CUSTOMER-FILE
LABEL RECORDS ARE STANDARD
RECORD IS VARYING IN SIZE FROM 1 TO 252 CHARACTERS
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS V
DATA RECORD IS GMS0161I-REC.
01 INPUT-REC.
05 WS-REC-LEN PIC S9(4) COMP.
05 WS-REC-TXT PIC X OCCURS 1 TO 252 TIMES
DEPENDING ON WS-REC-LEN.
Regards
|
|
Back to top |
|
|
|