IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

difference between read and read into


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Fri Jan 11, 2008 11:54 am
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Jan 11, 2008 11:57 am
Reply with quote

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
View user's profile Send private message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Fri Jan 11, 2008 12:12 pm
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Jan 11, 2008 12:14 pm
Reply with quote

Hi Gomathi,

Did u intialize ur WS-CUST-REC ?
Back to top
View user's profile Send private message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Fri Jan 11, 2008 12:16 pm
Reply with quote

yes
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Jan 11, 2008 12:20 pm
Reply with quote

Hi Gomathi,

Could u please provide the code of procedure division ?
Back to top
View user's profile Send private message
gpriyaeng

New User


Joined: 04 Jan 2008
Posts: 10
Location: hyderabad

PostPosted: Fri Jan 11, 2008 12:46 pm
Reply with quote

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
View user's profile Send private message
ousep143

New User


Joined: 06 Oct 2007
Posts: 32
Location: India

PostPosted: Fri Jan 11, 2008 2:45 pm
Reply with quote

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
icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
No new posts Timestamp difference and its average ... DB2 11
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Difference when accessing dataset in ... JCL & VSAM 7
Search our Forums:

Back to Top