Gen Example: Accessing GlobData from Gen Inline Code for Java
search cancel

Gen Example: Accessing GlobData from Gen Inline Code for Java

book

Article ID: 386918

calendar_today

Updated On:

Products

Gen

Issue/Introduction

The Gen runtimes and generated applications make use of a global data area to maintain state information and other data that is essential to the execution of the applications. The Gen developer sometimes wishes to access some of this global data for their own purposes in their External Action Blocks (EABs) or their Inline Code. The purpose of this article is to describe how to access this global data area from Inline Code in Java generated code.

For generated Java applications, this global data area is accessed through a Gen Java runtime class named GlobData. The GlobData class does not contain any actual data, but contains only references to other Gen Java runtime classes. These other classes contain instance variables that are similar to what may have been seen in the ief_globdata (C) and GLOBDATA (COBOL) data structures.

Environment

Gen 8.6 Inline Code for Java

Resolution


Class Structure

The structure of the GlobData class and these other classes is described below.


GlobData class

Class

Getter Method

Description

StateData

getStateData()

State information

ErrorData

getErrorData()

Error information

TraceData

getTraceData()

Trace information

DBMSData

getDBMSData()

DBMS state information



StateData class

Variable

Data Type

Getter Method

Description

command

String

getCommand()

Command

trancode

String

getTranCode()

Trancode

exitState

int

getExitState()

Exitstate number

exitInfoMsg

String

getExitInfoMsg()

Exitstate message text

exitMsgType

char

getExitMsgType()

Exitstate message type

userId

String

getUserId()

User ID

terminalId

String

getTerminalId()

Terminal ID

printerId

String

getPrinterId()

Printer ID

runtimeType

String

getRuntimeType()

Runtime Type

dialect

String

getDialect()

Dialect

messageFile

String

getMessageFile()

Dialect message table

clientUserId

String

getClientUserId()

Client user ID

clientPassword

String

getClientPassword()

Client password

currentABId

String

getCurrentABId()

Action block ID

currentABName

String

getCurrentABName()

Action block name

lastABName

String

getLastABName()

Last action block name

currentEventType

String

getCurrentEventType()

Current event type

lastStatementNumber

String

getLastStatementNumber()

Last statement number

lastSubStatementNumber

String

getLastSubStatementNumber()

Last substatement number

currentDate

int

getCurrentDate()

Current date

currentTime

int

getCurrentTime()

Current time

nextLocation

String

getNextLocation()

Next location

nextTran

String

getNextTran()

Next tran

transactionRetryLimit

int

getTransactionRetryLimit()

Transaction retry limit

transactionRetryCount

int

getTransactionRetryCount()

Transaction retry count



ErrorData class

Variable

Data Type

Getter Method

Description

status

String

getStatus()

Error status

lastStatus

String

getLastStatus()

Last status

serverFailedAction

int

getServerFailedAction()

Server failed action

errorActionName

String

getErrorActionName()

Error action block name

errorMessageNumber

short

getErrorMessageNumber()

Error message number

errorMessage

String

getErrorMessage()

Error message text

errorEncounteredSW

char

getErrorEncounteredSW()

Error encountered switch

viewOverflowSW

char

getViewOverflowSW()

View overflow switch

functionName

String

getFunctionName()

Function name

rollbackRequested

char

getRollbackRequested()

Rollback requested status



TraceData class

Variable

Data Type

Getter Method

Description

isTracing

boolean

getIsTracing()

Tracing flag

traceHost

String

getTraceHost()

Trace host

tracePort

int

getTracePort()

Trace port



DBMSData class

Variable

Data Type

Getter Method

Description

actionId

int

getActionId()

Action block ID

attributeId

int

getAttributeId()

Attribute ID

dbmsManager

IDBMSManager

getDBMSManager()

DBMS manager

transactionManager

ITransactionManager

getTransactionManager()

Transaction manager

processQueue

boolean

getProcessQueue()

Process DAQ flag

v1Present

boolean

getV1Present()

View 1 present flag

v2Present

boolean

getV2Present()

View 2 present flag

cascade1

boolean

getCascade1()

Cascade 1 flag

cascade2

boolean

getCascade2()

Cascade 2 flag

disassociateQueue

Vector<Object>

getDisassociateQueue()

Disassociate queue

saveSQLException

SQLException

getSaveSQLException()

SQL exception

 

Inline Code Examples

One of the first things to do is determine if GlobData is actually populated with the data of interest. The easiest way to do that would be to add an Inline Code statement in the PAD logic at the point where the data needs to be accessed. The Inline Code statement shown below will display the entire contents of GlobData. The output from this Inline Code statement will be written to the Application Server log file at runtime.





Once it is confirmed that GlobData contains the data of interest, the above Inline Code statement can be changed to retrieve only the desired data fields. The Inline Code statement shown below contains examples of retrieving one data field from each of the four runtime classes that are contained within the GlobData class.




Caveats

  • GlobData is a proprietary data structure. While it rarely changes, there is no guarantee that it won’t change in the future. Therefore, the code written to access GlobData today may not always work in the future.

  • It is strongly discouraged to update the contents of GlobData. Any problems that are reported will need to be reproducible without user updates in order for any problem to be researched by Gen Support/Engineering,

  • Not all data fields in GlobData are populated in all cases. For example, some data fields are only populated when an error occurs, when tracing in the Diagram Trace Utility, or when executing RI Triggers. Also, some data fields are only populated depending upon the application type (client, server, etc.). This is why it is recommended above to verify GlobData is actually populated with the data of interest at the point the data needs to be accessed.

Additional Information

While this article is written specifically about accessing GlobData from Inline Code for generated Java code, the Gen developer can also access the global data area using Inline Code for other generated languages.