CICS Scrolling logic with examples

CICS scrolling logic looks very simple in algorithm representation but implementing it practically so many questions arises. This topic is to clear all the queries related to CICS scrolling (page Up / Down) logic with suitable examples.

Let me give few basic points before getting into detailed implementation logic.

  • Decide the number of rows(MAX-SCRN-SIZE) to be displayed on a single screen.
  • First time MAX-SCRN-SIZE rows needs to be displayed and data items that are required for the page up or Page down logic should be stored so as to available for the next execution of the program(i:e It should be available for PF7 or Pf8 transaction execution)
  • For PF8, we need the last key data displayed on the screen and for Pf7, we need the first Key data displayed on the screen. Also we may need one indicator to tell whether the next page exists or not and one variable to tell in Screen number (first screen or 2nd screen or on last screen etc)
  • These data items can be stored either in Commarea or in TSQs.


  • Here I am using COMMAREA to store the data between transactions and VSAM ESDS files as the database.
  • Lets take the example of displaying the Customer latest Bank transactions on the screen.
  • Input for this would be the Customer number
  • Bank transaction data would be stored in a VSAM file.

Declaration →

Declare Commarea fields that are to be preserved for the next execution of the transaction in working storage area like below.

LK-COMM-AREA is used to receive the data in next transaction.

Procedure Division.

In case if the Formatted date & time are needed

IF EIBCALEN=0–> Do nothing, just return the control back to CICS and clear the screen

First time, Nothing will be in DFHCOMMAREA, but in PF7/PF8 case Last Key, First Key and Page Exists indicator would be present as these items would be sent in RETURN command.

Receive the map and check the response. If it is normal proceed further.


  • Start Browse using the input Key
  • Read thru the file until it reaches the MAX-SCRN-SIZE or no more records are present.
  • Save the first record & Last record key in Commarea fields
  • Once all the screen is filled to its MAX size, check whether the next record in the file exists or not and set the COMMAREA Next page indicator accordingly.
  • Send map And issue a RETURN command


  • Get the Communication area into working storage
  • Check the screen number, If it is in the first page itself, Then no scrolling is possible
  • Otherwise move the Stored first key of previous screen to Key field to set the browsing point
  • Start reading the previous records from that point and set the counters accordingly and populate the screen fields.
  • Once all the screen fields are populated, populate the communication area fields.
  • Send Map and issue a return command with COMMAREA option.


  • Get the Communication area into working storage.
  • Check whether Next page exists or not using the indicator variable of COMMAREA
  • If it does not exists send a suitable message to screen along with the current map.
  • If it exists perform the same logic as A000 para and populate the ww-comm-area fields and send MAP and Issue RETURN command with COMMAREA option.


Leave a Reply

Your email address will not be published. Required fields are marked *