You can include all COBOL statement types in the source member, except LINKAGE SECTION code and additional PROCEDURE DIVISION USING statements. CA 2E places the different divisions and sections in the user source in their appropriate positions within a program.
You must begin the code for each division or section according to the standard COBOL conventions. For example:
+ + + + - A 1 B.. ... 2 ... ... 3 WORKING-STORAGE SECTION. 01 VAR-1 PIC 9999 COMP. 01 VAR-2 PIC 9999 COMP. PROCEDURE DIVISION. MOVE VAR-1 TO VAR-2 PERFORM ROUTINE MOVE VAR-2 TO VAR-1
In the generated code, Relevant Area B code normally follows that code generated by CA 2E from the user source function but do not assume it does. You will find that FILE-SECTION entries, in particular, precede entries generated for other function types. Code is thus considered to be divided by anything found in Area A.
CA 2E treats Area B code between a PROCEDURE DIVISION Area A statement (or the beginning of the member) and the next Area A statement (or the end of the member if sooner) as instance code. If there are repeated calls to an EXCUSRSRC function, CA 2E generates this code on every call to the function, at the point indicated by the action diagram. CA 2E includes all other code in the generated program only once, if it is a section.
CA 2E does not actually incorporate the following Area A statements from user source into the generated code because they are all present in the generated code already. If they are specified in EXCUSRSRC code, they serve only to show where the subsequent Area B statements (that is, all preceding next Area A statements or the end of the member if sooner) should be placed:
+ + + + + - A 1 B.. ...2 ... ...3 IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. I-O CONTROL. DATA DIVISION. FILE-SECTION. WORKING-STORAGE-SECTION.
CA 2E decodes and places Area A statements as follows:
If an EXCUSRSRC function contains code for more than one section, remember that these sections are not consecutive within the host program; they are only required to be syntactically correct within their own section or division. If you use the COBOL syntax checker when editing user source, you may incur errors because the syntax checker assumes that the code present in the source member constitutes a complete COBOL program, and that the sections and divisions encountered are consecutive within the source. Both these assumptions are false for the source of an EXCUSRSRC function.
The COBOL user source must be correct within the context of the source into which it is inserted. If you are generating COBOL 85, it must follow COBOL 85 conventions; if you are generating COBOL 74 it must follow COBOL 74 conventions. Keep these points in mind:
You can include an EXCUSRSRC function written in COBOL 74 within a function generated in COBOL 85, provided the COBOL 74 code does not include any language elements that are invalid in COBOL 85. First copy the COBOL 74 source to the COBOL 85 source file (QLBLSRC) and do one of the following:
You can place parameter fields at any point in the instance code. You cannot split them across a source record boundary. Parameters must be of the form USR-PARM-U-MMMM where U is the parameter usage defined in the function (I, O or B) and MMMM is the mnemonic name (DDS name) of the formal parameter. For example:
+ + + + - A 1 B .. ... 2 ... ... 3 ADD USR-PARM-I-ORVL TO USR-PARM-B- LNVL GIVING USR-PARM-O-TLVL END-ADD
CA 2E checks the usage of parameters within the instance code, the U part of the name, for correspondence with the formal parameter. The letter U is reserved as the initial letter for user-specified field and section names in user-written source. If you use other prefixes, you may find they conflict with CA 2E generated names in certain instances. If you use COBOL indicators, you must ensure that they do not conflict with those used elsewhere in the program.
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |