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
 

 

Multiple Value declaration in cobol for variable
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Vidya Kajale

New User


Joined: 01 Jun 2010
Posts: 43
Location: India

PostPosted: Tue Jun 14, 2011 11:57 am    Post subject: Multiple Value declaration in cobol for variable
Reply with quote

can we have more then one value assign to a variable at level 01, 05 ,77 tct other than 88.

EX: 01 WS-report-1
05 ws-report-1A PIC X value 'A' , 'B' , 'c'
o5 WS-REPOrt-1B PIC X value 'X' , 'V'



Please suggest me suitable code. And how that variable will take diiferent values to write into the file.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Tue Jun 14, 2011 12:03 pm    Post subject:
Reply with quote

No. Not at the same time, anyway.

What are you trying to do? Will OCCURS do what you want?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jun 14, 2011 12:20 pm    Post subject:
Reply with quote

1. you can not have multiple value clauses for a variable.

2. use multiple level-88's and set them to true when appropriate.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Tue Jun 14, 2011 11:31 pm    Post subject: Re: Multiple Value declaration in cobol for variable
Reply with quote

Vidya Kajale wrote:
can we have more then one value assign to a variable at level 01, 05 ,77 ect other than 88.

EX: 01 WS-report-1
05 ws-report-1A PIC X value 'A' , 'B' , 'c'
05 WS-REPOrt-1B PIC X value 'X' , 'V'
This would mean that a single byte has 2 different values simultaneously.
It is not yet possible.

Note: 88 level assigns a value when used in a SET statement, not when declared.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Wed Jun 15, 2011 12:14 am    Post subject:
Reply with quote

Nice one Marso - not
Quote:
yet
possible.

A very optimistic approach. Awaiting Quantum COBOL.
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: Wed Jun 15, 2011 12:40 am    Post subject: Reply to: Multiple Value declaration in cobol for variable
Reply with quote

Truly a variable.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Jun 15, 2011 4:20 am    Post subject: Reply to: Multiple Value declaration in cobol for variable
Reply with quote

And no, you can't use an 88 with multiple values, SET it, and get multiple values in the field associated with the 88.
Quote:
Yet.


We still have no idea what the TS wanted to do. You could use the "bits" to indicate the presence/absence of up to eight distinct values in one byte, but no application comes to mind which can't be dealt with in a more obvious way.

Or, maybe for ultra-performance, a cool "GO TO DEPENDING ON"? You work out the answer to the IF/EVALUATE before the data arrives in the program. Put it in a half-, or full-word, whichever the compiler is more comfortable with. Only attempt this under supervision by qualified personnel (who may, or may not, have anything to do with IT).
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: Wed Jun 15, 2011 5:07 am    Post subject:
Reply with quote

Hello,

Quote:
can we have more then one value assign to a variable at level 01, 05 ,77
As has been posted, this cannot be done.

If it was possible, how would you use it?

If you explain what you want to accomplish, someone may have a suggestion.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Jun 15, 2011 5:33 am    Post subject:
Reply with quote

Quote:
Or, maybe for ultra-performance, a cool "GO TO DEPENDING ON"? You work out the answer to the IF/EVALUATE before the data arrives in the program. Put it in a half-, or full-word, whichever the compiler is more comfortable with. Only attempt this under supervision by qualified personnel (who may, or may not, have anything to do with IT).
Bill, this is WAY too close to the ALTER statement COBOL used to allow. Great. Now I'll have nightmares the rest of the week from when I had to support a program that used ALTER.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Wed Jun 15, 2011 11:55 am    Post subject:
Reply with quote

Sorry Robert, no evil intent on my part :-)

You mean

Code:

ALTER AN-INNOCENT-PARAGRAPH-NAME TO PROCEED TO DISAPPEAR-UP-ITS-OWN...


That one?

I never knew how ALTER got all the bad press and GO TO DEPENDING ON escaped almost unscathed either.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jun 15, 2011 12:03 pm    Post subject: Reply to: Multiple Value declaration in cobol for variable
Reply with quote

Quote:
Awaiting Quantum COBOL.


With or Without the Heinsenberg parser
icon_question.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Jun 15, 2011 2:56 pm    Post subject:
Reply with quote

ALTER was the Schrodiinger's Cat of COBOL -- you never knew for sure if the GO TO you were looking at was the one that got executed, unless you tracked through the code (opened the box?).
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: Wed Jun 15, 2011 9:11 pm    Post subject: Reply to: Multiple Value declaration in cobol for variable
Reply with quote

Hello,

Minimum flames please . . . icon_wink.gif

ALTER did make for a very handy "fitst-time" switch. . .

The first COBOL-only shop i worked for had it in their standards that the only time ALTER could be used was as a first time thru indicator. Keep in mind that when the rule was changed that all new code would be COBOL, it was the people most experienced in assembler that saw no problem with the ALTER for handling "first time". This was basically how they handled first-time in their assembler code - have a no-op before the first time code and turn it into an unconditional branch around the first time code so there would be no checking - just a cheap branch.

d
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Wed Jun 15, 2011 10:03 pm    Post subject:
Reply with quote

Heisenberg is out for a drive and a cop pulls him over.

"Sir, do you know how fast you were going?" "No," replies Heisenberg, "but I know where I am."
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Wed Jun 15, 2011 10:30 pm    Post subject:
Reply with quote

Once upon a time it was common to use the Cobol statement "ON 1" as a first time switch. Very handy because you didn't have to remember to turn it on or off.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Jun 17, 2011 6:31 pm    Post subject: Re: Reply to: Multiple Value declaration in cobol for variab
Reply with quote

Bill Woodger wrote:
And no, you can't use an 88 with multiple values, SET it, and get multiple values in the field associated with the 88.
Quote:
Yet.


We still have no idea what the TS wanted to do. You could use the "bits" to indicate the presence/absence of up to eight distinct values in one byte, but no application comes to mind which can't be dealt with in a more obvious way.

I would like to point out that you can use a format
Code:
VALUE 1 THROUGH 5
or
Code:
VALUE 'B' THROUGH 'K'

for conditional variables (88 level), so whenever the conditional variable is set to a value that is inside the collating sequence between the 2 end literals, the condition is evaluated true.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jun 17, 2011 6:34 pm    Post subject:
Reply with quote

not to forget, when SETting the CONDITION-CODE TO TRUE
only the first value listed in the VALUE clause is used.

(don't want to confuse anyone...)
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Jun 17, 2011 6:42 pm    Post subject:
Reply with quote

The construct with multiple values should in my opinion only be used for checking external values to match a specific condition. For explicitely setting conditions on and off (true/false), use a single literal as condition value.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Fri Jun 17, 2011 7:03 pm    Post subject: Reply to: Multiple Value declaration in cobol for variable
Reply with quote

I think I introduced the confusion when pre-empting the question of "what about multiple values on an 88 when I do SET, does that get me multiple values in my data-name".

The answer is still no, that doesn't happen. A fuller answer, as dbz points out, is that only the first value that has been typed for the 88 is placed in the data-name when (if) you do a SET for that data-name. Only one value is needed for the condition to be true, plus, as we head back to the start of the topic, only one value can be held in one byte at any one time.

Code:
88 A VALUE 7.
88 B VALUE 7 THRU 9
88 C VALUE 7, 1, 3, 9.
88 D VALUE 7, 1 THRU 4, ZERO, 8.


SET/DISPLAY for each of these would display 7, and the condition would be true. By the time you've SET them all, they'd all be true, the value of the data-name would be 7, but only because of the last SET, the others would only be true by co-incidence.

Of the about, I'm with Kjeld, I'd only really want to use A (and I'd give it a meaningful name, of course). But, if you come across an 88 with multiple values, that is SET, this is what happens.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jun 17, 2011 7:16 pm    Post subject:
Reply with quote

well, since it is friday and we all seem to have time on our hands,

SETting a CONDITION-NAME TO TRUE
is the same as
MOVE <first value of VALUE Clause> TO <owning data description entry>

IF CONDITION-NAME IS TRUE
is the same as
IF <owning data description entry> = <one of the values of the VALUE Clause of the CONDITION-NAME>

what level-88's accomplish is to remove the need for idiots to fill the PROCEDDURE DIVISION with literals.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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