Generating record structure classes
You can create Smalltalk classes from the data division structure of other languages using a parser. If you use a VA Smalltalk external function part to parse a C include file or COBOL copybook file for record structure definitions, VA Smalltalk stores the information in an internal, temporary object table. As an alternative, you can use the VA Smalltalk Record Class Generator. The Record Class Generator parses the file you specify and permanently creates a class in your hierarchy for each record structure.
Using the parser
Use the Record Class Generator to break a COBOL or C data division structure into Smalltalk classes.
The Record Class Generator can parse applications that satisfy all of the following requirements:
The application must have as a prerequisite the application AbtRecordStructureBaseApp.
The application must have the current user as a group member.
You can use COBOL or C to define the format of the segments that your program will be reading or modifying. Several segments can exist within one COBOL or C definition.
For a C header file, all data types declared with typedef or struct can be used to generate a class. For a COBOL copy library file, the record formats declared by 01-level declarations can be used.
The parser generates classes for each first level of segment definition; that is, each of the highest levels in the structure becomes a class. The parser also generates the getter and setter methods for the class; each lower level definition is split into a getter and a setter method in its class.
Parsing data division structures
To parse C or COBOL structures into Smalltalk classes, do the following:
1. In a Organizer, select Generate > Record wrapper from the Parts menu.
The Record Class Generator window opens:
Record Class Generator window
This window is similar to the Record settings page of the C and COBOL External Function parts.
2. Select the name of the Function language, C or COBOL.
3. Enter the name of the COBOL or C source file declaring the data types or records used by the external function. To list the available files, select Find.... To view the contents of a file, select View.
4. Select the Parameter word size, 16 bit or 32 bit, based on whether your compiler produces 16- or 32-bit code.
Note:
This setting does not apply to the COBOL External Function part.
5. Select the Alignment to specify the byte alignment for the record structure. Set this value to the same value you used when you compiled the DLL. Refer to the appropriate compiler documentation for more information about byte alignment.
Note:
This setting does not apply to the COBOL External Function part.
6. Choose Yes or No for Translate Data?. The default is No. If the file you will be accessing using the parsed structure contains binary data created on OS/390, the data needs to be converted. Select Yes if you want your binary data converted.
Tip icon
You can also manually modify the getter and setter methods generated by the parser to convert between ASCII and EBCDIC for testing on the workstation. Update COBOL or C display field getter and setter methods with methods mvsFromEbcdic and mvsAsEbcdic respectively. When packaging for OS/390, you do not need to remove these methods from your generated classes; they become NOOP methods on OS/390.
When Yes is selected for Translate data?, the fields for Endian and Code page are enabled.
a. Select Big or Little for the Endian value. The default is Big.
b. Enter the Code Page number. The default is 37, which is the code page for OS/390.
7. When you have specified the file you want to use, select Parse. A list of all the record and type definitions found appears in the Records to generate drop-down list. The name of each entry in the list is the name as it appears in the parsed file, converted to a valid Smalltalk class name. All underscores and dashes are removed, and the first character is capitalized if necessary.
8. From the Records to generate group box, use the drop-down list, and then use the list box below it to specify the structures or items within the record that you want to generate. The first record in the drop-down list is selected as the default after the file has been parsed.
Tip icon
You can select a subset of the fields in a record and select Selected fields from the Generate menu if you want only a subset of the fields to be included in the generated class. You can also select fields and select Rename selected fields from the pop-up menu on the fields list to rename fields before generating the record class.
9. Select Generate >All Fields to generate selectors for all of the fields within the record that you specified. Select Generate >Selected Fields to generate selectors for the fields you selected within the record that you specified in the Records to generate list.
You will be prompted to enter a class name for the generated selectors; the default will be the name selected in the Records to generate list.
a. Enter the class name for generated selectors. Select OK. If the parser found constants defined in the parsed file, you will also be prompted to specify a pool dictionary name; the default will be the name of the generated selector concatenated with the word Constants.
b. Enter the name for the pool dictionary or select Cancel to proceed creating a pool dictionary.
If the parsed file contains any constant definitions (level-78 and level-88 items for COBOL; #define items for C), a prompter will appear asking you to specify the name of a pool dictionary for the generated class. You can enter a valid global variable name or select Cancel to proceed with the record generation.
The classes resulting from the parsed structure are subclasses of OsPtr unless data conversion is requested.
When data conversion is requested, the Record Class Generator generates a class, that is a subclass of AbtForeignOSObject. If the class already exists, it will be overwritten in the application in which it was originally created. If it is a new class, it will be created in the application that you were browsing when you invoked the Record Class Generator. The generated class can always be moved to a different application as needed.
To save a representation of your record for later editing, select Archival method from the Generate menu of the Record Class Generator. This adds a class method representing the record to the class you specify. You can use the method to reconstruct the selectors of the record.
Last modified date: 05/14/2020