IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Page Up Logic in TSQ


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gupta vishal

New User


Joined: 25 Sep 2007
Posts: 15
Location: Gurgaon

PostPosted: Tue Mar 11, 2008 10:19 am
Reply with quote

Hi,
I am facing a problem of doing a page up operation while reading the data from TSQ. The problem is I can read a fix number of rows say x from tsq depending on the screen and I am displaying the x rows at a time. These rows are fetched from TSQ using the next command in readq operation.
I am stuck in page up as the cics does not support 'prev' command in readq. Can any one suggest how can i do page up reading the cicis.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Tue Mar 11, 2008 2:41 pm
Reply with quote

Hi......

You can do like this too.

when you press PF7 then you read the number of specified set of records and display in the map from TSQ and keep the last record in the COMMAREA and as well as the first record, so you can read from last record to first record easily by DECRIMENTING the counter, when the attention key is PF8

Code:
IF PF7 IS FOR SCROLL DOWN.
IF PF8 IS FOR SCROLL UP.

the above depends on your requirement.
Back to top
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Thu Mar 13, 2008 3:05 am
Reply with quote

read tsq by ITEM number
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Thu Mar 13, 2008 9:00 am
Reply with quote

Hi Earl Haigh.

Refering the post, Reading TSQ is not a problem. Please check the question. The question is about scroll up and scroll down logic.
Back to top
View user's profile Send private message
rpuhlman

New User


Joined: 11 Jun 2007
Posts: 80
Location: Columbus, Ohio

PostPosted: Thu Mar 13, 2008 8:02 pm
Reply with quote

There are multiple methods, but here is one that has worked successfully for me. By your description, you are trying to display multiple records on a given screen, and you are writing a single row to the TS Queue for every record you want to display on the screen. You also want to be able to Page Forward and Backward between the screens. Based on these assumptions, this is what my example will be guiding you thru. I am also going to assume that you have studied and understand the basics of TS Queues as well as knowing the basics of COBOL in a CICS command level environment.

The code below is NOT exact code or even all the code, but a general example of a process to load and access your TS Queue. I’m using a VSAM example. A DB2 FETCH or IMS call could easily be substituted.

The key to this simplistic method is to capture and store two values in your commarea. The first is NUMITEMS, which is an option of the WRITEQ TS command, defined as a binary halfword:

Code:
03  CA-NUMITEMS   PIC S9(04) COMP VALUE ZEROS.


The second is ITEM, which you will use as an option of the READQ TS command, defined as a binary halfword:

Code:
03  CA-ITEM       PIC S9(04) COMP VALUE +1.


Let’s say you want to display 10 records on every screen (I will use ‘map’ interchangeably with screen) along with 5 columns for every record. Define a table in working storage that has 10 occurrences:

Code:
01  TSQ-PAGE-TABLE.
    03  TSQ-PAGE-ENTRY OCCURS 10 TIMES.
        05  TSQ-RECORD.
            07  TSQ-REC-ELEMENT-1  PIC  X(05)  VALUE SPACES.
            07  TSQ-REC-ELEMENT-2  PIC  X(10)  VALUE SPACES.
            07  TSQ-REC-ELEMENT-3  PIC  X(05)  VALUE SPACES.
            07  TSQ-REC-ELEMENT-4  PIC  X(08)  VALUE SPACES.


(You will probably want to redefine the output part of your symbolic map as a table that occurs 10 times … easier, consistent processing later in your code).

Now you want to perform logic, as part of your first time in process (or maybe after some key values were entered on the screen for specific data retrieval), that will ‘read input, load the page table, writeq the page table’ until you have reached some ending condition. The important thing here is that when you have completed loading the TS Queue, CA-NUMITEMS will contain a constant value of the total number of items (in this case ‘pages’) in the Queue. (Constant unless you issue more writeqs for some odd reason … and there are those odd reasons)
Read thru your file (generic), until you’ve reached end-of-file or some other condition, and load the TSQ table with up to 10 records. After the 10th record is loaded, write the TS Queue from TSQ-PAGE-TABLE. CA-NUMITEMS is updated with the total number of items (pages) in the TS Queue every time you writeq a “Page” of records.

Once you’ve successfully loaded the queue, you want to load the screen with what is in the queue. So you READQ TS, (CA-ITEM is initially +1 so you will get the first page), move the TSQ-REC-ELEMENT-1 thru 5 (TSQ-SUB) to their respective map elements, set the display attributes, send the map and then return to your transaction.

You now will always know where you are in your paging (PF7 / PF8) process. If PF7 is pressed, you compute the ITEM (page) you want to access from the TS queue, by subtracting 1 from the current ITEM, which is stored in CA-ITEM. If the resulting value is 0*, you know you are already at the first page and can send a message accordingly, otherwise, you use the result value to retrieve the corresponding page (ITEM) from the TS queue, load the map fields, set the attributes, send the map and return to the transaction.

The process is basically the same for PF8, except that you compute the ITEM (page) you want to access by adding 1 to the current ITEM (page) which is stored in CA-ITEM. If the resulting value is greater than the last possible page, i.e. *CA-NUMITEMS, then you are already at the last page and can send a message accordingly, otherwise you use the result value to retrieve the corresponding page (ITEM) from the TS Queue, load the map fields, set the attributes, send the map and return to the transaction.

*Note: If resulting value is 0, reset CA-ITEM back to +1. If resulting value is greater than CA-NUMITEMS, reset CA-ITEM to CA-NUMITEMS.

By capturing these values, not only will you always know where you are in your paging, you can display a “page number of page numbers” on the screen, something like “PAGE: 16 OF 250”. If you open page number for entry, you can go directly to the page. These are “features” that customers/users like to see.

First time loading and retrieving the TS Queue:

Code:
A100-SOME-PARA-NAME.
 
    PERFORM
      UNTIL NO-MORE-RECORDS OR SOME-ERROR

      EXEC CICS READNEXT ….

      IF RESP-CODE = ZEROS
         IF TSQ-SUB > 10
            PERFORM A999-WRITEQ-TS THRU A999-EXIT
         ELSE
            ADD  1                           TO TSQ-SUB
            MOVE record elements TO TSQ-REC-ELEMENT-1 thru 5 (TSQ-SUB)
         END-IF
      ELSE
        IF RESP-CODE = DFHRESP(NOTFND) OR DFHRESP(ENDFILE)
           SET NO-MORE-RECORDS TO TRUE
           IF TSQ-SUB > 0
              PERFORM A999-WRITEQ-TS THRU A999-EXIT
           END-IF
        ELSE
           SET SOME-ERROR TO TRUE
        END-IF
      END-IF
    END-PERFORM.
       
    IF SOME-ERROR
       PERFORM some error routine ….
    END-IF.

    PERFORM Y000-READQ-TS       THRU Y000-EXIT.
    PERFORM Z900-LOAD-MAP       THRU Z900-EXIT.
    PERFORM Z997-SEND-MAP       THRU Z997-EXIT.
    PERFORM Z998-RETURN-TRANSID THRU Z998-EXIT.
       
A100-EXIT.
    EXIT.

A999-WRITEQ-TS.
      
    EXEC CICS WRITEQ TS QUEUE    (name)
                        FROM     (TSQ-PAGE-TABLE)
                        NUMITEMS (CA-NUMITEMS)
                        RESP     (RESP-CODE)
    END-EXEC.

    IF RESP-CODE = ZEROS
       INITIALIZE TSQ-PAGE-TABLE
       MOVE ZEROS    TO TSQ-SUB
    ELSE
       SET SOME-ERROR TO TRUE
    END-IF.

A999-EXIT.
    EXIT.


Paging process – Reached only if EIBAID is DFHPF7 or DFHPF8

Code:
P000-PAGING-PROCESS.

    IF EIBAID = DFHPF7
       COMPUTE CA-ITEM = CA-ITEM – 1
       END-COMPUTE
       IF CA-ITEM = 0
          MOVE +1             TO CA-ITEM
          MOVE first page message to message area on the map
       ELSE
          PERFORM Y000-READQ-TS THRU Y000-EXIT
          PERFORM Z900-LOAD-MAP THRU Z900-EXIT
       END-IF
    ELSE
       COMPUTE CA-ITEM = CA-NUMITEMS + 1
       END-COMPUTE
       IF CA-ITEM > CA-NUMITEMS
          MOVE CA-NUMITEMS    TO CA-ITEM
          MOVE last page message to message area on the map
       ELSE
          PERFORM Y000-READQ-TS THRU Y000-EXIT
          PERFORM Z900-LOAD-MAP THRU Z900-EXIT
       END-IF
    END-IF.

    PERFORM Z997-SEND-MAP       THRU Z997-EXIT.
    PERFORM Z998-RETURN-TRANSID THRU Z998-EXIT.

P000-EXIT.
        EXIT.


Support paragraphs -

Code:
Y000-READQ-TS.

    EXEC CICS READQ TS QUEUE (name)
                       INTO  (TSQ-PAGE-TABLE)
                       ITEM  (CA-ITEM)
                       RESP  (RESP-CODE)
    END-EXEC.

    IF RESP-CODE > ZEROS
       PERFORM some error routine
    END-IF.

Y000-EXIT.
    EXIT.

Z900-LOAD-MAP.

    PEFORM VARYING TSQ-SUB FROM 1 BY 1
     UNTIL TSQ-SUB > 10
      MOVE TSQ-REC-ELEMENT-1 thru 5 (TSQ-SUB) TO
           MAP-REC-ELEMENT-1 thru 5 (TSQ-SUB) – redefined symbolic map
    END-PERFORM.

Z900-EXIT.
    EXIT.

Z997-SEND-MAP.

    Set map field attributes, date & time, page number, etc …

    EXEC CICS SEND MAP ….

Z997-EXIT.
    EXIT.

Z998-RETURN-TRANSID

    EXEC CICS RETURN TRANSID ….

Z998-EXIT.
    EXIT.
Back to top
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Fri Mar 14, 2008 8:09 am
Reply with quote

Hi vasanth..

Looks like Rpuhlman wrote the code to answer the question, it reads tsq
by ITEM number like I suggested.


Regards,
Earl
Back to top
View user's profile Send private message
quanzhong

New User


Joined: 12 Aug 2008
Posts: 46
Location: china

PostPosted: Thu Sep 18, 2008 1:51 pm
Reply with quote

Hi,

Quote:

*Note: If resulting value is 0, reset CA-ITEM back to +1. If resulting value is greater than CA-NUMITEMS, reset CA-ITEM to CA-NUMITEMS.


from your solution, so that loop can be achieved.

when resulting value is 0, reset CA-ITEM back to CA-NUMITEMS. and when value is greater than CA-NUMITEMS, reset CA-ITEM to 1.

My question is that, from users' perspective, are they happy for that ?
Back to top
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Thu Sep 18, 2008 7:09 pm
Reply with quote

Quote:
My question is that, from users' perspective, are they happy for that ?

huh ? why would an end user care how you coded the program?
Back to top
View user's profile Send private message
sajjan jindal
Warnings : 1

New User


Joined: 09 Sep 2007
Posts: 60
Location: india

PostPosted: Sat Jul 25, 2009 8:02 pm
Reply with quote

The best post on Paging\Scrolling Logic.
Thanks everyone.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Sat Aug 16, 2014 2:36 am
Reply with quote

Sorry for opening up this post again. I have a question on the value in CA-ITEM & CA-NUM-ITEM. How are the values in CA-ITEM and CA-NUM-ITEM stored or rather where is that stored to be used in the below portion in above code

Code:
P000-PAGING-PROCESS.

    IF EIBAID = DFHPF7
       COMPUTE CA-ITEM = CA-ITEM – 1
       END-COMPUTE
       IF CA-ITEM = 0
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Aug 16, 2014 12:36 pm
Reply with quote

Read the fifth post.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Sat Aug 16, 2014 8:15 pm
Reply with quote

Thanks..
So I have to store in DFHCOMMAREA and use that in EXEC CICS return statement to retain the value.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
No new posts Abend S0C4 11 (Page Translation Excep... PL/I & Assembler 16
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
Search our Forums:

Back to Top