When a terminal connection to CICS® has been established, the Terminal, Screen and Field objects are used to navigate through the screens presented by the CICS server application, reading and updating screen data as required.
// Get access to the Screen object
Screen screen = terminal.getScreen();
for ( int i=1; i <= screen.fieldCount(); i++ ) {
Field field = screen.field(i); // get field by index
if ( field.textLength() > 0 )
System.out.println( "Field " + i + ": " + field.getText() );
}
// Return PF3 to CICS
screen.setAID( AID.PF3 );
terminal.send();
// Disconnect the terminal from CICS
terminal.disconnect();
for ( int i=1; i <= screen.fieldCount(); i++ ) {
Field field = screen.field(i); // get field by index
// Find unprotected (i.e. input) fields
if ( field.inputProt() == Field.unprotect )
...
// Find fields the same as a specific text string
if ( field.getText().equals( "CICS Sign-on") )
...
// Find red fields
if ( field.foregroundColor() == Field.red )
...
}