Simplifying coding
About this task
You
can use coding techniques to improve your productivity. By using the COPY
statement, the format 2 SORT
statement, COBOL
intrinsic functions, and Language Environment® callable services, you
can avoid repetitive coding and having to code many arithmetic calculations
or other complex tasks.
If your program contains frequently
used code sequences (such as blocks of common data items, input-output
routines, error routines, or even entire COBOL programs), write the
code sequences once and put them in a COBOL copy library. You can
use the COPY
statement to retrieve these code sequences
and have them included in your program at compile time. Using copybooks
in this manner eliminates repetitive coding.
To sort a table, you can use the format 2 SORT
statement
to simplify coding. It provides a much simpler way compared to the
format 1 SORT
statement.
COBOL provides various capabilities for manipulating strings and numbers. These capabilities can help you simplify your coding.
The Language Environment date and time callable services store dates as fullword binary integers and store time stamps as long (64-bit) floating-point values. These formats let you do arithmetic calculations on date and time values simply and efficiently. You do not need to write special subroutines that use services outside the language library to perform such calculations.
Using numeric intrinsic functions
Using math-oriented callable services
Using date callable services
Eliminating repetitive coding
Converting data items (intrinsic functions)
Evaluating data items (intrinsic functions)
Using Language Environment callable services