Receiving data field-by-field is the easiest way of receiving data.
In the simplest case you would issue a FEPI RECEIVE command without specifying an INTO data area. FEPI gets the data from the back-end system and builds the resulting screen image internally. The cursor position is returned by the CURSOR option. Information about the number of lines, columns, and fields in the screen image is returned by the LINES, COLUMNS, and FIELDS options.
To get the data, you issue the FEPI EXTRACT FIELD command for each individual field that you want. As well as the data, you can find out the attribute settings for the field, and its length and position. The attribute values are defined in the DFHBMSCA copy book, as is used with BMS. You can issue as many FEPI EXTRACT FIELD commands as you need, for whichever fields you want. You can issue more than one for each field, for example, if you want to get the data and attributes separately. It is generally preferable to use the FIELDLOC option rather than FIELDNUM. There may be spurious attributes between each displayed field which make determining field numbers difficult.
A sample program illustrates the techniques used; see Screen image RECEIVE and EXTRACT FIELD.
The FEPI RECEIVE command completes on ‘end of chain’. This normally coincides with ‘change direction’ or ‘end bracket’, meaning that all data has been received. In some cases, however, back-end applications may send data to you in several sections (chains), each causing a screen update, so you must keep on receiving data until ‘change direction’ or ‘end bracket’ is indicated.
In all cases, the ENDSTATUS option is set to indicate what the completion conditions were. Where several conditions occur together, ENDSTATUS shows the most significant one. The values of ENDSTATUS and their associated meanings are shown in Table 11.
ENDSTATUS | End bracket | Change direction | End of chain | Next command expected |
---|---|---|---|---|
EB | Y | - | Y | Any |
CD | - | Y | Y | FEPI SEND or CONVERSE |
LIC | - | - | Y | FEPI RECEIVE |
Note:
Y=Condition indicated. |
When ‘end bracket’ is received, the session is in contention state, and either end may try to transmit data next. Some back-end systems use ‘end bracket’ in the middle of a series of transmissions to allow the terminal to break in if it wants, and they may use ‘end bracket’ instead of ‘change direction’ at the end of the flow. This is particularly true of IMS™. CICS® usually sends ‘change direction’ eventually, although it may send ‘end bracket’ indicators intermediately.
Using your knowledge of the back-end application and system, you must check the data that you have already received, to determine whether more data is to be expected or the transmission is complete. If more data is expected, you should issue another FEPI RECEIVE command; if the transmission is complete, it is the front-end application’s turn to send data.
You should always use the TIMEOUT option on a FEPI RECEIVE command; see Time-outs.
Apart from communication errors caused externally, the most likely error you may get is due to bad command sequencing. That is, you have issued a FEPI RECEIVE when a FEPI SEND is expected. A FEPI RECEIVE must not follow a FEPI SEND without attention, or a FEPI RECEIVE that indicated ‘change direction’.
Another likely error is ‘previous SEND failed’. This may be an external communication error, or it may be that the back-end system has responded negatively--as IMS does, for example, if you try to run an unknown transaction. The sense data which you can get using FEPI EXTRACT CONV tells you which error it is, and, where the back-end system has responded negatively, you simply issue another FEPI RECEIVE to get the data.
[[ Contents Previous Page | Next Page Index ]]