Previous Topic: Conducting a Map Paging SessionNext Topic: How to Code an Update Application


How to Code a Browse Application

To write a pageable map application that allows the user to display data but not update it, perform the following steps:

  1. Establish a switch in variable storage. This switch should be set on if run-time mapping has transmitted the first page.
  2. Issue mapping mode housekeeping statements, as explained in Housekeeping.
  3. Initiate the map paging session by issuing a STARTPAGE statement that specifies NOWAIT and BROWSE.
  4. Initialize header data fields.
  5. Perform the following steps iteratively until all data is retrieved:
    1. Perform database retrieval and move data to map data fields in variable storage.
    2. Issue a MAP OUT DETAIL NEW statement, checking for a status of 4676 (DC-FIRST-PAGE-SENT).
    3. Set the first-page switch if 4676 is returned; perform the IDMS-STATUS routine if 4676 is not returned.

Ending the Browse Session

If, after all detail occurrences have been created, the first-page switch is not set, you should transmit the map page to the terminal screen by issuing a MAP OUT RESUME statement.

The next task specified in the DC RETURN NEXT TASK CODE statement should include logic that tests to see if the user has indicated the end of the map paging session. If so, issue an ENDPAGE SESSION statement.

Example of a Browse Application

The program excerpt below shows a pageable map application in which run-time mapping handles all paging requests (paging type of NOWAIT) and the operator cannot make updates (paging mode of BROWSE).

After acquiring the data passed from a previous task and establishing that database records are present, this program issues MAP OUT DETAIL statements iteratively until all detail occurrences are written. DEPTEND, which is specified as the next task, ends the paging session with the ENDPAGE command and performs processing based on the control key pressed.

 DATA DIVISION
 01  FIRST-PAGE-SW           PIC X  VALUE 'N'.
        88 LESS-THAN-A-PAGE     VALUE 'N'.
 01  MAP-WORK-REC.
     05 WORK-FIRST            PIC X(10).
     05 WORK-LAST             PIC X(15).
     05 WORK-EMP-ID           PIC X(4).
 LINKAGE SECTION.
 01  PASS-DEPT-INFO.
     05 PASS-DEPT-ID         PIC 9(4).
     05 PASS-DEPT-INFO-END   PIC X.

 PROCEDURE DIVISION.
     BIND MAP DCTEST01.
     BIND MAP DCTEST01 RECORD MAP-WORK-REC.
*** ACQUIRE DEPT-ID FROM ERROR CHECKING PROGRAM ***
     GET STORAGE FOR PASS-DEPT-INFO TO
                    PASS-DEPT-INFO-END
        WAIT SHORT USER
        STGID 'RKNS'.
*
     MOVE PASS-DEPT-ID TO DEPT-ID-0410.
     FREE STORAGE STGID 'RKNS'.
*
     COPY IDMS SUBSCHEMA-BINDS.
     READY USAGE-MODE RETRIEVAL.
*
     OBTAIN CALC DEPARTMENT
       ON DB-REC-NOT-FOUND GO TO NO-DEPT-ERR.
     IF DEPT-EMPLOYEE IS EMPTY
           GO TO NO-EMP-ERR.
*** BEGIN MAP PAGING SESSION ***
     STARTPAGE SESSION DCTEST01 NOWAIT BACKPAGE BROWSE.
     PERFORM A100-GET-EMPLOYEES THRU A100-EXIT
                      UNTIL DB-END-OF-SET.
     FINISH.
*** IF FIRST PAGE NOT YET SENT, MAP OUT RESUME ***
     IF LESS-THAN-A-PAGE
        MAP OUT USING DCTEST01 RESUME.
*** NEXT TASK ENDS PAGING SESSION ***
     DC RETURN NEXT TASK CODE 'DEPTEND'.

 A100-GET-EMPLOYEES.
     OBTAIN NEXT WITHIN DEPT-EMPLOYEE
        ON DB-END-OF-SET GO TO A100-EXIT.
     MOVE EMP-FIRST-NAME-0415 TO WORK-FIRST.
     MOVE EMP-LAST-NAME-0415 TO WORK-LAST.
     MOVE EMP-ID-0415 TO WORK-EMP-ID.
*** MAP OUT CURRENT DETAIL, CHECK FOR ERROR-STATUS OF 4676 ***
     MAP OUT USING DCTEST01
         DETAIL NEW
         ON DC-FIRST-PAGE-SENT
            MOVE 'Y' TO FIRST-PAGE-SW.
 A100-EXIT.
     EXIT.
 .
 .
 .
*** FURTHER PROCESSING, INCLUDING ERROR ROUTINES ***