Mainframe+Jobs+USA
Mainframe+Jobs+USA

These 3 techniques are so helpful for CICS-Mainframe programmers to implement handling cursor position.

  • Using IC:

First, if a map contains a single entry field, you can specify the IC option in the DFHMDF macro for that field.

For maps with more than one entry field, however, the IC technique isn’t flexible enough. So you’ll need to use one of the other two techniques: direct or symbolic cursor positioning.

Example:

CUSTNO DFHMDF POS=(2,26), X
LENGTH=6, X
ATTRB=(NORM,UNPROT,IC), X
COLOR=TURQUOISE, X
INITIAL=’______’

  • Direct Cursor Positioning:

To use direct cursor positioning, you include the CURSOR option on the SEND MAP command with a cursor position. Note that this cursor position is a displacement from the start of the screen, not a row/column address, so you have to calculate the value. Then, you can code the displacement directly in the CURSOR option, or you can move the value to a binary halfword field (PIC S9(4) COMP) that’s specified in the CURSOR option.

Example:

EXEC CICS
SEND MAP(‘MNTMAP1’)
MAPSET(‘MNTSET1’)
FROM(MNTMAP1O)
CURSOR(346)
END-EXEC.

Formula to find displacement:

The CURSOR value specifies a screen position that represents a displacement from the start of the screen. For a 24×80 screen, it must be a number from 0 to 1919, where 0 is row 1/column 1 and 1919 is row 24/column 80. To calculate the displacement for a screen position, use this formula:
(Row-number – 1) x 80 + (Column-number – 1) = Displacement

  • Symbolic Cursor:

Direct cursor positioning has two major drawbacks. First, cursor displacements are awkward to use. Second, and perhaps more important, direct cursor positioning ties your program to specific screen locations. So, if you change your mapset by moving a field from one screen location to another, you have to change your program as well.

Symbolic cursor positioning is much more flexible. With this technique, you move -1 to the corresponding length field in the symbolic map to tell CICS to move the cursor to that field. Then, you issue a SEND MAP command with the CURSOR option, but without a displacement value.

*Interview Question:

Note that if you move -1 to more than one length field, the cursor is positioned at the first field containing -1.

So, when you edit data entry fields, it’s common to move -1 to the length fields of all input fields that are invalid. That way, the cursor will be positioned at the start of the first field that’s in error.

Example:

MOVE –1 TO CUSTNO1L.

EXEC CICS
SEND MAP(‘MNTMAP1’)
MAPSET(‘MNTSET1’)
FROM(MNTMAP1O)
CURSOR
END-EXEC.

Advertisements