We need to access a new file from some of our Batch Procedure Steps. Can this be written using Inline Code instead of an External Action Block (EAB)?
Gen 8.6
COBOL Batch applications
Yes, file I/O can be performed using Inline Code. In fact, using Inline Code instead of an External Action Block (EAB) has a couple of big advantages:
The attached example model shows one possible way of accessing a file using Inline Code instead of an EAB. All of the file access code is contained in a single Action Block named MYFILE_ACCESS. You can USE this Action Block from your Batch Procedure Steps just like you would have used an EAB.
The BATCH_PSTEP_1 Batch Procedure Step in the attached model contains a simple example of writing some content to a file. The Batch Procedure Step then reads the file content back in and verifies that the same number of records were read as were originally written.
This is a very simple example, but it does show the Batch Procedure Step calling the MYFILE_ACCESS Action Block to perform Open, Write, Close operations on the file and then Open, Read, Close operations on the file.
The MYFILE_ACCESS Action Block contains several Inline Code statements that have a Code Name defined, such as A1000-MAIN, A1100-OPEN-FILE, A1200-CLOSE-FILE, A1300-READ-FILE, A1400-WRITE-FILE, etc. Please note that when an Inline Code statement has a Code Name defined, that code will be generated into its own paragraph, but it will not be executed unless performed by another Inline Code statement that does not have a Code Name defined.
The example model contains only one Inline Code statement without a Code Name defined. This particular Inline Code statement contains a single PERFORM A1000-MAIN THRU A1000-MAIN-EXIT statement. This statement is how all the other Inline Code statements get executed, depending upon the value of the import file_access request code that is passed to the MYFILE_ACCESS Action Block.
For other example models, please see the hub article: Gen 8.6 Example (Model) articles