Simplifying coding

You can use coding techniques to improve your productivity. By using the COPY statement, the format 2 SORT statement, COBOL intrinsic functions, Language Environment® callable services, Start of changeCOBOL/Java™ communication features, calls between AMODE 31 (31-bit) and AMODE 64 (64-bit) COBOL programs, and user-defined functions,End of change you can avoid repetitive coding and having to code many arithmetic calculations or other complex tasks. In addition, compiler options including SSRANGE, NUMCHECK, PARMCHECK, and INITCHECK can help detect invalid data issues to ease your migration efforts from COBOL 4 or earlier to COBOL 6 or later.

COPY statement

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. For details, see Eliminating repetitive coding.

Format 2 SORT statement

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. For details, see Using the format 2 SORT statement to sort a table.

Intrinsic functions

COBOL provides various capabilities for manipulating strings and numbers. These capabilities can help you simplify your coding. For details, see Converting data items (intrinsic functions) and Evaluating data items (intrinsic functions).

Language Environment callable services

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. For details, see Using Language Environment callable services.

Start of changeCOBOL/Java interoperability

COBOL programs can interoperate with Java programs without using the object-oriented programming framework. Therefore, you can easily extend your COBOL applications with Java. For details, see Compiling, linking, and running non-OO COBOL applications that interoperate with Java and COBOL/Java interoperability outside of the object-oriented (OO) COBOL framework.

End of change
Start of changeAMODE 31 (31-bit) and AMODE 64 (64-bit) COBOL programs interoperability

You can create AMODE 64 COBOL applications that can interoperate with your existing AMODE 31 COBOL applications. AMODE 64 COBOL applications can access data items greater than the existing AMODE 31 data size limits, without changes to the program logic. For details, see COBOL applications with mixed AMODE 31 and AMODE 64 programs.

End of change
Start of changeUser-defined functions

As with many popular programming languages, COBOL supports user-defined functions, which gives you a familiar structure. Write your own functions using the user-defined function definition and invoke them like intrinsic functions, improving code modularity and maintainability. For details, see Function identification division in the Enterprise COBOL for z/OS® Language Reference and Using user-defined functions.

End of change
Start of changeCompiler options to detect invalid data during COBOL migration

Start of changeOne of the most common problems when migrating to Enterprise COBOL 6 is caused by invalid COBOL data that cannot be detected by inspecting source code. To identify these problems more easily, consider using the 2-step compile process, that is, use the SSRANGE, NUMCHECK, PARMCHECK, INITCHECK, and OPT(0) compiler options for initial code changes and unit tests, and then recompile with NOSSRANGE, NONUMCHECK, NOPARMCHECK, and OPT(2) for quality assurance tests and production. For details, see FAQs about compiling with Enterprise COBOL in the Enterprise COBOL Migration Guide.End of change

For all the COBOL migration-related information, visit the COBOL Migration Portal, which includes case studies, COBOL experts interview videos, the cloud-based COBOL Migration Assistant for a navigation through the migration process, COBOL Migration and Performance Tuning Webinars, FAQs, other IBM® products to support your migration, and many other resources.

End of change