Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Can we do EOF checking for ACCEPT from SYSIN?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Can we do EOF checking for ACCEPT from SYSIN?
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    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Dec 27, 2010 10:45 pm    Post subject:
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

Active Member


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

PostPosted: Tue Dec 28, 2010 3:55 am    Post subject:
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    Post subject:
Reply with quote

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

Active User


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

PostPosted: Thu Dec 30, 2010 7:26 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Checking Current date vickey_dw DFSORT/ICETOOL 1 Wed Feb 08, 2017 11:14 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Syncsort - NULL in Integer field chec... nartcr SYNCSORT 4 Thu Oct 06, 2016 6:47 am
No new posts Reasonable way of checking wildcards ... sergeyken CLIST & REXX 5 Wed Sep 07, 2016 8:43 pm
No new posts Need to know what sysin for DFHTU690 ... pkmurali CICS 3 Mon Jul 25, 2016 1:36 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us