The numeric data you use in your program will be one of the five types available with VS COBOL II:
The types COMPUTATIONAL and COMPUTATIONAL-4 are synonymous with BINARY. The type COMPUTATIONAL-3 is synonymous with PACKED-DECIMAL.
There are six valid sign representations for external decimal (USAGE DISPLAY without the SIGN IS SEPARATE clause) and internal decimal (USAGE PACKED-DECIMAL) COBOL data. These are:
The VS COBOL II compiler option NUMPROC affects sign processing. When you use NUMPROC(PFD), the compiler assumes that the sign in your program data is one of three 'preferred signs.' The preferred signs in COBOL are:
Based on this assumption, the compiler uses whatever sign it is given to process data, even if the sign is incompatible with the data definition. The preferred sign is generated only where necessary (such as when signed data is moved to-an unsigned or alphanumeric data item). Using the NUMPROC(PFD) option can save a great deal of processing time, but you must be sure you use preferred signs with your data for correct processing.
When the NUMPROC(NOPFD) compiler option is in effect, the compiler accepts any valid sign configuration. When processing is done with DISPLAY or PACKED-DECIMAL data, the sign in the sending item is converted to the preferred sign before the operation is performed. The preferred sign is also generated in the receiver. NUMPROC(NOPFD) is less efficient than NUMPROC(PFD), but it should be used whenever data that does not use preferred signs may exist. In the case where an unsigned, external decimal sender is moved to an alphanumeric receiver, the sign is unchanged (even with NUMPROC(NOPFD)).
When NUMPROC(MIG) is in effect, the compiler generates code that is similar to that produced by OS/VS COBOL. This option can be especially useful as a tool when migrating; OS/VS COBOL programs to VS COBOL II. NUMPROC has no effect on binary data or floating-point data.
Incompatible Data and Numeric Class Test
The compiler assumes that the values you supply for a data item are valid for the item's PICTURE and USAGE clause and assigns the value you specify without checking for validity. When an item is given a value that is not compatible with its data description, then references to that item in the Procedure Division will be undefined and your results will be unpredictable. Frequently, values are passed into your program and assigned to items that have incompatible data descriptions for those values. For example, nonnumeric data may be moved or passed into a field in your program that is defined as a numeric item. Or, perhaps a signed number is passed into a field in your program that is defined as an unsigned number. In either case, these fields contain invalid data. It is your responsibility to ensure that the contents of a data item conform to its PICTURE and USAGE clauses before using the data item in any further processing steps. You can use the numeric class test (IF data-item IS NUMERIC.) to perform this data validation.
The numeric class test checks the contents of a data item against a set of values that are valid for the particular PICTURE and USAGE of the data item. For example, a packed decimal item would be checked for hexadecimal values X'O' through X'9' in the digit positions and for a valid sign in the sign position, as described earlier.
Execution of the numeric class test is affected by the NUMPROC compiler option and the NUMCLS installation option. Only external decimal, external floating-point, and packed decimal items are checked for sign, because binary and internal floating-point items use an 'operational' sign that is always valid.
Data Format Conversions
When the code in your program involves the interaction of numeric data items with different data formats, the compiler converts the items:
The conversion generally requires additional storage and processing time because data is moved to an internal work area and converted before the operation is performed. The results may have to be moved back into a work area and converted again.
A conversion is actually a move of a value from one data item to another. The compiler performs any conversions that are required during the execution of arithmetic and comparisons with the same rules that are used for MOVE and COMPUTE statements. When possible, the compiler performs the move to preserve the numeric value as opposed to a direct digit-for-digit move.
Conversions between fixed-point data formats (external decimal, packed decimal, and binary) are completed without loss of precision. The more significant conversions, where a loss of precision is possible, are those between fixed-point data formats and floating-point data formats (short floating-point, long floating-point, and external floating-point).
Numeric Data Types. Typical Uses and Conversions
For better and efficient data conversion follow the guidelines given below:
Avoid Unnecessary Numeric Conversions
Using the USA&E clause wisely when you define the data can eliminate unnecessary data conversions. The default for a numeric item is DISPLAY. Using DISPLAY items (external decimal or external floating point) for computation is inefficient, because it requires conversion each time the data is used in a calculation. So, when defining numeric items that are used only for internal calculations, define them as BINARY or PACKED-DECIMAL; when defining floating-point items that are used only for internal calculations, define them as COMP-1 or COMP-2.
When you perform several calculations on DISPLAY (external decimal data) items or use two data items of different formats together, efficiency is increased if the data is converted once instead of several times. For example, if A is defined as a DISPLAY item and B as a PACKED-DECIMAL item, move A into a work area that has been defined as PACKED-DECIMAL whenever you will be using both items in a series of operations. When you use this technique, the conversion is performed only once, instead of each time an operation is performed.
Be careful when you are using this technique; if the value of A should change, move the new value into the work area before using it in an operation.
Plan the Size of Numeric Data Items
To avoid size errors, you need to plan the size of your numeric data items, particularly items that will hold the results of numeric calculations. The ON SIZE ERROR option is a safeguard against putting a result into an item that is too small for it. You can use it with these COBOL statements: ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT. This clause does cause extra processing. When you code the ON SIZE ERROR clause, the compiler generates code to check for overflow error during execution of each arithmetic calculation with an associated ON SIZE ERROR clause. To avoid overflow errors:
Align Data for Efficient Execution
Moving numeric items is more efficient when the receiving item has the same type and number of decimal places as the sending item. Processing is most efficient when data items are alike in terms of data type, field length, position of the sign, and decimal position. Also, use of a separate sign can slow processing. Avoid it for data you're using in computations.
De-editing allows you to move a numeric-edited data item into a numeric or numeric-edited receiving data item. This is accomplished by first establishing the unedited value of the numeric-edited data item. This unedited value may be signed. The unedited numeric value is then moved to the receiving numeric data item. Suppose that a character field is being used to contain a numeric value that is displayed on the terminal, and is also being used to contain a value that the computer operator enters on the terminal. Suppose that this field has the following definition:
The data item used to define this field would look like:
01 NUM-EDIT PIC -Z(6).9(2) USAGE IS DISPLAY.
This field could be initialized by the statement MOVE ZEROES TO NUM-EDIT and then displayed on the terminal for the user to see, and it would contain the value 'bbbbbb.OO'. Later the computer operator may use this field to enter data. Suppose that the operator entered 'bbbb123.45 into the field, and you wanted to obtain the numeric value of the field, by moving it into another data item which was defined:
01 NUMERIC-ITEM PIC S9(6)V9(2) USAGE PACKED-DECIMAL.
The statement 'MOVE NUM-EDIT TO NUMERIC-ITEM' causes de-editing to take place, whereby the numeric value of the numeric edited field NUM-EDIT is moved into the numeric item, and the numeric item then contains the value +123.45.
IBM Mainframe Related Interview Questions
|IBM Lotus Notes Interview Questions||IBM-CICS Interview Questions|
|COBOL Interview Questions||Linux Interview Questions|
|IBM-JCL Interview Questions||IBM Mainframe Interview Questions|
|IBM AIX Interview Questions||IBM WAS Administration Interview Questions|
|IBM Lotus Domino Interview Questions||IBM Integration Bus Interview Questions|
|Mainframe DB2 Interview Questions||Unix Production Support Interview Questions|
Ibm Mainframe Tutorial
Introduction To Software Development
Introduction To Ibm Mainframes
Tso And Ispf
Jes2, ]es3 And Sms
Introduction To Job Control Language (jcl)
The Job Statement
The Exec Statement
The Job And Exec Statements
The Dd Statement
Procedures And Symbolic Parameters
Generation Data Groups (gdg), Compile/link-edit And Run Jcls
Access Method Services (ams)
Additional Vsam Commands
Introduction To Rexx
Overview Of Rexx
Introduction To Cics
Exception Handling In Cics
Developing A Cics Application
Cics Programming Techniques
Basic Mapping Support (bms)
Transient Data Control
Temporary Storage Control
Interval And Task Control
Cics Application Design
Recovery And Restart
System Security And Intersystem Communication
Cics Debugging Facilities And Techniques
Bms Map Definition Macros And Copylib Members
Cics Response And Abend Codes
Data, Information And Information Processing
Introduction To Database Management Systems
Introduction To Relational Database Management Systems
Database Architecture And Data Modeling
Overview Of Db2
Structured Query Language (sql)
Data Security And Access
Db2 Application Development
Qmf And Db2i
Db2 Performance Monitoring, Utilities And Recovery/restart
Overview Of Information Management System (ims)
Introduction To Vs Cobol Ii
Overview Of Application Development In Vs Cobol Ii
Overview Of The Cobol Program
Sorting And Merging Files
Coding Cobol Programs That Run Under Cics. Ims, Db2 And Ispf
Compiling The Program
Link-editing The Program
Executing The Program
Improving Program Performance
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.