RetrieveCommandDefinition()
method
Description
The RetrieveCommandDefinition()
and RetrieveCommandDefinitionXml()
methods query the QCDRCMDD API to retrieve the definition of a CL (*CMD) command on the IBM i, with two possible return formats.
RetrieveCommandDefinitionXml
: returns the command details as an XML source.RetrieveCommandDefinition
: deserializes the XML returned by the QCDRCMDD API into aCommandDefinition
object which represents the complete structure of the command, including its parameters, elements, and additional information.
Both methods allow you to specify whether only the required parameters should be included in the return via the requiredParametersOnly
parameter.
Syntax
// XML only
RetrieveCommandDefinitionXml(string commandName, string commandLibrary = « *LIBL », bool requiredParametersOnly = false)
// Object
RetrieveCommandDefinition(string commandName, string commandLibrary = « *LIBL », bool requiredParametersOnly = false)
Parameters
Name | Type | Description |
---|---|---|
commandName |
string |
Name of the command to query (Max 10 characters). |
CommandLibrary |
string |
Library containing the command (Max 10 characters, default is *LIBL ). |
requiredParametersOnly |
bool |
Specifies whether to retrieve only basic information about the command (CMDD0100 = true ) or the complete set (CMDD0200 = false (default)). |
Return
RetrieveCommandDefinitionXml
: returns a string containing the XML representing the definition of the specified command.RetrieveCommandDefinition
: Returns an object of typeCommandDefinition
which contains detailed information about the various components of the CL command, corresponding to the instructions used to define CL commands:
CommandDefinition
Class
Property | Type | Description |
---|---|---|
CmdDefinition | List<Command> |
List of CL commands defined in the command structure. |
Command
Class (CL command, with its metadata and parameters).
Property | Type | Description |
---|---|---|
CommandName | string |
Name of CL command (CDATA, required). |
LibraryName | string |
Name of the library containing the command (CDATA, required). |
CCSID | string |
Character coding identifier (CDATA, required). |
PromptMessage | string |
Prompt message for the command (CDATA, optional). |
PromptMsgID | string |
Prompt message identifier (CDATA, optional). |
HlpPnlGrp | string |
Help panel group (CDATA, optional). |
HlpPnlGrpLib | string |
Help panel group library (CDATA, optional). |
HlpID | string |
Help identifier (CDATA, optional). |
MaxPos | string |
Maximum control position (CDATA, optional). |
CurLib | string |
Name of the current library (CDATA, optional). |
PrdLib | string |
Name of the product library (CDATA, optional). |
PmtOvrPgm | string |
Substitution programme for the prompt (NMTOKEN, optional). |
PmtOvrLib | string |
Substitution library for the prompt (CDATA, optional). |
MsgF | string |
Message file associated with the command (CDATA, optional). |
MsgFLib | string |
Message file library (CDATA, optional). |
PmtFile | string |
Command prompt file (CDATA, optional). |
PmtFileLib | string |
Prompt file library (CDATA, optional). |
PmtFileMsg | string |
Message for the prompt file (CDATA, optional). |
ExecBatch | string |
Indicates whether the command can be run in batch (YES or NO, required). |
ChgCmdExit | string |
Control change indicator on exit (YES or NO, required). |
RtvCmdExit | string |
Control recovery on exit indicator (YES or NO, required). |
Parameters | List<CommandParameter> |
List of parameters defined for the order. |
Dependencies | List<CommandDependency> |
List of dependencies defined between command parameters. |
CommandParameter
Class (parameter of a command, with its specific details and configurations).
Property | Type | Description |
---|---|---|
Kwd | string |
Parameter keyword (CDATA, required). |
Type | string |
Parameter data type (DEC, INT2, INT4, UINT2, UINT4, CHAR, etc. required). |
Min | string |
Minimum value authorised for the parameter (CDATA, optional). |
Max | string |
Maximum value authorised for the parameter (CDATA, optional). |
PmtCtlPgm | string |
Prompt control programme (NMTOKEN, optional). |
PmtCtlLib | string |
Prompt control library (CDATA, optional). |
PmtCtl | string |
Prompt control (PMTRQS or PMTCTL, optional). |
KeyParm | string |
Indicates whether the parameter is key (YES or NO, default: NO). |
PosNbr | string |
Parameter position number (CDATA, optional). |
Prompt | string |
Prompt message for the parameter (CDATA, optional). |
PromptMsgID | string |
Prompt message identifier (CDATA, optional). |
Len | string |
Parameter length (CDATA, optional). |
Dft | string |
Default value of parameter (CDATA, optional). |
Constant | string |
Constant indicator for defining fixed values (CDATA, optional). |
Rel | string |
Dependency on other parameters (GT, EQ, GE, LT, NE, LE, optional). |
RelVal | string |
Value for the dependency relationship (CDATA, optional). |
RelKwd | string |
Keyword associated with the dependency relationship (CDATA, optional). |
RangeMinKwd | string |
Keyword for defining the minimum range value (CDATA, optional). |
RangeMaxKwd | string |
Keyword for the maximum range value (CDATA, optional). |
RangeMinVal | string |
Minimum value for the range (CDATA, optional). |
RangeMaxVal | string |
Maximum value for the range (CDATA, optional). |
ChoiceMsgID | string |
Identifier of the choice message for this parameter (CDATA, optional). |
ChoicePgm | string |
Choice program for defining value options (NMTOKEN, optional). |
ChoiceLib | string |
Library where the programme of choice is stored (CDATA, optional). |
Rstd | string |
Restriction indicator (YES or NO, optional). |
Full | string |
Indicates whether the parameter is complete (YES or NO, optional). |
AlwUnprt | string |
Indicator to authorise printing of this parameter (YES or NO, optional). |
AlwVar | string |
Indicates whether the parameter is variable (YES or NO, optional). |
Expr | string |
Associated expression to define calculations or rules (YES or NO, optional). |
IsDtaAra | string |
Indicator for specifying whether the parameter is a data zone (YES or NO, optional). |
IsFile | string |
Indicates whether the parameter is a file (IN, OUT, UPD, INOUT, UNSPFD, NO, optional). |
IsPgm | string |
Indicates whether the parameter is a programme (YES or NO, optional). |
Vary | string |
Indicates whether the parameter is variable (INT2, INT4, NO, optional). |
ListDspl | string |
Indicator to display as a list (INT2 or INT4, optional). |
PassAtr | string |
Pass attribute for the parameter (YES or NO, optional). |
Case | string |
Parameter break (MONO or MIXED, optional). |
CCSID | string |
Character encoding identifier for the parameter (JOB or UTF16, optional). |
InlPmtLen | string |
Length of online prompt for user input (possible values: PWD, 1-12, 17, 25, 32, 50, 80, 132, 256, 512, optional). |
RtnVal | string |
Return value for this parameter (YES or NO, optional). |
PassVal | string |
Value passed for this parameter to other processes (DFT or NULL, optional). |
Choice | string |
Possible options for this parameter (CDATA, optional). |
Elements | List<CommandElement> |
List of sub-elements defining components of the parameter. |
Qualifiers | List<CommandQualifier> |
List of qualifiers for this parameter. |
PromptControl | CommandPromptControl |
Prompt control defined for the parameter. |
Values | List<CommandValue> |
List of values that the parameter can take. |
SingleValues | List<CommandSingleValues> |
List of unique values for the parameter. |
SpecialValues | List<CommandSpecialValues> |
List of special values defined for the parameter. |
ChoiceProgramText | List<CommandChoiceProgramText> |
List of texts associated with the parameter selection program. |
ChoiceProgramValues | List<CommandChoiceProgramValue> |
List of choice programme values. |
CommandElement
Class (element of a command parameter, with its specific details and configurations).
Property | Type | Description |
---|---|---|
Type | string |
Type of element (DEC, INT2, INT4, UINT2, UINT4, CHAR, NAME, GENERIC, LGL, HEX, VARNAME, DATE, TIME, X, SNAME, CNAME, PNAME, ELEM, QUAL, ZEROELEM, required). |
Max | string |
Maximum value authorised for this element (CDATA, optional). |
Prompt | string |
Prompt message associated with this element (CDATA, optional). |
PromptMsgID | string |
Prompt message identifier (CDATA, optional). |
Len | string |
Maximum element length (CDATA, optional). |
Min | string |
Minimum value authorised for this element (CDATA, optional). |
Dft | string |
Default value for the element if no other value is provided (CDATA, optional). |
Constant | string |
Constant indicator (CDATA, optional). |
Rel | string |
Dependency on other elements (GT, EQ, GE, LT, NE, LE, optional). |
RelVal | string |
Value for the dependency relationship (CDATA, optional). |
RangeMinVal | string |
Minimum value of the range for this element (CDATA, optional). |
RangeMaxVal | string |
Maximum range value for this element (CDATA, optional). |
DspInput | string |
Indicates whether the input should be displayed (YES, NO, PROMPT, optional). |
ChoiceMsgID | string |
Select message identifier (CDATA, optional). |
ChoicePgm | string |
Choice programme associated with the element (NMTOKEN, optional). |
ChoiceLib | string |
Program library of choice (CDATA, optional). |
Rstd | string |
Restriction indicator (YES or NO, optional). |
Full | string |
Indicates whether the item is complete (YES or NO, optional). |
AlwUnprt | string |
Indicates whether the item can be unprinted (YES or NO, optional). |
AlwVar | string |
Indicates whether the element is variable (YES or NO, optional). |
Expr | string |
Associated expression for calculations or rules for the element (YES or NO, optional). |
IsDtaAra | string |
Indicates whether the element is a data zone (YES or NO, optional). |
IsFile | string |
Indicates whether the item is a file (IN, OUT, UPD, INOUT, UNSPFD, NO, optional). |
IsPgm | string |
Indicates whether the item is a programme (YES or NO, optional). |
Vary | string |
Indicates whether the element is variable (INT2, INT4, NO, optional). |
PassAtr | string |
Passage attribute for this element (YES or NO, optional). |
Case | string |
Case indicator (MONO or MIXED, optional). |
CCSID | string |
Character encoding identifier for the element (JOB or UTF16, optional). |
InlPmtLen | string |
Length of online prompt for the element (possible values: PWD, 1-12, 17, 25, 32, 50, 80, 132, 256, 512, optional). |
Choice | string |
Possible options for this element (CDATA, optional). |
Qualifiers | List<CommandQualifier> |
List of qualifiers for this element, providing additional information. |
Values | List<CommandValue> |
List of possible values that the element can take. |
SingleValues | List<CommandSingleValues> |
List of unique values for this element. |
SpecialValues | List<CommandSpecialValues> |
List of special values defined for this element. |
ChoiceProgramText | List<CommandChoiceProgramText> |
List of texts associated with the choice programme for this element. |
ChoiceProgramValues | List<CommandChoiceProgramValue> |
List of associated choice programme values. |
CommandQualifier
Class (qualifier for a command parameter.)
Property | Type | Description |
---|---|---|
Type | string |
Qualifier type (INT2, INT4, UINT2, UINT4, CHAR, NAME, GENERIC, SNAME, CNAME, required). |
Prompt | string |
Prompt message for qualifier (CDATA, optional). |
PromptMsgID | string |
Prompt message identifier (CDATA, optional). |
Len | string |
Maximum length for qualifier (CDATA, optional). |
Min | string |
Minimum value authorised for this qualifier (CDATA, optional). |
Dft | string |
Default value for the qualifier (CDATA, optional). |
Constant | string |
Constant indicator (CDATA, optional). |
Rel | string |
Dependency on other qualifiers (GT, EQ, GE, LT, NE, LE, optional). |
RelVal | string |
Value of the dependency relationship (CDATA, optional). |
RangeMinVal | string |
Minimum value for the range of this qualifier (CDATA, optional). |
RangeMaxVal | string |
Maximum value for the range of this qualifier (CDATA, optional). |
DspInput | string |
Display indicator for input (YES, NO, PROMPT, optional). |
ChoiceMsgID | string |
Identifier of the choice message for this qualifier (CDATA, optional). |
ChoicePgm | string |
Choice program for defining value options (NMTOKEN, optional). |
ChoiceLib | string |
Library where the programme of choice is stored (CDATA, optional). |
Rstd | string |
Restriction indicator (YES or NO, optional). |
Full | string |
Indicates whether the qualifier is complete (YES or NO, optional). |
AlwUnprt | string |
Indicates whether the qualifier can be unprinted (YES or NO, optional). |
AlwVar | string |
Indicates whether the qualifier is variable (YES or NO, optional). |
Expr | string |
Associated expression for qualifier calculations or rules (YES or NO, optional). |
Vary | string |
Variability indicator for the qualifier (INT2, INT4, NO, optional). |
PassAtr | string |
Pass attribute for the qualifier (YES or NO, optional). |
InlPmtLen | string |
Length of online prompt for qualifier (possible values: PWD, 1-12, 17, 25, 32, 50, 80, 132, 256, 512, optional). |
Choice | string |
Possible options for the qualifier (CDATA, optional). |
Values | List<CommandValue> |
List of possible values for the qualifier. |
SpecialValues | List<CommandSpecialValues> |
List of special values for the qualifier. |
ChoiceProgramText | List<CommandChoiceProgramText> |
List of texts associated with the qualifier selection programme. |
ChoiceProgramValues | List<CommandChoiceProgramValue> |
List of choice programme values associated with the qualifier. |
CommandPromptControl
Class (prompt control for a command parameter.)
Property | Type | Description |
---|---|---|
ControlKeyword | string |
Keyword for prompt control (CDATA, required). |
NumberTrueRelation | string |
Relationship for the number of true conditions (ALL, GT, EQ, GE, LT, NE, LE, required). |
NumberTrue | string |
Number of true conditions required to activate the control (CDATA, optional). |
LogicalRelation | string |
Logical relationship between conditions (AND or OR, optional). |
Conditions | List<CommandPromptControlCondition> |
List of associated prompt control conditions. |
CommandPromptControlCondition
Class (prompt control condition.)
Property | Type | Description |
---|---|---|
Relation | string |
Comparison relationship (GT, EQ, GE, LT, NE, LE, SPCFD, UNSPCFD, optional). |
CompareValue | string |
Comparison value for the condition (CDATA, optional). |
CommandValues
Class (List of values for a command parameter.)
Property | Type | Description |
---|---|---|
Values | List<CommandValue> |
List of values available for a parameter. |
CommandSingleValues
Class (List of unique values for a parameter.)
Property | Type | Description |
---|---|---|
SingleValues | List<CommandValue> |
List of unique values associated with the parameter. |
CommandSpecialValues
Class (list of special values for a parameter.)
Property | Type | Description |
---|---|---|
SpecialValues | List<CommandValue> |
List of special values defined for the parameter. |
CommandChoiceProgramValues
Class (list of choice program values.)
Property | Type | Description |
---|---|---|
ChoiceProgramValues | List<CommandChoiceProgramValue> |
List of values associated with the choice programme. |
CommandValue
Class (value for a command parameter.)
Property | Type | Description |
---|---|---|
Value | string |
Parameter value (CDATA, required). |
MapTo | string |
Mapped value associated with the parameter value (CDATA, optional). |
CommandChoiceProgramText
Class (text associated with the program used to choose a parameter).
Property | Type | Description |
---|---|---|
Text | string |
Text associated with the choice program for the parameter (CDATA, required). |
CommandSpecialValue
Class (special value for a parameter.)
Property | Type | Description |
---|---|---|
Value | string |
Special parameter value (CDATA, required). |
MapTo | string |
Mapped value associated with the special value (CDATA, optional). |
CommandChoiceProgramValue
Class (choice program value)
Property | Type | Description |
---|---|---|
Value | string |
Choice programme value for the parameter (CDATA, required). |
MapTo | string |
Mapped value associated with the programme value of choice (CDATA, optional). |
CommandDependency
Class (dependency between command parameters.)
Property | Type | Description |
---|---|---|
ControlKeywordRelation | string |
Control keyword relationship (GT, EQ, GE, LT, NE, LE, SPCFD, ALWAYS, required). |
ControlKeyword | string |
Control keyword associated with the dependency (CDATA, optional). |
CompareKeyword | string |
Comparison keyword for assessing dependency (CDATA, optional). |
CompareValue | string |
Value used for comparison in dependency (CDATA, optional). |
NumberTrueRelation | string |
Relation for the number of true conditions in the dependency (GT, EQ, GE, LT, NE, LE, ALL, optional). |
NumberTrue | string |
Number of true conditions required to activate the dependency (CDATA, optional). |
MessageID | string |
Identifier of the message associated with the dependency (CDATA, optional). |
DependencyParameters | List<CommandDependencyParameter> |
List of associated dependency parameters. |
CommandDependencyParameter
Class (dependency parameter.)
Property | Type | Description |
---|---|---|
Keyword | string |
Dependency parameter keyword (CDATA, required). |
Relation | string |
Comparison relationship (GT, EQ, GE, LT, NE, LE, SPCFD, required). |
CompareKeyword | string |
Keyword to compare in the dependency relationship (CDATA, optional). |
CompareValue | string |
Value used for comparison in the dependency parameter (CDATA, optional). |
Exceptions
- InvalidOperationException: Thrown in the event of failure to retrieve command definition information or in the event of an XML deserialization error.
Examples of use
Retrieving the XML for the specified CL command
string commandXml = conn.RetrieveCommandDefinitionXml("CRTLIB", "QSYS", false);
Console.WriteLine(commandXml);
Retrieves a commandDefinition object for the specified CL command
CommandDefinition commandDefinition = conn.RetrieveCommandDefinition(‘CRTLIB’, ‘QSYS’, false);
Console.WriteLine($‘Command: {commandDefinition.CmdDefinition.First().CommandName}’);
References
For more information on the QCDRCMDD API, see the official IBM documentation.