|
Converter generation |
|
|
Once built the XML describing the structure(s) of the file, the file's conversion program must be generated. This task is achieved by means of "xmlconverter", which analyzes the XML description and generates the corresponding COBOL program for the conversion of the file. By default, the program generated, provides EBCDIC to ASCII conversion. I.e. xmlconverter -o FILE01.cbl FILE01.xml The converter is COBOL program that, for the whole source file:
If a files has been described with multiple structures, the program contains the code to properly convert the different structure. For each structure defined, it contains the statements to convert every field in the structure and, if critical redefines have been found, it also contains all the possible conversion branches for all the critical situation. The program does not contain the logic to recognize which structure to use and which redefine branch to apply: the programmer must take care to code such logic. At generation time it also possible to instruct the xmlconverter to add in the generated code some data checks (i.e. packed field or numeric checks), to get error messages whenever the data being converted is not compatible with the expected data type. OpenCOBOL: if using OpenCOBOL, on any platform, remember to provide the --open-cobol command line option to xmlconverter. Windows: if using Microfocus NetExpress, remember to provide the --net-express command line option to xmlconverter. Data type handling When generating the converter program, xmlconverter automatically chooses the default conversion function for each field in the record. To force different conversion method for specific fields, you may insert in the XML descriptor file the "conversion" attribute on the field descriptions (dataitem) you want to handle. The conversion attribute may assume one of the following values:
I.e. <dataitem name="HOUR-PRICE"
The explanation of different data type is the following: binary Binary fields need a special consideration, depending on the target architecture. The mainframe uses a big endian data representation, therefore we must be aware of the target binary representation. To activate the binary fields conversion, run xmlconverter providing the option -B. Big Endian target Architectures such SPARC, PPC, z/Series and IA64 (with HPUX), use big endian binary representation, thus they represent data exactly as the mainframe does. Therefore, there is no need to convert binary fields for these systems. Little Endian target Architecture such Alpha, i686, x86_64 and IA64 (with Linux and Windows), use little endian binary representation, that means that binary data are represented differently than the mainframe ones. We also have to consider that many COBOL compilers (Microfocus, ACU, OpenCOBOL) may manage binary fields (COMP usage clause) as big endian fields. Therefore, when the target is a little endian system, you may decide to convert or not binary fields, depending on the kind of programs that will use this data once converted:
Furthermore, there is a special consideration for COBOL programs using Oracle: when the program coding does not includes host variables between BEGIN/END DECLARE SECTION, it may be necessary to force the compiler to represent all COMP fields as COMP-5, that means system native. In this case you must convert binary fields. packed Packed fields are not converted. Only numeric test is possible to validate their content. If a field is not numeric it can be initialized to zero. To force this test is necessary to run xmlconverter with -p command-line option. numeric Numeric fields are converted by XCONVZONED if it is signed otherwise it is converted by XCONVCHAR function. It's also possible to add a validation on its content with -n option. If numeric test is required, function ZERO2NOTNUMERIC is called. If a non-numeric field is detected during check, the conversion process is stopped. char Char fields are converted by XCONVCHAR function. Conversion direction By default the generated programs handles EBCDIC to ASCII conversion. To generate a program which converts from ASCII to EBCDIC, force -a parameter on command line when running xmlconverter. |