| Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Generate C/C++ Source (GENCSRC) command maps externally-described file information to the equivalent structures that can be included into ILE C or ILE C++ programs. The structures generated from the specified file object are written to either a source file member or a stream file.
| Top |
| Keyword | Description | Choices | Notes |
|---|---|---|---|
| OBJ | From object | Path name | Optional, Positional 1 |
| SRCFILE | To source file | Qualified object name | Optional |
| Qualifier 1: To source file | Name | ||
| Qualifier 2: Library | Name, *CURLIB | ||
| SRCMBR | To source member | Name, *OBJ | Optional |
| SRCSTMF | To source stream file | Path name | Optional |
| RCDFMT | Record format | Single values: *ALL Other values (up to 20 repetitions): Name |
Optional |
| SLTFLD | Select fields | Values (up to 6 repetitions): *BOTH, *OUTPUT, *INPUT, *KEY, *INDICATOR, *LVLCHK, *NULLFLDS | Optional |
| PKDDECFLD | Packed decimal fields | *DECIMAL, *CHAR | Optional |
| STRUCTURE | Structures | *PACKED, *NONPACKED | Optional |
| ONEBYTE | 1-byte character fields | *ARRAY, *CHAR | Optional |
| UNIONDFN | Union definition name | Character value, *OBJ, *NONE | Optional |
| TYPEDEFPFX | Typedef prefix | Character value, *OBJ, *NONE | Optional |
| Top |
Specifies the object to map, which must be a *FILE object in the QSYS file system.
| Top |
Specifies the physical file that will contain the generated structures. The physical file must exist.
Note: Ensure that the record length of the physical file is large enough to avoid truncation of the data.
Qualifier 1: To source file
Qualifier 2: Library
| Top |
Specifies the name of the file member which will contain the mapped structures. If a member by this name does not exist, it will be added automatically. The records in an existing member by this name will be replaced.
| Top |
Specifies the stream file that will contain the generated structures. All directories in the stream file's path must exist. If a file by this name does not exist, it will be created automatically. The data in an existing file by this name will be replaced.
| Top |
Specifies which record formats of the file are to have C/C++ structures generated.
Single values
Other values
| Top |
Specifies the usage type of fields that will be mapped.
You can specify 6 values for this parameter.
For physical and logical files, you can specify *INPUT, *BOTH, *KEY, *LVLCHK, and *NULLFLDS. For device files you can specify *INPUT, *OUTPUT, *BOTH, *INDICATORS, and *LVLCHK.
| Top |
Specifies the mapping of packed decimal fields.
| Top |
Specifies whether or not packed structures are generated.
| Top |
Specifies whether an array or a single character is generated for one-byte fields.
| Top |
Specifies the union names generated.
| Top |
Specifies the prefix for the generated structures.
| Top |
Example 1: Create Mapping of All Record Formats
GENCSRC OBJ('/QSYS.LIB/QTEMP.LIB/MYTBL.FILE')
SRCFILE(QTEMP/H)
This command creates a mapping for all record formats of file object MYTBL in library QTEMP. The mapping is stored in member MYTBL of source file H in library QTEMP.
The generated mapping can be included into a C/C++ program with the following include statement.
#include "QTEMP/H(MYTBL)"
Example 2: Create Mapping for One Record Format
GENCSRC OBJ('/QSYS.LIB/QTEMP.LIB/MYTBL.FILE')
SRCSTMF('/tmp/myHdr.h') RCDFMT(PRSNL)
SLTFLD(*INPUT) PKDDECFLD(*CHAR)
STRUCTURE(*NONPACKED) TYPEDEFPFX(TAB1)
This command creates a mapping for record format PRSNL of file object MYTBL in library QTEMP. Only the input fields in the record format are mapped. The generated structure will not be packed, it will contain char arrays in place of packed decimal data in the record, and the name of the structure will be prefixed with TAB1. The mapping will be stored in the stream file /tmp/myTbl.h.
The generated mapping can be included into a C/C++ program with the following include statement.
#include "/tmp/myTbl.h"
| Top |
| Top |