IBM Software Group EGL Sequential File Access This
® IBM Software Group EGL Sequential File Access This section describes how to access serial (sequential) files from a program. It assumes you understand EGL projects, the language, tools and build-files. © 2006 IBM Corporation
Sequential File I/O - Using a Program to Write to a Sequential File Let’s say that you want to write a program that reads your relational database, processed rows, and writes out an external file (like a report or some other batch process). Here are the steps: 4 Create a batch program to write to a sequential file § Create a new record of type: serial. Record – which contains a reference to a logical name associated with an external file § Write EGL logic to read and/or write to an external file 4 Modify the project default Build file. Add a new resource association part 4 Add an Association element for the external file § Logical (internal) name § File type § (Physical) file name/file spec 4 Specify for the project default Build file the option to point to the new Resource Association for the external file 4 Debug or Run the batch program § § From the above you can see that much of the work revolves around modifying the project Build Descriptor file. Up to now we’ve barely used it for anything! That is about to change, but first we’ll create a new batch EGL program. Last update: 12/04/2007 2
Sequential File I/O – New Program – 1 of 2 From Project Explorer, create a new standalone EGL program, in the programs folder, named: file. Writer Add two records as shown here (note copy/paste code from the Notes section of the slides) Serial record – to access a sequential file Basic record – just for more practice Press Ctrl/S – and remove any EGL syntax errors Last update: 12/04/2007 3
Sequential File I/O – New Program – 2 of 2 Add the following business logic By copying all of the code from the Notes section of the slide… and replacing all of the code in your new file. Writer program Press Ctrl/S - and remove any errors Press Ctrl/G – to generate Java for the program Notes: end. Of. File is an EGL reserved word that you can think of as an “enumerated condition” – like an “ 88 -level” in COBOL When the actual end-of-file (past last record of the file) condition happens, the end. Of. File condition will be true. Last update: 12/04/2007 4
Add a new Resource Association – 1 of 3 Here are the steps: 1. (From Window menu) Select Show View > Outline 2. (From Project Explorer) Open batch. Buildfile. eglbld 3. (From the Outline view) Right click over batch. Build. eglbld - and select: 4 Add Part. . . From add EGL Build Part select: Resource Associations 4 Click Next > From Resource Associations Part specify: Last update: 12/04/2007 4 Name: res. Association 4 Click Finish 5
Add a new Association to the Resource Association – 2 of 3 Add a new Association: - Click Add Association - (Re)Name the file: cust. File - Select: System: win File Type: seqws - Specify the system. Name c: customer. Data. dat - Select text: YES § Press Ctrl/S Note: if pointing system. Name to a directory, it must already exist Last update: 12/04/2007 6
Add the Resource Association to the Build file – 3 of 3 Select: batch. Build file. eglbld § Uncheck Show only Un specified options and find the resource. Associations option § Using the drop-down select: res. Association § Press Ctrl/S Last update: 12/04/2007 7
Debug the Program From Project Explorer: 4 Open file. Writer. egl and add some break-points 4 Right-click over file. Writer. egl and select: Debug EGL Program 4 Respond OK to all database prompts. Verify your work: • Follow the logic • View the variable values Last update: 12/04/2007 8
Verify the External Data File From Windows Explorer – or My Computer, open: c: customer. Data. dat Last update: 12/04/2007 9
- Slides: 9