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

Can we do EOF checking for ACCEPT from SYSIN?


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

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Mon Dec 27, 2010 9:35 pm
Reply with quote

Hi
I hava a cobol program.
In it there are three lines of input string in SYSIN.
say

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCC

I have a dataname VAR1 PIC IS X(80).

I need to ACCEPT these inputs using the data name VAR1 and print them out on the spool.

I know how to do this using READ statement by taking SYSIN as a dataset. While taking SYSIN as a dataset, i can use READ statement and check for End of File using AT END.

But i just want to know how it can be done using ACCEPT statement.
Is there any way of checking the End of the input when using ACCEPT statment.

PERFORM 3 TIMES
ACCEPT VAR1 FROM SYSIN
DISPLAY VAR1
END-PERFORM.

It prints all the three lines of input. But here i mentioned 3 times which represent 3 lines of input strings. But i need the system will take care of end of file at the run time. How can i do it?
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Dec 27, 2010 10:11 pm
Reply with quote

According to the manual ( which you should have read ):

"If EOF is encountered before any data has been moved to the
receiving area, padding will not take place and the contents of the
receiving area are unchanged"

So, the way to "test" for EOF is to pre-load the receiving area with some value that would NEVER be input via SYSIN ( e.g. low values ), and then, AFTER the ACCEPT, test to see if the area still contains that pre-loaded value - if it does, then you have reached EOF.
Back to top
View user's profile Send private message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Mon Dec 27, 2010 10:20 pm
Reply with quote

Thanks for your reply Ronald. But i dont get you.
If possible could you please explain this with a small example.
Your kind help makes me to understand the solution better.

Thanks
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Dec 27, 2010 10:41 pm
Reply with quote

What's to explain?
Code:
MOVE LOW-VALUE TO VAR1(1:1)
ACCEPT VAR1 FROM SYSIN
IF VAR1(1:1) = LOW-VALUE
THEN
   do what should be done if SYSIN is at EOF
ELSE
   do what should be done if SYSIN is NOT at EOF
END-IF
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Dec 27, 2010 10:45 pm
Reply with quote

Hello,

Quote:
But i just want to know how it can be done using ACCEPT statement.
FWIW - none of the systems i've supported for many years (over 20) allow data entering the program via ACCEPT/sysin.

A parm is used for small amounts of data and a "real file" is used for things like your situation.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Dec 28, 2010 3:55 am
Reply with quote

But it is good robust programming to check for the lack of the three parms the program is expecting via ACCEPT.

If three parms are not present, or if other validity checks fail, then the program should be appropriately terminated.
Back to top
View user's profile Send private message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Tue Dec 28, 2010 7:56 am
Reply with quote

Thanks buddies.
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 121
Location: Puerto Rico

PostPosted: Thu Dec 30, 2010 7:26 pm
Reply with quote

You could do what Mr. Burr suggested or you could put a end-of-file marker in your sysin like 'END' which you would test for in your program to know that you have reached the end of data.
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 Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
No new posts REXX - Dataset checking in a do forev... CLIST & REXX 6
No new posts Checking the total counts inside a re... JCL & VSAM 5
No new posts COBOL reading from SYSIN COBOL Programming 1
No new posts concatenate sysin to dsn JCL & VSAM 7
Search our Forums:

Back to Top