Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

6.2.7 COMPUTE Statement



The COMPUTE statement assigns the value of an arithmetic expression to one or more data items.

With the COMPUTE statement, arithmetic operations can be combined without the restrictions on receiving data items imposed by the rules for the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements.

When arithmetic operations are combined, the COMPUTE statement can be more efficient than the separate arithmetic statements written in a series.


    ___ Format _____________________________________________________________ 
   |                                                                        |
   |              <___________________________                              |
   | >>__COMPUTE____identifier-1__ _________ _|__ _=_______ ______________> |
   |                              |_ROUNDED_|    |_ EQUAL _|                |
   |                                                                        |
   | >__arithmetic-expression_____________________________________________> |
   |                                                                        |
   | >__ ____________________________________________ ____________________> |
   |    |_ ____ __SIZE ERROR__imperative-statement-1_|                      |
   |      |_ON_|                                                            |
   |                                                                        |
   | >__ _________________________________________________ _______________> |
   |    |_NOT__ ____ __SIZE ERROR__imperative-statement-2_|                 |
   |           |_ON_|                                                       |
   |                                                                        |
   | >__ _____________ __________________________________________________>< |
   |    |_END-COMPUTE_|                                                     |
   |                                                                        |
   |________________________________________________________________________|
identifier-1
Must name elementary numeric item(s) or elementary numeric-edited item(s).


X Can name an elementary floating-point data item.


X The word EQUAL can be used in place of =.


X If identifier-1 or the result of the arithmetic expression (or both)
X are date fields, see "Storing Arithmetic Results That Involve Date
X Fields" in topic 6.1.5.2.3 for details on how the result is stored in
| identifier-1. If a year-last date field is specified as identifier-1,
| then the result of the arithmetic expression must be a non-date.

arithmetic-expression
Can be any arithmetic expression, as defined in "Arithmetic Expressions" in topic 6.1.5.

When the COMPUTE statement is executed, the value of the arithmetic expression is calculated, and this value is stored as the new value of each data item referenced by identifier-1.

An arithmetic expression consisting of a single identifier, numeric function, or literal allows the user to set the value of the data item(s) referenced by identifier-1 equal to the value of that identifier or literal.


X A year-last date field must not be specified in the arithmetic
X expression.

Subtopics:



Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.