Accessing fields on CICS 3270 screens

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.

The Screen object is created by the Terminal object and is obtained via the getScreen method on the Terminal object. It provides methods for obtaining general information about the 3270 screen, for example, cursor position, and for accessing individual fields by row and column, screen position, or index. The following example prints out field contents, ends the CICS transaction by returning PF3, and disconnects the terminal:
   // 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();
The Field class provides access to the text and attributes of an individual 3270 field. You can use these in a variety of ways to locate and manipulate information on a 3270 screen:
   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 )
           ...
   }

Information Information

Feedback


Timestamp icon Last updated: Tuesday, 19 November 2013


https://ut-ilnx-r4.hursley.ibm.com/tg_latest/help/topic/com.ibm.cics.tg.doc//progde/access.html