For Programmers: Free Programming Magazines  


Home > Archive > Cobol > March 2004 > Compile error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Compile error
KL

2004-03-26, 10:59 pm

Can someone help? I have coded this and can't figure out why I get an error:

BONUS-PROCESS.
DIVIDE SAL-SLD-P BY SAL-ASKING-P GIVING SAL-PO-ASKING.
MULTIPLY 100 BY SAL-PO-ASKING.
EVALUATE SAL-PO-ASKING
WHEN SAL-PO-ASKING >= 95
MULTIPLY SAL-SLD-P BY .05 GIVING SAL-COMM-PAID
COMPUTE SAL-BONUS = (SAL-SLD-P - (SAL-ASKING-P * .95)) * .4
ADD SAL-BONUS TO SAL-COMM-PAID
WHEN SAL-PO-ASKING >= 94
MULTIPLY SAL-SLD-P BY .045 GIVING SAL-COMM-PAID
WHEN SAL-PO-ASKING >= 93
MULTIPLY SAL-SLD-P BY .04 GIVING SAL-COMM-PAID
WHEN SAL-PO-ASKING >= 92
MULTIPLY SAL-SLD-P BY .035 GIVING SAL-COMM-PAID
WHEN SAL-PO-ASKING >= 91
MULTIPLY SAL-SLD-P BY .03 GIVING SAL-COMM-PAID
WHEN SAL-PO-ASKING >= 90
MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
WHEN OTHER
MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
COMPUTE SAL-PENALTY = (SAL-ASKING-P * .95) - SAL-SLD-P
SUBTRACT SAL-PENALTY FROM SAL-COMM-PAID
END-EVALUATE.

It appears to have a problem with the numeric literals 95-90. The exact
compile error I get is:
E Selection object or THROUGH/THRU invalid; found '95'

and it says the same thing for 94-90. Any ideas?

KL
William M. Klein

2004-03-26, 10:59 pm

You don't tell us compiler - but what you are doing is valid as a Micro Focus
extension - or in the 2002 ISO COBOL Standard - but *not* in a "strictly" '85
Standard compiler. You are using a "partial expression" in your when clause,
i.e. a clause that starts with a relational operator. It is valid to code:

Evaluate A
When B
...
When C thru D

***
but it is NOT valid to code

Evaluate A
When > B
....
When = C

***

You can code
Evaluate True
When A > B
...
When A = C

***

Does this make the problem clear?

--
Bill Klein
wmklein <at> ix.netcom.com
"KL" <klbjornme@aol.comjunkhell> wrote in message
news:20040313233938.02537.00003479@mb-m23.aol.com...
> Can someone help? I have coded this and can't figure out why I get an error:
>
> BONUS-PROCESS.
> DIVIDE SAL-SLD-P BY SAL-ASKING-P GIVING SAL-PO-ASKING.
> MULTIPLY 100 BY SAL-PO-ASKING.
> EVALUATE SAL-PO-ASKING
> WHEN SAL-PO-ASKING >= 95
> MULTIPLY SAL-SLD-P BY .05 GIVING SAL-COMM-PAID
> COMPUTE SAL-BONUS = (SAL-SLD-P - (SAL-ASKING-P * .95)) * .4
> ADD SAL-BONUS TO SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 94
> MULTIPLY SAL-SLD-P BY .045 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 93
> MULTIPLY SAL-SLD-P BY .04 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 92
> MULTIPLY SAL-SLD-P BY .035 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 91
> MULTIPLY SAL-SLD-P BY .03 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 90
> MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
> WHEN OTHER
> MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
> COMPUTE SAL-PENALTY = (SAL-ASKING-P * .95) - SAL-SLD-P
> SUBTRACT SAL-PENALTY FROM SAL-COMM-PAID
> END-EVALUATE.
>
> It appears to have a problem with the numeric literals 95-90. The exact
> compile error I get is:
> E Selection object or THROUGH/THRU invalid; found '95'
>
> and it says the same thing for 94-90. Any ideas?
>
> KL



Donald Tees

2004-03-26, 10:59 pm

KL wrote:
> Can someone help? I have coded this and can't figure out why I get an error:
>
> BONUS-PROCESS.
> DIVIDE SAL-SLD-P BY SAL-ASKING-P GIVING SAL-PO-ASKING.
> MULTIPLY 100 BY SAL-PO-ASKING.
> EVALUATE SAL-PO-ASKING
> WHEN SAL-PO-ASKING >= 95
> MULTIPLY SAL-SLD-P BY .05 GIVING SAL-COMM-PAID
> COMPUTE SAL-BONUS = (SAL-SLD-P - (SAL-ASKING-P * .95)) * .4
> ADD SAL-BONUS TO SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 94
> MULTIPLY SAL-SLD-P BY .045 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 93
> MULTIPLY SAL-SLD-P BY .04 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 92
> MULTIPLY SAL-SLD-P BY .035 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 91
> MULTIPLY SAL-SLD-P BY .03 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 90
> MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
> WHEN OTHER
> MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
> COMPUTE SAL-PENALTY = (SAL-ASKING-P * .95) - SAL-SLD-P
> SUBTRACT SAL-PENALTY FROM SAL-COMM-PAID
> END-EVALUATE.
>
> It appears to have a problem with the numeric literals 95-90. The exact
> compile error I get is:
> E Selection object or THROUGH/THRU invalid; found '95'
>
> and it says the same thing for 94-90. Any ideas?
>
> KL



Your sytax is wrong ...

evaluate sal-po-asking
when >= 95
blah
when >= 94
blah blah
when >= 93
etc etc

Donald




Michael Mattias

2004-03-26, 10:59 pm

"Donald Tees" <donald_tees@nospam.sympatico.ca> wrote in message
news:1MX4c.9$Q16.2532@news20.bellglobal.com...
> KL wrote:
error:[color=darkred]
> Your sytax is wrong ...
>
> evaluate sal-po-asking
> when >= 95
> blah
> when >= 94
> blah blah
> when >= 93



But you could...

Evaluate true
when sal-po-asking >=95

when sal-po-asking >=94 'by the way the greater than is moot here

....

MCM





KL

2004-03-26, 10:59 pm

In article <of_4c.34307$PY.23991@newssvr26.news.prodigy.com>, "Michael Mattias"
<michael.mattias@gte.net> writes:

>"Donald Tees" <donald_tees@nospam.sympatico.ca> wrote in message
>news:1MX4c.9$Q16.2532@news20.bellglobal.com...
>error:
>
>
>But you could...
>
> Evaluate true
> when sal-po-asking >=95
>
> when sal-po-asking >=94 'by the way the greater than is moot here
>
>...
>
>MCM


Why is the greater that moot here? What would happen if I just used = and the
value turned out to be 94.5? Just wondering.

KL
KL

2004-03-26, 10:59 pm

In article <1MX4c.9$Q16.2532@news20.bellglobal.com>, Donald Tees
<donald_tees@nospam.sympatico.ca> writes:

>KL wrote:
>error:
>
>
>Your sytax is wrong ...
>
> evaluate sal-po-asking
> when >= 95
> blah
> when >= 94
> blah blah
> when >= 93
> etc etc
>
>Donald


I tried that and got errors, so I added in that part thinking it was the
problem. Will take out and try again.

KL
KL

2004-03-26, 10:59 pm

Actually, I don't know what compiler I am using. This is for a class and we
use RED for editor, I think we use REALCOB for the compiler, but not sure if
that makes any sense to you all.

KL

In article <X2T4c.19905$%06.915@newsread2.news.pas.earthlink.net>, "William M.
Klein" <wmklein@nospam.netcom.com> writes:

>You don't tell us compiler - but what you are doing is valid as a Micro Focus
>extension - or in the 2002 ISO COBOL Standard - but *not* in a "strictly" '85
>Standard compiler. You are using a "partial expression" in your when clause,
>i.e. a clause that starts with a relational operator. It is valid to code:
>
> Evaluate A
> When B
> ...
> When C thru D
>
>***
>but it is NOT valid to code
>
> Evaluate A
> When > B
> ....
> When = C
>
>***
>
>You can code
> Evaluate True
> When A > B
> ...
> When A = C
>
>***
>
>Does this make the problem clear?
>
>--
>Bill Klein
> wmklein <at> ix.netcom.com
>"KL" <klbjornme@aol.comjunkhell> wrote in message
>news:20040313233938.02537.00003479@mb-m23.aol.com...
>error:
>



JerryMouse

2004-03-26, 10:59 pm

Donald Tees wrote:
>
>
> Your sytax is wrong ...
>
> evaluate sal-po-asking
> when >= 95
> blah
> when >= 94
> blah blah
> when >= 93
> etc etc
>


Nah, can't use ">=" after a "when" if evaluating a data-name

You can, however:

EVALUATE SAL-PO-ASKING
WHEN 95 THRU 10000 *> or some other arbitrarily large number
blah
WHEN 94 THRU 10000
blah2
WHEN 92.5 THRU 10000
blah3
etc.


Richard

2004-03-26, 10:59 pm

Donald Tees <donald_tees@nospam.sympatico.ca> wrote

> Your sytax is wrong ...
>
> evaluate sal-po-asking
> when >= 95
> blah
> when >= 94
> blah blah
> when >= 93
> etc etc


That will depend on the compiler version being used and, possibly, the
compiler switches as it is not 'ANS85 standard but is an extension
found in some compilers.

EVALUATE Sal-po-Asking
WHEN 95 THRU 999
foo
WHEN 94
bar
WHEN 93
foo2
....

There is no need to check for >= 93 as at most only one block will be
executed and WHEN's are evaluated strictly in order given.
KL

2004-03-26, 10:59 pm

In article <ofudnXosF7HrAcnd4p2dnA@giganews.com>, "JerryMouse"
<nospam@bisusa.com> writes:

>Donald Tees wrote:
>
>Nah, can't use ">=" after a "when" if evaluating a data-name
>
>You can, however:
>
>EVALUATE SAL-PO-ASKING
> WHEN 95 THRU 10000 *> or some other arbitrarily large number
> blah
> WHEN 94 THRU 10000
> blah2
> WHEN 92.5 THRU 10000
> blah3
> etc.
>


This worked perfectly. Thanks everyone for the suggestions.

KL
Volker Bandke

2004-03-26, 10:59 pm

On Sun, 14 Mar 2004 11:55:34 -0600, "JerryMouse" <nospam@bisusa.com>
wrote:

>Donald Tees wrote:
>
>Nah, can't use ">=" after a "when" if evaluating a data-name
>
>You can, however:
>
>EVALUATE SAL-PO-ASKING
> WHEN 95 THRU 10000 *> or some other arbitrarily large number
> blah
> WHEN 94 THRU 10000
> blah2
> WHEN 92.5 THRU 10000
> blah3
> etc.
>


Which will not work if sal-po-asking = 20000

Better to code

EVALUATE TRUE
WHEN SAL-PO-ASKING >= 95
PERFROM THIS
WHEN SAL-PO-ASKING >_ 96
PERFORM THAT
etc

WHEN OTHER
PERFORM SOMETHING-ELSE
END-EVALUATE






--
With kind Regards |\ _,,,---,,_
ZZZzz /,`.-'`' -. ;-;;,
Volker Bandke |,4- ) )-,_. ,\ ( `'-'
(BSP GmbH) '---''(_/--' `-'\_)

Doubt is not a pleasant condition, but certainty is absurd. -- Voltaire

(Another Wisdom from my fortune cookie jar)
JerryMouse

2004-03-26, 10:59 pm

Volker Bandke wrote:
> On Sun, 14 Mar 2004 11:55:34 -0600, "JerryMouse" <nospam@bisusa.com>
> wrote:
>
>
> Which will not work if sal-po-asking = 20000


Good catch! I should have said:

EVALUATE SAL-PO-ASKING
WHEN 95 THRU 20001 *> or some other arbitrarily large number
blah
WHEN 94 THRU 20001
blah2
WHEN 92.5 THRU 2001
blah3
etc.


Michael Mattias

2004-03-26, 10:59 pm

"KL" <klbjornme@aol.comjunkhell> wrote in message
news:20040314115159.00545.00004823@mb-m02.aol.com...
> In article <of_4c.34307$PY.23991@newssvr26.news.prodigy.com>, "Michael

Mattias"
> <michael.mattias@gte.net> writes:
>
here[color=darkred]
> Why is the greater that moot here? What would happen if I just used = and

the
> value turned out to be 94.5? Just wondering.


Because I failed to consider the possibility of sal-po-asking being
non-integer. No PICTURE clause was supplied and all your values looked like
integers... so I just assumed they were integers.

MCM






Richard

2004-03-26, 10:59 pm

klbjornme@aol.comjunkhell (KL) wrote

> BONUS-PROCESS.
> DIVIDE SAL-SLD-P BY SAL-ASKING-P GIVING SAL-PO-ASKING.
> MULTIPLY 100 BY SAL-PO-ASKING.
> EVALUATE SAL-PO-ASKING
> WHEN SAL-PO-ASKING >= 95
> MULTIPLY SAL-SLD-P BY .05 GIVING SAL-COMM-PAID
> COMPUTE SAL-BONUS = (SAL-SLD-P - (SAL-ASKING-P * .95)) * .4
> ADD SAL-BONUS TO SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 94
> MULTIPLY SAL-SLD-P BY .045 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 93
> MULTIPLY SAL-SLD-P BY .04 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 92
> MULTIPLY SAL-SLD-P BY .035 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 91
> MULTIPLY SAL-SLD-P BY .03 GIVING SAL-COMM-PAID
> WHEN SAL-PO-ASKING >= 90
> MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
> WHEN OTHER
> MULTIPLY SAL-SLD-P BY .025 GIVING SAL-COMM-PAID
> COMPUTE SAL-PENALTY = (SAL-ASKING-P * .95) - SAL-SLD-P
> SUBTRACT SAL-PENALTY FROM SAL-COMM-PAID
> END-EVALUATE.


Personally, I would suggest that this code be replaced by a table,
preferably one read in from, say, a text file or even an indexed file
at runtime.

Building it from table driven code makes maintenance much easier when
commission rates change, or for other reasons, and would even allow
different rates and percentages for various conditions.
KL

2004-03-26, 10:59 pm

In article <RRh5c.34605$PY.33372@newssvr26.news.prodigy.com>, "Michael Mattias"
<michael.mattias@gte.net> writes:

>"KL" <klbjornme@aol.comjunkhell> wrote in message
>news:20040314115159.00545.00004823@mb-m02.aol.com...
>Mattias"
>here
>the
>
>Because I failed to consider the possibility of sal-po-asking being
>non-integer. No PICTURE clause was supplied and all your values looked like
>integers... so I just assumed they were integers.
>
>MCM


Then I am sorry for not including everything needed to understand the problem.
I would have sent the whole program if I thought it was needed, but was worried
about the space it would have taken up.

KL
KL

2004-03-26, 10:59 pm

In article <RRh5c.34605$PY.33372@newssvr26.news.prodigy.com>, "Michael Mattias"
<michael.mattias@gte.net> writes:

>"KL" <klbjornme@aol.comjunkhell> wrote in message
>news:20040314115159.00545.00004823@mb-m02.aol.com...
>Mattias"
>here
>the
>
>Because I failed to consider the possibility of sal-po-asking being
>non-integer. No PICTURE clause was supplied and all your values looked like
>integers... so I just assumed they were integers.
>
>MCM


Then I am sorry for not including everything needed to understand the problem.
I would have sent the whole program if I thought it was needed, but was worried
about the space it would have taken up.

KL
KL

2004-03-26, 10:59 pm

In article <217e491a.0403151331.31d723fe@posting.google.com>,
riplin@Azonic.co.nz (Richard) writes:

>klbjornme@aol.comjunkhell (KL) wrote
>
>
>Personally, I would suggest that this code be replaced by a table,
>preferably one read in from, say, a text file or even an indexed file
>at runtime.
>
>Building it from table driven code makes maintenance much easier when
>commission rates change, or for other reasons, and would even allow
>different rates and percentages for various conditions.


I am new to COBOL, could you explain this table driven code for me?

KL
Richard

2004-03-26, 10:59 pm

klbjornme@aol.comjunkhell (KL) wrote

>
> I am new to COBOL, could you explain this table driven code for me?


Analyse the calculations and put all the data items into a table:

01 Bonus-Rates.
03 FILLER PIC X(20) VALUE "09500 00500 -0950 +1000
+0400".
03 FILLER PIC X(20) VALUE "09400 00450 +0000 +0000
+0000".
03 FILLER PIC X(20) VALUE "09300 00400 +0000 +0000
+0000".
03 FILLER PIC X(20) VALUE "09200 00350 +0000 +0000
+0000".
03 FILLER PIC X(20) VALUE "09100 00300 +0000 +0000
+0000".
03 FILLER PIC X(20) VALUE "09000 00250 +0000 +0000
+0000".
03 FILLER PIC X(20) VALUE "00000 00250 +0950 -1000
+1000".
01 Bonus-RDF REDEFINES Bonus-Table.
03 Bonus-Item OCCURS 7.
05 Bonus-PO PIC 9V9999.
05 FILLER PIC X.
05 Bonus-Rate PIC 9V9999.
05 FILLER PIC X.
05 Bonus-Asking PIC S9V999 SIGN LEADING SEPARATE.
05 FILLER PIC X.
05 Bonus-Negate PIC S9V999 SIGN LEADING SEPARATE.
05 FILLER PIC X.
05 Bonus-Add PIC S9V999 SIGN LEADING SEPARATE.

01 Sal-PO-Asking PIC S9V9999.


DIVIDE SAL-SLD-P BY SAL-ASKING-P GIVING SAL-PO-ASKING
PERFORM
VARYING I FROM 1 BY 1
UNTIL I = 7
OR Sal-PO-Asking >= Bonus-PO(I)
CONTINUE
END-PERFORM

MULTIPLY SAL-SLD-P BY Bonus-Rate(I)
GIVING SAL-COMM-PAID
COMPUTE SAL-BONUS = ( ( SAL-SLD-P * Bonus-Negate(I) )
+ (SAL-ASKING-P * Bonus-Asking(I))) *
Bonus-Add(I)
ADD SAL-BONUS TO SAL-COMM-PAID
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com