Generate C/C++ Source (GENCSRC)

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

Parameters

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

From object (OBJ)

Specifies the object to map, which must be a *FILE object in the QSYS file system.

Top

To source file (SRCFILE)

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

name
Specify the name of an existing file.

Qualifier 2: Library

*CURLIB
The current library for the job is used to locate the physical file. If no current library entry exists in the library list, QGPL is used.
name
Specify the name of the library where the file is located.
Top

To source member (SRCMBR)

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.

*OBJ
The object name derived from the From object (OBJ) parameter will be used as the member name.
name
Specify the name of the file member to contain the generated C/C++ structures.
Top

To source stream file (SRCSTMF)

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.

path-name
Specify the complete path name of the stream file to contain the generated source code.
Top

Record format (RCDFMT)

Specifies which record formats of the file are to have C/C++ structures generated.

Single values

*ALL
All record formats for the file will have structures generated.

Other values

name
Specify which record formats will have structures generated. A maximum of 20 record formats can be specified.
Top

Select fields (SLTFLD)

Specifies the usage type of fields that will be mapped.

You can specify 6 values for this parameter.

*BOTH
Fields declared as INPUT, OUTPUT, or BOTH in the DDS are included in the typedef structure. Option and response indicators are included in both structures unless the keyword INDARA is specified in the external file description for device files.
*INPUT
Fields declared as either INPUT or BOTH are included in the mapped structures. Response indicators are included in the input structure unless the keyword INDARA is specified in the external file description for device files.
*OUTPUT
Fields declared as either OUTPUT or BOTH are included in the record structures. Option indicators are included in the output structure unless the keyword INDARA is specified in the external file description for device files.
*KEY
Fields declared as keys in the external file description are included. This option is only valid for database files and DDM files.
*INDICATOR
A separate 99-byte structure for indicators is created when the indicator option is specified. This option is only valid for device files.
*LVLCHK
A typedef of an array of struct is generated, named _LVLCHK_T. A pointer to an object of type _LVLCHK_T is also generated and is initialized with the level check information (format name and level identifier).
*NULLFLDS
If there is at least one null-capable field in the record format of the DDS, a null map typedef is generated containing a character field for every field in the format. With this typedef, you can specify which fields are to be null (set value of each null field to '1', otherwise set to '0'). Also, if the *KEY option is used along with the *NULLFLDS option, and there is at least one null-capable key field in the format, an additional typedef is generated containing a character field for every key field in the format.

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

Packed decimal fields (PKDDECFLD)

Specifies the mapping of packed decimal fields.

*DECIMAL
Packed decimal fields are declared as _Decimal data types.
*CHAR
Packed decimal fields are declared as character arrays.
Top

Structures (STRUCTURE)

Specifies whether or not packed structures are generated.

*PACKED
Packed structures are generated.
*NONPACKED
Packed structures are not generated.
Top

1-byte character fields (ONEBYTE)

Specifies whether an array or a single character is generated for one-byte fields.

*ARRAY
A one-element array of char is generated for one-byte characters.
*CHAR
A single-byte character field is generated for one-byte characters.
Top

Union definition name (UNIONDFN)

Specifies the union names generated.

*OBJ
Use the file name derived from the OBJ parameter.
*NONE
No union is generated.
union-name
Generate a union definition with the name union-name_t. Maximum length is 50 characters.
Top

Typedef prefix (TYPEDEFPFX)

Specifies the prefix for the generated structures.

*OBJ
Use the file name derived from the OBJ parameter.
*NONE
Do not use a prefix for the generated structures.
prefix-name
Specify a prefix for the structure name. Maximum length is 50 characters.
Top

Examples

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

Error messages

*ESCAPE Messages

CZM2613
GENCSRC failed to generate include file.
Top