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
 

 

Want to put in a loop in EVALUATE
Goto page 1, 2  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 72
Location: india

PostPosted: Fri Apr 06, 2012 3:35 pm    Post subject: Want to put in a loop in EVALUATE
Reply with quote

Hi,

I want to execute my current Evaluate logic until end of records.
My current Evaluate is like that:

EVALUATE ACTION-TYPE
WHEN 'R'
PERFORM 1000-SELECT-PROCESS THRU 1000-EXIT
WHEN 'A'
PERFORM 2000-ACCEPT-PROCESS THRu 2000-EXIT
WHEN 'V'
PERFORM 3000-DELETE-PROCESS THRU 3000-EXIT
END-EVALUATE.

The above operation is for single record.
Now my new requirement is, if the ACTION-TYPE is V, then there may be multiple records to delete.

so i have to change the condition to accept for multiple records to delete.

If I code like this,

In the WORKING STORAGE SECTION... i declare
01 WS-SWITCHES.
05 END-OF-DEL-FILE-FLAG PIC X(01) VALUE 'N'.
88 END-OF-DEL-YES VALUE 'Y'.

then... changing the EVALUATE like...

EVALUATE ACTION-TYPE
WHEN 'R'
PERFORM 1000-SELECT-PROCESS THRU 1000-EXIT
WHEN 'A'
PERFORM 2000-ACCEPT-PROCESS THRu 2000-EXIT
END-EVALUATE.

EVALUATE ACTION-TYPE UNTIL END-OF-DEL-YES
WHEN 'V'
PERFORM 3000-DELETE-PROCESS THRU 3000-EXIT
AT END SET END-OF-DEL-YES TO TRUE
END-EVALUATE.

Will it work properly for sngle and multiple records to process when ACTION-TYPE = D ?

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

maxsubrat

New User


Joined: 27 Feb 2008
Posts: 72
Location: india

PostPosted: Fri Apr 06, 2012 3:36 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

little correcton.. in the last line

Will it work properly for sngle and multiple records to process when ACTION-TYPE = V ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Apr 06, 2012 3:45 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

Why wouldn't your existing code work with multiple records?
Back to top
View user's profile Send private message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 72
Location: india

PostPosted: Fri Apr 06, 2012 4:09 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

I think once a single records processed(deleted), then it will execute END-EVALUATE.
If 5 records are there suppose with ACTION-TYPE as V, in that case i think the 1st record will delete.
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Fri Apr 06, 2012 4:21 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

I understand you did not test your code, because it contains some COBOL-errors. WHY did you not test before asking ?

There is nothing as At End ind an evaluate!
You say you want to perform many deletes when ACTION-TYPE is V!
Why not put it in a loop like
Code:
When 'V'
     Perform 3000-Delete-Process
         Until End-Of-Del-Yes
End-Evaluate


In the 3000-Delete-Process paragraph you just set the End-Of-Del-Yes to true when you have finished your deletes.
Another tip: there is no need for the full stop (.) after a COBOL-verb. Just give a . at the end just before the the next paragraphname.
Yet another tip: Ever Never code Perform THRU ! Also there is no need for the different -EXIT paragraphs, assuming you dont code -70s COBOL using a lot of GO TOs.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Apr 06, 2012 4:29 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

You read a record, you do the evaluate with the new action type, whose code in the performs cause the current record to be processed. Repeat until EOF. What's difficult?

If you need to do "multiple stuff" to process any particular type of record, just code that inside the relevant perform.
Back to top
View user's profile Send private message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 72
Location: india

PostPosted: Fri Apr 06, 2012 4:46 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

For a single record, there is an ACTION-TYPE.
Suppose take 'V' as ACTION-TYPE, for each record there is an action type.
So If i put the end of record condition before the WHEN 'V', then only all the records will process.
If I put after that, which you provided, then how can all the records processed ? Instead it will process only one record.


I have not tested the code, because due to some interface with other application.
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Fri Apr 06, 2012 5:09 pm    Post subject:
Reply with quote

You said:
Quote:
Now my new requirement is, if the ACTION-TYPE is V, then there may be multiple records to delete.

The quote from your post tells me that you have many records to delete when you find 'V' as Action-Type.
I will have to assume you read som records from a file (File1), and every record tells you "what to do". This "what to do" may be delete one or many records in another file (File2). In this case my code works.
I think you have to be more detailed in your description.
This is not a "problem", but normal programming logic for a COBOL-programmer. If you do not quallify, pls use http://ibmmainframeforum.com/ - for students etc.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Fri Apr 06, 2012 5:14 pm    Post subject:
Reply with quote

How do you help a new programmer by answering questions before he has even taken 5 minutes to test his code?
Back to top
View user's profile Send private message
coboljoost

New User


Joined: 05 Apr 2012
Posts: 5
Location: groningen

PostPosted: Thu Apr 12, 2012 2:04 am    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
Reply with quote

Peter cobolskolan wrote:
I understand you did not test your code, because it contains some COBOL-errors. WHY did you not test before asking ?

There is nothing as At End ind an evaluate!
You say you want to perform many deletes when ACTION-TYPE is V!
Why not put it in a loop like
Code:
When 'V'
     Perform 3000-Delete-Process
         Until End-Of-Del-Yes
End-Evaluate


In the 3000-Delete-Process paragraph you just set the End-Of-Del-Yes to true when you have finished your deletes.
Another tip: there is no need for the full stop (.) after a COBOL-verb. Just give a . at the end just before the the next paragraphname.
Yet another tip: Ever Never code Perform THRU ! Also there is no need for the different -EXIT paragraphs, assuming you dont code -70s COBOL using a lot of GO TOs.


in my opinion ALWAYS code a perform .. thru ..-exit
its best practice.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Apr 12, 2012 2:19 am    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
Reply with quote

coboljoost wrote:

in my opinion ALWAYS code a perform .. thru ..-exit
its best practice.


Welcome to the forum.

Not much of an argument to support your assertion, is there?

In my opinion ALWAYS follow the site standards. Feel free to try to change them, but if you loose the argument accept it and go with what everyone else does.

Three in the morning is no time to find that someone else's "best practice" has been misunderstood by someone on maintenance.

As to always code perform thru ..-exit, it's nuts. My opinion. However, if that is what a boss wants, that's what they get. And a request to explain why, of course :-)
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Thu Apr 12, 2012 7:01 pm    Post subject:
Reply with quote

@ maxsubrat

Back to the top first.

"EVALUATE ACTION-TYPE UNTIL END-OF-DEL-YES"

Wow, do we have an enhancement in the evaluate-clause now?
Back to top
View user's profile Send private message
coboljoost

New User


Joined: 05 Apr 2012
Posts: 5
Location: groningen

PostPosted: Thu Apr 12, 2012 11:39 pm    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
Reply with quote

Bill Woodger wrote:
coboljoost wrote:

in my opinion ALWAYS code a perform .. thru ..-exit
its best practice.


Welcome to the forum.

Not much of an argument to support your assertion, is there?

...


it has to do with the following :
.

...you might be working on small systems for small companies, but i work on huge systems for (huge) companies, since we use cobol i assume this is LEGACY software..otherwise the company probably uses an oop language..other companies use a cobol-dialect which is generated into normal cobol then compiled.

the generated cobol and also some -70's cobol and cobol by not-so-skilled programmers can contain many go to's.

there is no telling where u might end-up if there is a mishap in the code...
the thru... -exit is there for a good reason...

unless you live in a perfect world without go to's in legacy software, its best practise to use the thru.. -exit

did not mean to offend u, its my opinion.

there's no telling where you'll end up if someone made an error in code that does compile..

again, i work on code that in some cases has been written many years ago, it might been written by other programmers. the systems i work on are too large to read line by line. there might be go to's in the source and there might not be, i dont really need to know and i dont care. if the code works and the assignment is NOT to rewrite existing code i wont touch it.
It might have go to's it might not, with the thru ..-exit i keep risks in check.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Apr 13, 2012 12:11 am    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
Reply with quote

Don't worry, I am far from easily offended :-)

Quote:
there is no telling where u might end-up if there is a mishap in the code...
the thru... -exit is there for a good reason...

Quote:
unless you live in a perfect world without go to's in legacy software, its best practise to use the thru.. -exit

Quote:

there's no telling where you'll end up if someone made an error in code that does compile..

Quote:

It might have go to's it might not, with the thru ..-exit i keep risks in check.


The above seem to be the content of your reply. I am confused. If you yourself do not code GO TOs (I'm guessing you, generally, don't) then you don't need any paragraphs (as in those which are not PERFORMed), as you have nothing for them to be targets of. So you don't need a -exit. So you don't need PERFORM THRU. If you do code GO TOs yourself, you need paragraphs, and may well need -exit as a target for a GO TO.

Reading between the lines, you seem to think that the PERFORM THRU protects you in some way from the errant GO TOs of others. If you do think that, would you care to explain?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7909
Location: Bellevue, IA

PostPosted: Fri Apr 13, 2012 12:33 am    Post subject:
Reply with quote

Quote:
there's no telling where you'll end up if someone made an error in code that does compile..
This is true no matter what standards are in use.

If a program contains GO TO and PERFORM statements, the possibility exists for falling through PERFORM EXIT paragraphs. In fact, a poorly written program can even fall through PERFORM EXIT paragraphs without a single GO TO statement in it -- we've seen examples on this forum.
Back to top
View user's profile Send private message
coboljoost

New User


Joined: 05 Apr 2012
Posts: 5
Location: groningen

PostPosted: Fri Apr 13, 2012 3:13 am    Post subject:
Reply with quote

reworked the post and could not find a delete button, see post below
Back to top
View user's profile Send private message
coboljoost

New User


Joined: 05 Apr 2012
Posts: 5
Location: groningen

PostPosted: Fri Apr 13, 2012 3:17 am    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
Reply with quote

Quote:

Reading between the lines, you seem to think that the PERFORM THRU protects you in some way from the errant GO TOs of others. If you do think that, would you care to explain?


as robert stated, when not using the exit statement the possibility exist for falling through the perform exit paragraph (especially so when using goto's).

when this happens it can be very hard to find out why a program is not behaving like expected (debugging might give you serious headaches!).

using the "thru ..-exit" will make life easier when debugging.

Although i do not use go to's myself, i mainly program in a cobol dialect (called delta-cobol), this source is generated into standard cobol(85) which in turn is compiled.

the generated cobol does contain many go to's (even though me and other programmers don't use go to's in the delta-cobol source).
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Apr 13, 2012 3:55 am    Post subject: Re: Reply to: Want to put in a loop in EVALUATE
Reply with quote

coboljoost wrote:
[...]
as robert stated, when not using the exit statement the possibility exist for falling through the perform exit paragraph (especially so when using goto's).

What Robert actually wrote:
If a program contains GO TO and PERFORM statements, the possibility exists for falling through PERFORM EXIT paragraphs. In fact, a poorly written program can even fall through PERFORM EXIT paragraphs without a single GO TO statement in it -- we've seen examples on this forum.


Quite a different thing.

Quote:
using the "thru ..-exit" will make life easier when debugging.


Can you explain how?

Can you explain, leaving aside all the other stuff, what you think

Code:
    PERFORM A-PARAGRAPH THRU A-PARAGRAPH-EXIT

A-PARAGRAPH.

...

A-PARAGRAPH-EXIT.
    EXIT
    .


does for you? How does it protect you from GO TOs? How does it aid you at all? Leaving out all the rest, just sticking to the subject. You gave it as general advice, best practice, so...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 13, 2012 5:37 am    Post subject:
Reply with quote

one of my skills (for which i have received mucho dinero)
is laying code in a module so that no one can find my code except
due to an id and remarks.

if I am writing a program from scratch,
  • I follow site rules
  • and code it my way.

if I am making changes to a program, especially if it is a large complex module,
keeping in mind that when i leave, the people here will have to maintain the code,
i use the same coding style as the primary author (if his code is still around).

biggest problem with legacy programs,
there is NO modular programming techniques to be found.
the name of the game is try to figure out the logic,
determine what needs to be changed,
change it in such a way that it looks like the original authors style,
with reference to
  • paragraph naming conventions
  • paragraph PERFORM syntax
  • usage of GO TO
.

it is bad enough to have to follow logic in a legacy program
(alot of times, even new stuff)
without having to suddenly deal with a new coding style
and spend less time on the logic.

i don't advocate perform paragraph thru exit,
i am strickly a perform Section, without an exit
but if the piece of shit is so written, any additions will be in the same style.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Apr 13, 2012 1:00 pm    Post subject: Reply to: Want to put in a loop in EVALUATE
Reply with quote

But dbz, do you do work for "small systems for small companies" or "huge systems for (huge) companies"? It seems that it matters, somehow, at least for certain imaginations. I've been searching for the compiler options which reflect the difference...

I think I found 'em.

Code:
CBL BIGANDIMPORTANT(MAGICHAPPENS)
CBL NOBIGANDIMPORTANT(NOMAGIC)


coboljoost, you maybe feel you've had a rough entry here. We have many people who read what is posted here. If you post advice, you'd best be able to support it, otherwise it just misleads others.

If it is just plain, bland, "opinion", someone said to you one time and you've always done it without thinking about it, just leave it out, please.

'nuf for now.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts save SAY var loop. italo_pm CLIST & REXX 3 Sun Sep 04, 2016 3:06 am
No new posts print out the correct info in LOOP? jackzhang75 CLIST & REXX 7 Wed Dec 23, 2015 10:39 pm
No new posts Using different values for Skeleton d... venksiv CLIST & REXX 8 Thu Sep 03, 2015 5:28 pm
No new posts Issue with Do Loop. santosh_g CLIST & REXX 5 Tue May 12, 2015 9:24 am
No new posts A cursor within a multi-fetch cursor ... Rohit Umarjikar DB2 1 Thu Mar 06, 2014 9:43 am


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