BROWSE SELECT Prototype

The BROWSE prototype provided a field that could be used to accept a new scrolling value but not the selection of a record for additional detailed processing. This BROWSE SELECT prototype does provide the same scrolling capability of the BROWSE with the added colums of action items (Selection field).

In the example below, a new last name can be typed to retrieve a new set of records for processing or an appropriate action can be typed on a line to select a record for detailed processing.

 07/14/02 12:59PM        * * Employee Inquiry System * *               TESTMAP1 
 MERISTEM                * * *     Name Search     * * *     Page 1 of 3 pages  
                                                                            
        Name                               First Name                  State
        VERMONT_______________________     GORDON                      state
                                                                            
 Sel Stat First Name            City/State                Zip    C R  Account 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 Q 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 R 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 T 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 U 
  _   A   PATRICIA              BOSTON            VT      05352  Y B  2028067 V 
  _   A   PATRICIA              BOSTON            VT      05352  Y B  2028067 W 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 X 
  _   A   GORDON                BOSTON            VT      05035  Y B  2028067 0 
  _   A   GORDON                BOSTON            VT      05035  Y B  2028067 6 
  _   A   PATRICIA              BOSTON            VT      05035  Y B  2028067 7 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 G 
  _   A   PATRICIA              BOSTON            VT      05352  Y B  2028067 H 
  _   A   GORDON                BOSTON            VT      05035  Y B  2028067 L 
  _   A   GORDON                BOSTON            VT      05352  Y B  2028067 M 
                                                                            
  E=Exit, M=Main Menu, C=Change, 1-9=Inquiry, PF7=Back, PF8=Frwd

The Program = TESTCON2

Copy into your library and rename immediately. Most of your changes are highlighted in red.

*
* Program  : TESTCON2
* System   : MERISTEM
* Title    : Browse Select ...
* Generated: Jul 13,02 at 01:10 PM by DDHAMIL
* Function : This program is used to browse the ...
*
*
*
* History
*
DEFINE DATA /* Global Data Area
LOCAL
*
* Constants.

Modify #MAX-PAGES to identify how much scrolling you want the program to support.

Currently the user can scroll all the way to the end of the data but can only back up 20 screens of data with the PF7 key.

01 #MAX-PAGES(P3) CONST<20>        /* Maximum scroll pages.
01 #MAX-PANELS(P3) CONST<1>        /* Max left/right panel.

This version of the program provides 14 lines of selection. Changing these values is permitted but you'll have to do a little work with the INPUT NO ERASE used to prompt for actions.

01 #SEL-TBL-SIZE(P3) CONST<14>
01 #TOTAL-ACTION-LINES(P3)CONST<14>/* Max sel lines
01 #UNCONDITIONALLY(L) CONST<TRUE> /* Used to REJECT always.
*
* Miscellaneous local variables.
01 #ACTION(A1)
01 #BKWRD-TABLE-DECREMENT(P1)      /* Bkwrd scroll table decrement.
01 #END-OF-DATA(L)                 /* End of logical read.
01 #END-OF-PAGE-LINE(P5)           /* Line number where EOP starts.
*

Change these format and length settings to match your primary key.

* Save first key and ISN found in case scroll back record was deleted.

01 #FIRST
  02 #KY(A30)                      /* 1st KEY when looking for match.
  02 #ISN(P10)                     /* 1st ISN when looking for match.
01 #FIRST-ACTION-LINE(P3) INIT<8>
  /* Line where action column starts
01 #FIRST-INPUT(L) INIT<TRUE>      /* Trigger End of Page.
01 #FIRST-ISN-FOUND(L)             /* Found the first ISN
01 #FORWARD(L) INIT<TRUE>          /* Not backwards left or right.
01 #IN-BATCH(L)                    /* Batch mode.
*

Change this setting to your primary key.

* Define input fields.
01 #INPUT
  02 CUSTOMER-LAST-NAME(A30)       /* Input key value.
01 REDEFINE #INPUT
  02 #FIRST-CHAR-ON-SCREEN(A1)     /* Allow '.' to terminate.
01 #INSIDE-READ-LOOP(L)            /* Executing statement inside read.
*
 BROWSE SELECT Prototype

Change these format and length settings to match your primary key.

* Value of the scroll key on current record
01 #KEY(A30)                       /* Key of record.
01 #KEY-CV(C) INIT<(AD=I)>         /* Determine if key was modified.
01 #NEXT-LINE(P3)                  /* Next screen line to be written.
01 #NULL-KEY(A30)                  /* Null key of record.
01 #NULL-ISN(P10)                  /* Null ISN of record.
01 #NULL-ACTION(A1)
01 #MATCH-FOUND(L)                 /* Matched Unique Id from table.
01 #REDISPLAY-SCREEN(L)            /* If true, don't scroll forward.
01 #SCR-CV(C) INIT<(AD=I)>         /* Determine if any field modified.
01 #SEL-INDX(P5)                   /* Select table index.

Change these format and length settings to match your primary key.

01 #SEL-TBL(1:#TOTAL-ACTION-LINES) /* Selection table.
  02 #KY(A30)
  02 #ISN(P10)
  02 #ACTIONS(A1)                  /* Function code column.
  02 #ACTION-CV(C) INIT<(AD=NP)>   /* Control var. for func. code col

Change #SELECTS to identify the number and value of each valid action

01 #SELECTS(A1/13)
  INIT (V) <'E','U','M','C','1','2','3','4','5','6','7','8','9'>

Change these format and length settings to match your primary key.

01 #SELECTED-KEY(A30)              /* Key of selected record.
01 #SELECTED-ISN(P10)              /* ISN of selected record.
*
* Key value for starting position of read.
01 #START
  02 #KY(A30)
  02 #ISN(P10)
*
* Tables for backward/sideways scrolling feature
01 #SCROLL-INDX(P3)                /* Index of Scroll Table.
01 #SCROLL-TBL(1:#MAX-PAGES)
  02 #KY(A30)                      /* Store top key/page.
  02 #ISN(P10)                     /* Store top ISN on each page.
01 #STD-KEY-PRESSED(L)             /* Return, Quit, Flip, Main.
01 #TOP-LINE(P3)
01 #TOP-OF-PAGE(L)                 /* Top of Page was triggered.
01 #TOTAL-PAGES(P3)
01 #LAST-PAGE(P3)

Views and user-defined variables specific to the application.

*
* Views.
*
* Primary view being scrolled.
01 TEST-RECORD VIEW OF CUSTOMER-MASTER
  02 CUSTOMER-LAST-NAME
  02 CUSTOMER-FIRST-MIDDLE
  02 CITY-STATE
  02 ZIP-CODE
  02 COMPANY
  02 REGION
  02 POLICY-NUMBER
  02 CHECK-DIGIT
  02 STATUS-CODE
  02 AGENT
01 #USERID(A8)
END-DEFINE
FORMAT KD=OFF LS=132 PS=21 SG=OFF ES=OFF ZP=OFF IP=OFF
SET KEY ALL

Application dependent setup processing.

SET KEY PF3='%%'
*
* The following code is where the passed values for starting the
* read are stored
*
MOVE 'VERMONT' TO #INPUT.CUSTOMER-LAST-NAME
** INPUT #INPUT.CUSTOMER-LAST-NAME

You'll need to make the appropriate adjustments to the line above. If the primary key value is being passed from an external source, you'll need to identify that variable here and use it throughout the program. If it comes from the application GDA you'll follow the same procedure to install the variable throughout the program.

SET CONTROL 'Q'
PROG. REPEAT
  RESET #FIRST-ISN-FOUND #REDISPLAY-SCREEN #MATCH-FOUND
  IF #SCROLL-INDX LT 1 THEN
    ASSIGN #FORWARD = TRUE
  END-IF

Set to the name of your primary key.

  IF #FORWARD THEN
    ASSIGN #START.#KY = #INPUT.CUSTOMER-LAST-NAME
    ASSIGN #MATCH-FOUND = TRUE
  ELSE
    ASSIGN #START.#KY = #SCROLL-TBL.#KY(#SCROLL-INDX)
    ASSIGN #START.#ISN = #SCROLL-TBL.#ISN(#SCROLL-INDX)
  END-IF
  NEW-READ. REPEAT
    IF #FIRST-INPUT THEN
      RESET #FIRST-INPUT
      WRITE ' '
      NEWPAGE
    END-IF
*
    RESET #END-OF-DATA
    PERFORM PAGINATION-SETUP

Tune this READ to your view and primary key.

*
    READ-FILE. READ TEST-RECORD BY CUSTOMER-LAST-NAME
        STARTING FROM #START.#KY THRU #START.#KY
      ASSIGN #INSIDE-READ-LOOP = TRUE
      ASSIGN #KEY = TEST-RECORD.CUSTOMER-LAST-NAME
      DECIDE FOR FIRST CONDITION
        WHEN #FORWARD IGNORE
        WHEN #MATCH-FOUND IGNORE
        WHEN *ISN(READ-FILE.) = #START.#ISN
          ASSIGN #MATCH-FOUND = TRUE
        WHEN NONE
          IF NOT #FIRST-ISN-FOUND THEN
            ASSIGN #FIRST.#ISN = *ISN(READ-FILE.)
            ASSIGN #FIRST.#KY = #KEY
            ASSIGN #FIRST-ISN-FOUND = TRUE
          END-IF
          IF #KEY > #START.#KY THEN
            ASSIGN #SCROLL-TBL.#KY(#SCROLL-INDX) = #FIRST.#KY
            ASSIGN #SCROLL-TBL.#ISN(#SCROLL-INDX) = #FIRST.#ISN
            PERFORM EXIT-READ-LOOP
          ELSE
            REJECT #UNCONDITIONALLY
          END-IF
      END-DECIDE
*

This is your detail output line. You may only start in the 6th print position which means you only have 73 positions on the line to work with. Good luck.

      WRITE NOTITLE NOHDR
        6T STATUS-CODE 10T CUSTOMER-FIRST-MIDDLE
        32T CITY-STATE 58T ZIP-CODE (AD=Z) 2X
        COMPANY REGION 2X AGENT  CHECK-DIGIT
      PERFORM UPDATE-SELECTION-TABLE
    END-READ
*
    AT TOP OF PAGE
      ASSIGN #TOP-OF-PAGE = TRUE
      ASSIGN #BKWRD-TABLE-DECREMENT = 1
      RESET INITIAL #SEL-TBL(*)         /* Clear select table.
      IF #FORWARD AND #INSIDE-READ-LOOP THEN
        ADD 1 TO #SCROLL-INDX
        IF #SCROLL-INDX GT #MAX-PAGES  THEN
          ASSIGN #SCROLL-INDX = #MAX-PAGES
          MOVE BY NAME #SCROLL-TBL(2:#MAX-PAGES)
            TO #SCROLL-TBL(1:#MAX-PAGES - 1)
        END-IF
        ASSIGN #SCROLL-TBL.#KY(#SCROLL-INDX) = #KEY
        ASSIGN #SCROLL-TBL.#ISN(#SCROLL-INDX) = *ISN(READ-FILE.)
      END-IF
      ASSIGN #TOP-LINE = #FIRST-ACTION-LINE

This statement comprises the screen headers and subheaders and just about anything you want to appear at the top of your screen. I've tried to follow CGU convention here but you can make adjustments as you see fit. I used a print statement to aid in making the display of "Page n or n pages" easier to work with. There are seven lines at the top you can work with.

      PRINT *DATX *TIMX(EM=ZH:IIAP)
        25T '* * Employee Inquiry System * *' 71T 'TESTMAP1'
        / #USERID 25T '* * *     Name Search     * * *'
        61T 'Page' #SCROLL-INDX (AD=L) 'of' #TOTAL-PAGES (AD=L)'pages'
        // 43T 'First Name' 71T 'State'
        /  43T CUSTOMER-FIRST-MIDDLE 71T 'state'
        // 'Sel Stat First Name' 32T 'City/State'
        58T 'Zip    C R  Account'
    END-TOPPAGE
    AT END OF PAGE
      PERFORM UPDATE-SELECTION-TABLE
        PROTECT.
      FOR #SEL-INDX = 1 TO #TOTAL-ACTION-LINES
        IF #SEL-TBL.#ISN(#SEL-INDX) = #NULL-ISN THEN
          MOVE (AD=NP) TO #SEL-TBL.#ACTION-CV(#SEL-INDX)
        ELSE
          MOVE (AD=I) TO #SEL-TBL.#ACTION-CV(#SEL-INDX)
        END-IF
      END-FOR  /* PROTECT.
      ASSIGN #NEXT-LINE = 1 

You can make some small changes to the INPUT statement but only a few. Here I changed the prompt for the primary key that can be used to retrieve a new group of data for display and scrolling. You'll want to alter the last line to reflect your user's selectable actions.

      IF #END-OF-DATA OR NOT #IN-BATCH THEN
        INPUT NO ERASE (AD=TIML'_' CV=#SCR-CV PS=24)
          4/8 'Name'
          5/8 #INPUT.CUSTOMER-LAST-NAME(CV=#KEY-CV)
          8/2 #SEL-TBL.#ACTIONS(01) (CV=#ACTION-CV(01))
          9/2 #SEL-TBL.#ACTIONS(02) (CV=#ACTION-CV(02))
          10/2  #SEL-TBL.#ACTIONS(03) (CV=#ACTION-CV(03))
          11/2  #SEL-TBL.#ACTIONS(04) (CV=#ACTION-CV(04))
          12/2  #SEL-TBL.#ACTIONS(05) (CV=#ACTION-CV(05))
          13/2  #SEL-TBL.#ACTIONS(06) (CV=#ACTION-CV(06))
          14/2  #SEL-TBL.#ACTIONS(07) (CV=#ACTION-CV(07))
          15/2  #SEL-TBL.#ACTIONS(08) (CV=#ACTION-CV(08))
          16/2  #SEL-TBL.#ACTIONS(09) (CV=#ACTION-CV(09))
          17/2  #SEL-TBL.#ACTIONS(10) (CV=#ACTION-CV(10))
          18/2  #SEL-TBL.#ACTIONS(11) (CV=#ACTION-CV(11))
          19/2  #SEL-TBL.#ACTIONS(12) (CV=#ACTION-CV(12))
          20/2  #SEL-TBL.#ACTIONS(13) (CV=#ACTION-CV(13))
          21/2  #SEL-TBL.#ACTIONS(14) (CV=#ACTION-CV(14))
          23/2 'E=Exit, M=Main Menu, C=Change, 1-9=Inquiry,'
          'PF7=Back, PF8=Frwd'
        PERFORM VALIDATE-ACTION-CODES
*
        IF #STD-KEY-PRESSED THEN
          ASSIGN #FORWARD = FALSE
          PERFORM EXIT-READ-LOOP
        END-IF
        /* Batch handling
        IF *DEVICE = 'BATCH' THEN
          ASSIGN #IN-BATCH = TRUE
          SET CONTROL 'H'
          ASSIGN #FORWARD = TRUE
          PERFORM EXIT-READ-LOOP
        END-IF
        DECIDE ON FIRST *PF-KEY
          VALUE 'PF7'
            IF #SCROLL-INDX LE #BKWRD-TABLE-DECREMENT THEN
              REINPUT 'Top of scroll session ' ALARM
            END-IF
            SUBTRACT #BKWRD-TABLE-DECREMENT FROM #SCROLL-INDX
          ANY
            ASSIGN #FORWARD = FALSE
            PERFORM EXIT-READ-LOOP
          NONE
            IF NOT(*PF-KEY = 'ENTR' OR = 'PF8') THEN
              REINPUT 'Invalid program function key ' ALARM
            END-IF
            ASSIGN #FORWARD = TRUE
        END-DECIDE
        DECIDE FOR FIRST CONDITION
          WHEN #KEY-CV MODIFIED
            RESET #SCROLL-INDX
            ASSIGN #FORWARD = TRUE
          WHEN #SCR-CV MODIFIED OR #REDISPLAY-SCREEN
            ASSIGN #FORWARD = FALSE
          WHEN ANY
            PERFORM EXIT-READ-LOOP
          WHEN NONE
            IF #END-OF-DATA THEN
              REINPUT 'End of data reached, enter new start value '
            END-IF
        END-DECIDE
      END-IF
    END-ENDPAGE /* AT END OF PAGE
    ASSIGN #INSIDE-READ-LOOP = FALSE
    ASSIGN #END-OF-DATA = TRUE
    RESET #TOP-OF-PAGE
    IF *COUNTER(1450) = 0
      WRITE 20T '***** No Matching Records *****' (I)
    ELSE
      WRITE 27T '***** End of Data *****'
    END-IF
    IF #TOP-OF-PAGE = TRUE THEN
      ASSIGN #BKWRD-TABLE-DECREMENT = 0
    END-IF
    NEWPAGE

This subroutine is used to set the number of pages displayed at the top of each screen. You need only insert the view and primary key.

*
    DEFINE SUBROUTINE PAGINATION-SETUP
    FIND NUMBER TEST-RECORD WITH CUSTOMER-LAST-NAME
      = #START.#KY THRU #START.#KY
    DIVIDE 14 INTO *NUMBER(3060)
      GIVING #TOTAL-PAGES REMAINDER #LAST-PAGE
    IF #LAST-PAGE GT 0
      ADD 1 TO #TOTAL-PAGES
    END-IF
    END-SUBROUTINE
*
    DEFINE SUBROUTINE EXIT-READ-LOOP
*
    ESCAPE BOTTOM(NEW-READ.) IMMEDIATE
    END-SUBROUTINE /* EXIT-READ-LOOP
*
  END-REPEAT /* NEW-READ.
*
  PERFORM PROCESS-SELECTION-COLUMN
  IF #STD-KEY-PRESSED THEN
    RESET #STD-KEY-PRESSED
  END-IF
*
  DEFINE SUBROUTINE PROCESS-SELECTED-RECORD
*
* This subroutine determines the action taken when the user has typed
* a valid action code on screen. Lots of changes here but don't change:
* #ACTION - the action that was typed by the user
* #SELECTED-KEY - primary browse key value
* #SELECTED-ISN - ISN of the ADABAS record on the line where the user
*                 typed a value into #ACTION
*

You'll be changing all this code for each given application. When a valid action is typed by the user, this program provides the key value, the action selected and the ISN of the record on the line where the action was entered &endash; you take it from there.

GET-RECORD. GET TEST-RECORD #SELECTED-ISN
  DECIDE ON FIRST VALUE OF #ACTION
    VALUE 'M' FETCH 'P44MM00P'
    VALUE 'U' FETCH 'P440300P'
    VALUE 'E' FETCH 'P44300P'
    VALUE 'C' FETCH 'P44090P' #ACTION POLICY-NUMBER(GET-RECORD.)
    VALUE '1':'9'
      WRITE
        1/10 '=' #ACTION       /* The action that was entered by the user
        2/10 '=' #SELECTED-KEY /* The prime key (ie. browse key) of
        3/10 '=' #SELECTED-ISN /* ADABAS files only.
        5/10 'Record selected'
        7/10 CUSTOMER-FIRST-MIDDLE
        8/10 CITY-STATE
        9/10 ZIP-CODE
    NONE IGNORE
  END-DECIDE
  END-SUBROUTINE /* PROCESS-SELECTED-RECORD
*
  DEFINE SUBROUTINE PROCESS-SELECTION-COLUMN
*
* No changes are required in this subroutine
*
  FOR #SEL-INDX = 1 TO #TOTAL-ACTION-LINES
    IF #SEL-TBL.#ACTIONS(#SEL-INDX) NE #NULL-ACTION THEN
      ASSIGN #SELECTED-KEY = #SEL-TBL.#KY(#SEL-INDX)
      ASSIGN #SELECTED-ISN = #SEL-TBL.#ISN(#SEL-INDX)
      ASSIGN #ACTION       = #SEL-TBL.#ACTIONS(#SEL-INDX)
      PERFORM PROCESS-SELECTED-RECORD
    END-IF
  END-FOR
  RESET #SEL-TBL.#ACTIONS(*)
  END-SUBROUTINE
*
  DEFINE SUBROUTINE UPDATE-SELECTION-TABLE
*
* No changes are required in this subroutine
*
  IF #TOP-OF-PAGE THEN
    ASSIGN #SEL-INDX = 1
    RESET #TOP-OF-PAGE
  ELSE
    ASSIGN #SEL-INDX = #NEXT-LINE
  END-IF
  COMPUTE #NEXT-LINE = *LINE-COUNT + 1 - #TOP-LINE
  IF #SEL-INDX = 1 THRU #TOTAL-ACTION-LINES AND #INSIDE-READ-LOOP THEN
    ASSIGN #SEL-TBL.#KY(#SEL-INDX)  = #KEY
    ASSIGN #SEL-TBL.#ISN(#SEL-INDX) = *ISN(READ-FILE.)
  END-IF
  END-SUBROUTINE
*
  DEFINE SUBROUTINE VALIDATE-ACTION-CODES
*
* This subroutine verifies the action code typed by the user.
* You need to set the table (#SELECTS(*) in this example) where the
* valid actions are identified and adjust the REINPUT message to
* meet your actions.
*
  FOR #SEL-INDX = 1 TO #TOTAL-ACTION-LINES
    IF #SEL-TBL.#ACTIONS(#SEL-INDX) NE #NULL-ACTION THEN
      DECIDE FOR FIRST CONDITION
        WHEN NOT (#SEL-TBL.#ACTIONS(#SEL-INDX) = #SELECTS(*))
          REINPUT 'Invalid Select Code. Use U, M, C, E or 1-9 only.'
            MARK *#SEL-TBL.#ACTIONS(#SEL-INDX) ALARM

You may want to change this REINPUT message to reflect your application action codes.

        WHEN *PF-KEY NE 'ENTR'
          REINPUT
         'Line actions can only be specified in conjunction with enter '
            MARK *#SEL-TBL.#ACTIONS(#SEL-INDX) ALARM
        WHEN NONE
          ASSIGN #REDISPLAY-SCREEN = TRUE
      END-DECIDE
    END-IF
  END-FOR
  END-SUBROUTINE /* VALIDATE-ACTION-CODES
END-REPEAT /* PROG.
END