Gen Example Model: INLINE CODE for File I/O
search cancel

Gen Example Model: INLINE CODE for File I/O

book

Article ID: 265543

calendar_today

Updated On:

Products

Gen Gen - Host Encyclopedia Gen - Run Time Distributed Gen - Workstation Toolset

Issue/Introduction

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)?

Environment

Gen 8.6

COBOL Batch applications

Resolution

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:

  1. Inline Code is stored in the model instead of having to be maintained outside of Gen. This can help prevent problems such as lost EAB source code or having multiple versions of an EAB and not being sure which version is actually being used.
  2. Since Inline Code is actually part of an Internal Action Block, it is built by Gen. So there is no need to maintain separate compile/link JCL, as is necessary for EABs.

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.

Additional Information

For other example models, please see the hub article: Gen 8.6 Example (Model) articles

Attachments

1683565929584__infile.ief.zip get_app