A BMS output example
This example shows how BMS creates a formatted screen. It takes a list of data items from a program and displays them on the screen according to a predefined format.
BMS creates a formatted screen by merging variable data supplied by the program with constant data in the format (titles, labels for variable fields, default values for these fields). It builds the data stream for the terminal to which you are writing, to show this merged data in the designated screen positions, with the proper attributes (color, highlighting, and so on). You do not have to know anything about the data stream, and you do not need to know much about the format to write the required CICS® commands.
You define the formats, called maps, separately from the programs that use them. Allowing you to reposition fields, change their attributes, and change the constant text without modifying your programs. If you add or remove variable data, you need to change the programs which use the affected fields.
The basics of how this works are explained by an atypically simple example. In real life, requirements are always more complex, but this gives you the essentials without too much confusing detail. There are more realistic and complete BMS examples among the CICS sample applications. These programs are included in source form on the CICS distribution tape. More information can be found in the Sample Applications Guide.
QCK Quick Customer Account Check
Account: 0000005
Name: Thompson Chris
Max charge: $500.00
QCK Quick Customer Account Check
Account: 0000005
Name: Thompson Chris
Max charge: $0.00
STOLEN CARD - SECURITY NOTIFIED
You must first define the screen. We explain how to do so for this particular map in Creating the map. For the moment, however, let us assume that one of the outputs of this process is a data structure like the one in Figure 3. (We show the COBOL-coded version of the structure, because we are using COBOL to code our examples. However, BMS produces the structure in any language that CICS supports.) The map creation process stores this source code in a library from which you copy it into your program.
01 QCKMAPO.
02 FILLER PIC X(12).
02 FILLER PICTURE X(2).
02 ACCTNOA PICTURE X.
02 ACCTNOO PIC X(7).
02 FILLER PICTURE X(2).
02 SURNAMEA PICTURE X.
02 SURNAMEO PIC X(15).
02 FILLER PICTURE X(2).
02 FNAMEA PICTURE X.
02 FNAMEO PIC X(10).
02 FILLER PICTURE X(2).
02 CHGA PICTURE X.
02 CHGO PIC $,$$0.00
02 FILLER PICTURE X(2).
02 MSGA PICTURE X.
02 MSGO PIC X(30).
Each field that you name on the screen generates several fields in the data structure, which are distinguished by a 1-character suffix added to the name you assigned in the map. Two appear here, the “A” suffix for the field attributes byte and the “O” suffix for the output data. If we were creating a map to use special device features like color and highlighting, or were using the map for input as well as output, there would be many more. We tell you about these other fields in Setting the display characteristics and Receiving mapped data.
The key fields for this particular exercise are the ones suffixed with “O”. These are where you put the data that you want displayed on the screen. You use the “A” subfields if you want to change how the data is displayed. In our example, we use MSGA to highlight the message if our customer is using a dubious card.
WORKING-STORAGE SECTION.
C COPY IN SYMBOLIC MAP STRUCTURE.
01 COPY QCKSET.
01 ACCTFILE-RECORD.
02 ACCTFILE-ACCTNO PIC S9(7).
02 ACCTFILE-SURNAME PIC X(15).
02 ACCTFILE-FNAME PIC X(10).
02 ACCTFILE-CREDIT-LIM PIC S9(7) COMP-3.
02 ACCTFILE-UNPAID-BAL PIC S9(7) COMP-3.
02 ACCTFILE-CUR-CHGS PIC S9(7) COMP-3.
02 ACCTFILE-WARNCODE PIC X.
PROCEDURE DIVISION.
EXEC CICS READ FILE (ACCT) INTO (ACCTFILE-RECORD) RIDFLD (CKNO)
... END-EXEC.
MOVE ACCTFILE-ACCTNO TO ACCTNOO.
MOVE ACCTFILE-SURNAME TO SURNAMEO.
MOVE ACCTFILE-FNAME TO FNAMEO.
COMPUTE CHGO = ACCTFILE-CREDIT-LIM - ACCTFILE-UNPAID-BAL
- ACCTFILE-CUR-CHGS.
IF CHGO < ZERO, MOVE ZERO TO CHGO
MOVE 'OVER CHARGE LIMIT' TO MSGO.
IF ACCTFILE-WARNCODE = 'S', MOVE DFHBMBRY TO MSGA
MOVE 'STOLEN CARD - SECURITY NOTIFIED' TO MSGO
EXEC CICS LINK PROGRAM('NTFYCOPS') END-EXEC.
EXEC CICS SEND MAP ('QCKMAP') MAPSET ('QCKSET') END-EXEC.
EXEC CICS RETURN END-EXEC.