Module class | QSYS API Reference Guide

Estimated reading time: 19 minutes

Defines the core behavior of classes that were migrated from RPG or CL programs and modules.

Namespace: ASNA.QSys.Runtime.JobSupport Assembly: ASNA.QSys.Runtime.dll

Inheritance: Object

Constructors

Name Description
Module(CommonProgram) Called from constructors in derived classes to initializes the Module class.

Module(CommonProgram)

Called from constructors in derived classes to initializes the Module class.

Module(CommonProgram)

Parameters

Type Parameter name Description
CommonProgram containerProgram The program containing the module.

Properties

Type Name Description
IndicatorArray<Len<_1, _0, _0>> _IN The array of 100 main indicators.
Indicator _INLR The Last Record indicator.
Indicator _INRT The Return indicator.
ActivationGroup ActivationGroup Gets the program’s activation group.
Job CurrentJob Gets the module’s Job.
DocumentLibraryObject DLO Gets the Job’s DLO.
IntegratedFileSystem IFS Gets the Job’s IFS.
QueryResults QueryResults Used to retrieve host variables in EmbeddedSQL
Spooler Spooler Gets the Job’s spooler.
SQL_CommunicationsArea SQLCA Gets the SQL commuication area. It is populated AFTER (embedded) SQL command executes.
Dictionary<String, Object> SqlQueryResults Gets the result dictionary used to retrieve host variables in EmbeddedSQL
DateTime StartupMoment Gets the timestamp when the module was created.

Methods

Signature Description
Dispose(Boolean) Releases the resources used by the current instance of the Module class. This default implementation does nothing.
EndModuleCall() Notifies the program that contains this module that the *ENTRY module call has ended.
ExecOS400Command(String) Executes a command on the IBM i serving as the database server for the Job.
ExecSQL_Query(Int32, DbConnection, String, DBParm[]) Execute an SQL Command producing a QueryResults.
ExecSQL_Query(Int32, String, DBParm[]) Execute an SQL Command, on the default Job’s ado connection, producing a QueryResults.
ExecSQL_Query(Int32, SqlPreparedStatement, DBParm[]) Execute an prepared SQL Command producing a QueryResults.
ExecSQL_Statement(DbConnection, String, DBParm[]) Execute an non-query SQL Command.
ExecSQL_Statement(String, DBParm[]) Execute an non-query SQL Command on the default Job’s ado connection.
ExecSQL_Statement(SqlPreparedStatement, DBParm[]) Execute an non-query prepared SQL Command.
FormatMessage(String, String, String, String&) Produces the strings with the formatted first and second level text for a message. Any placeholders are replaced with values from the message data.
GetLdaField(Int32, Int32) Gets a value stored in the LDA.
[GetModule()](#t-getmodule-t) Gets a module contained in the same program or in one of the service programs.
PopInvocation() Pops one invocation from the invocation stack.
PushInvocation() Pushes the caller procedure in the invocation stack.
ReceiveMessage(Int32, String, MessageType, String, Boolean) Receive messages from the Program Queue. Messages are received in FIFO order.
ReceiveMessage(String, MessageType, String, Boolean) Receive messages from the Program Queue. Messages are received in FIFO order.
ReclaimActivationGroup(String) Reclaim the resources on the Job’s named activation group.
ReclaimResources(Boolean) Reclaim the resources on the Job’s default activation group.
RemoveMessage(String, String) Remove messages from the program queue entry.
RemoveMessage(Int32, String, String) Remove messages from the Program Queue.
RemoveMessage(String) Remove messages from *PRVious program called.
SendExternalMessage(String, String, String, MessageType) Send a message to *EXTernal message queue.
SendExternalMessage(String, MessageType) Send text message to *EXTernal message queue.
SendProgramMessage(String, String, String, String, MessageType) Send message to program message entry queue in the invocation stack.
SendProgramMessage(String, String, String, Int32, String, MessageType) Send message to program message queue in the invocation stack.
SendProgramMessage(String, String, MessageType) Send text message to program message entry queue in the invocation stack.
SendProgramMessage(String, Int32, String, MessageType) Send text message to program message queue in the invocation stack.
SetLdaField(Int32, Int32, String) Stores a value in the LDA.

void Dispose(bool disposing)

Releases the resources used by the current instance of the Module class. This default implementation does nothing.

void Dispose(bool disposing)

Parameters

Type Parameter name Description
Boolean disposing true to release managed and unmanaged resources; false to release only unmanaged resources.

void EndModuleCall()

Notifies the program that contains this module that the *ENTRY module call has ended.

void EndModuleCall()

void ExecOS400Command(string cmdText)

Executes a command on the IBM i serving as the database server for the Job.

void ExecOS400Command(string cmdText)

Parameters

Type Parameter name Description
String cmdText The command to execute on the server.

QueryResults ExecSQL_Query(int expectedResults, DbConnection sqlConnection, string sqlText, DBParm[] parameters)

Execute an SQL Command producing a QueryResults.

QueryResults ExecSQL_Query(int expectedResults, DbConnection sqlConnection, string sqlText, DBParm[] parameters)

Parameters

Type Parameter name Description
Int32 expectedResults The number of expected results.
DbConnection sqlConnection An open connection to the server where the SQL command will execute.
String sqlText The SQL command to execute.
DBParm[] parameters An array of parameters to be used with the command.

Returns

Type Description
QueryResults The results produced by the server.

QueryResults ExecSQL_Query(int expectedResults, string sqlText, DBParm[] parameters)

Execute an SQL Command, on the default Job’s ado connection, producing a QueryResults.

QueryResults ExecSQL_Query(int expectedResults, string sqlText, DBParm[] parameters)

Parameters

Type Parameter name Description
Int32 expectedResults The number of expected results.
String sqlText The SQL command to execute.
DBParm[] parameters An array of parameters to be used with the command.

Returns

Type Description
QueryResults The results produced by the server.

QueryResults ExecSQL_Query(int expectedResults, SqlPreparedStatement preparedStatement, DBParm[] parameters)

Execute an prepared SQL Command producing a QueryResults.

QueryResults ExecSQL_Query(int expectedResults, SqlPreparedStatement preparedStatement, DBParm[] parameters)

Parameters

Type Parameter name Description
Int32 expectedResults The number of expected results.
SqlPreparedStatement preparedStatement The prepared SQL command to execute.
DBParm[] parameters An array of parameters to be used with the command.

Returns

Type Description
QueryResults The results produced by the server.

void ExecSQL_Statement(DbConnection sqlConnection, string sqlText, DBParm[] parameters)

Execute an non-query SQL Command.

void ExecSQL_Statement(DbConnection sqlConnection, string sqlText, DBParm[] parameters)

Parameters

Type Parameter name Description
DbConnection sqlConnection An open connection to the server where the SQL command will execute.
String sqlText The SQL command to execute.
DBParm[] parameters An array of parameters to be used with the command.

void ExecSQL_Statement(string sqlText, DBParm[] parameters)

Execute an non-query SQL Command on the default Job’s ado connection.

void ExecSQL_Statement(string sqlText, DBParm[] parameters)

Parameters

Type Parameter name Description
String sqlText The SQL command to execute.
DBParm[] parameters An array of parameters to be used with the command.

void ExecSQL_Statement(SqlPreparedStatement preparedStatement, DBParm[] parameters)

Execute an non-query prepared SQL Command.

void ExecSQL_Statement(SqlPreparedStatement preparedStatement, DBParm[] parameters)

Parameters

Type Parameter name Description
SqlPreparedStatement preparedStatement The prepared SQL command to execute.
DBParm[] parameters An array of parameters to be used with the command.

string FormatMessage(string MsgFile, string MsgId, string MsgData, String& secondLevelText)

Produces the strings with the formatted first and second level text for a message. Any placeholders are replaced with values from the message data.

string FormatMessage(string MsgFile, string MsgId, string MsgData, String& secondLevelText)

Parameters

Type Parameter name Description
String MsgFile The message file name where the message description is to be found.
String MsgId The message identification.
String MsgData The replacement text, if any, for the message placeholders.
String& secondLevelText The formatted second level text of the message.

Returns

Type Description
String The formatted first level text of the message.

string GetLdaField(int start, int length)

Gets a value stored in the LDA.

string GetLdaField(int start, int length)

Parameters

Type Parameter name Description
Int32 start The one-based index into the location within the LDA where the value is stored.
Int32 length The length in characters of the value to retrieve.

Returns

Type Description
String The requested field value.

T GetModule()

Gets a module contained in the same program or in one of the service programs.

T GetModule<T>()

void PopInvocation()

Pops one invocation from the invocation stack.

void PopInvocation()

void PushInvocation()

Pushes the caller procedure in the invocation stack.

void PushInvocation()

Message ReceiveMessage(int stackPosition, string stackName, MessageType MsgType, string MsgKey, bool Remove)

Receive messages from the Program Queue. Messages are received in FIFO order.

Message ReceiveMessage(int stackPosition, string stackName, MessageType MsgType, string MsgKey, bool Remove)

Parameters

Type Parameter name Description
Int32 stackPosition Relative position from the stackName starting at 0.
String stackName Name of Program or Procedure in the stack.
MessageType MsgType Type of message to receive. Use Any if type is indifferent.
String MsgKey The message to remove. Use null if key is indifferent.
Boolean Remove true to remove the message from the queue.

Returns

Type Description
Message The message specified or null if the message was not found in the queue.

Message ReceiveMessage(string pgmQ, MessageType MsgType, string MsgKey, bool Remove)

Receive messages from the Program Queue. Messages are received in FIFO order.

Message ReceiveMessage(string pgmQ, MessageType MsgType, string MsgKey, bool Remove)

Parameters

Type Parameter name Description
String pgmQ The description of the program queue entry in the invocation stack. Composed of optional relative position (one of: *SAME, *PRV, number) and a procedure name (Use * for current procedure).
MessageType MsgType Type of message to receive. Use Any if type is indifferent.
String MsgKey The message to Remove. Use null if key is indifferent.
Boolean Remove true to Remove the message from the queue.

Returns

Type Description
Message The message specified or null if the message was not found in the queue.

void ReclaimActivationGroup(string groupName)

Reclaim the resources on the Job’s named activation group.

void ReclaimActivationGroup(string groupName)

Parameters

Type Parameter name Description
String groupName Name of the activation group.

void ReclaimResources(bool caller)

Reclaim the resources on the Job’s default activation group.

void ReclaimResources(bool caller)

Parameters

Type Parameter name Description
Boolean caller true to include the resource of the module’s program making this call; otherwise, false.

void RemoveMessage(string pgmQ, string messageKey)

Remove messages from the program queue entry.

void RemoveMessage(string pgmQ, string messageKey)

Parameters

Type Parameter name Description
String pgmQ The description of the program queue entry in the invocation stack. Composed of optional relative position (one of: *SAME, *PRV, number) and a procedure name (Use * for current procedure).
String messageKey The message to remove. It should always be “*ALL”.

void RemoveMessage(int stackPosition, string stackName, string messageKey)

Remove messages from the Program Queue.

void RemoveMessage(int stackPosition, string stackName, string messageKey)

Parameters

Type Parameter name Description
Int32 stackPosition Relative position from the stackName starting at 0.
String stackName Name of Program or Procedure in the stack.
String messageKey The message to remove. It should always be “*ALL”.

void RemoveMessage(string messageKey)

Remove messages from *PRVious program called.

void RemoveMessage(string messageKey)

Parameters

Type Parameter name Description
String messageKey The message to remove. It should always be “*ALL”.

string SendExternalMessage(string MsgId, string MsgFileName, string MsgData, MessageType MsgType)

Send a message to *EXTernal message queue.

string SendExternalMessage(string MsgId, string MsgFileName, string MsgData, MessageType MsgType)

Parameters

Type Parameter name Description
String MsgId The message identification.
String MsgData The replacement text, if any, for the message placeholders.
String MsgFileName The message file name where the message description is to be found.
MessageType MsgType One of the enumeration values that specifies the severity of the message.

Returns

Type Description
String The message key.

string SendExternalMessage(string MsgText, MessageType MsgType)

Send text message to *EXTernal message queue.

string SendExternalMessage(string MsgText, MessageType MsgType)

Parameters

Type Parameter name Description
String MsgText The user provide text of the message.
MessageType MsgType One of the enumeration values that specifies the severity of the message.

Returns

Type Description
String The message key.

string SendProgramMessage(string MsgId, string MsgFileName, string MsgData, string pgmQ, MessageType MsgType)

Send message to program message entry queue in the invocation stack.

string SendProgramMessage(string MsgId, string MsgFileName, string MsgData, string pgmQ, MessageType MsgType)

Parameters

Type Parameter name Description
String MsgId The message identification.
String MsgData The replacement text, if any, for the message placeholders.
String MsgFileName The message file name where the message description is to be found.
String pgmQ The description of the program queue entry in the invocation stack. Composed of optional relative position (one of: *SAME, *PRV, number) and a procedure name (Use * for current procedure).
MessageType MsgType One of the enumeration values that specifies the severity of the message.

Returns

Type Description
String The message key.

string SendProgramMessage(string MsgId, string MsgFileName, string MsgData, int stackPosition, string stackName, MessageType MsgType)

Send message to program message queue in the invocation stack.

string SendProgramMessage(string MsgId, string MsgFileName, string MsgData, int stackPosition, string stackName, MessageType MsgType)

Parameters

Type Parameter name Description
String MsgId The message identification.
String MsgData The replacement text, if any, for the message placeholders.
String MsgFileName The message file name where the message description is to be found.
Int32 stackPosition Relative position from the stackName starting at 0.
String stackName Name of Program or Procedure in the stack.
MessageType MsgType One of the enumeration values that specifies the severity of the message.

Returns

Type Description
String The message key.

string SendProgramMessage(string MsgText, string pgmQ, MessageType MsgType)

Send text message to program message entry queue in the invocation stack.

string SendProgramMessage(string MsgText, string pgmQ, MessageType MsgType)

Parameters

Type Parameter name Description
String MsgText The user provide text of the message.
String pgmQ The description of the program queue entry in the invocation stack. Composed of optional relative position (one of: *SAME, *PRV, number) and a procedure name (Use * for current procedure).
MessageType MsgType One of the enumeration values that specifies the severity of the message.

Returns

Type Description
String The message key.

string SendProgramMessage(string MsgText, int stackPosition, string stackName, MessageType MsgType)

Send text message to program message queue in the invocation stack.

string SendProgramMessage(string MsgText, int stackPosition, string stackName, MessageType MsgType)

Parameters

Type Parameter name Description
String MsgText The user provide text of the message.
Int32 stackPosition Relative position from the stackName starting at 0.
String stackName Name of Program or Procedure in the stack.
MessageType MsgType One of the enumeration values that specifies the severity of the message.

Returns

Type Description
String The message key.

void SetLdaField(int start, int length, string newValue)

Stores a value in the LDA.

void SetLdaField(int start, int length, string newValue)

Parameters

Type Parameter name Description
Int32 start The one-based index into the location within the LDA where newValue will be stored.
Int32 length The length in characters of the value to store.
String newValue The string value to store in the LDA.