示例: 等待来自显示文件和数据队列的输入
此示例显示作业中的程序正在等待来自显示文件的输入以及另一作业中的数据队列上的输入。
作业 B 中的程序正在等待来自它正在使用的显示文件的输入,并等待输入从作业 A 到达数据队列。而不是交替地等待显示文件,然后等待数据队列,程序等待一个对象,即数据队列。

程序调用 QRCVDTAQ 并等待在显示文件上指定的数据队列上的项的放置。 作业 A 还将条目放置在同一数据队列上。 有两种类型的条目放在此队列上,即显示文件条目和用户定义的条目。 当显示文件中的数据可用时,显示数据管理将显示文件项放在数据队列上。 作业 A 将用户定义的条目放在数据队列上。
上一个示例中描述了显示文件项的结构。
作业 A 放在队列上的项的结构由应用程序员定义。
以下示例显示作业 B 中的应用程序可能使用的编码逻辑:
.
.
.
.
OPEN DSPFILE ... /* Open the Display file. DTAQ parameter specified on*/
/* CRTDSPF, CHGDSPF, or OVRDSPF for the file. */
.
.
DO
WRITE DSPFILE /* Write with Invite for the Display file */
CALL QRCVDTAQ /* Receive an entry from the data queue specified */
/* on the DTAQ parameter for the file. Entries */
/* are placed on the data queue either by Job A or */
/* by display data management when data is */
/* available from any invited device on the display */
/* file. */
/* After the entry is received, determine what type */
/* of entry it is, process it, and return to receive */
/* the next entry on the data queue. */
IF 'ENTRY TYPE' FIELD = '*DSPF ' THEN /* Entry is from display */
DO /* file. Since this entry*/
/* does not contain the */
/* data received, the data*/
/* must be read from the */
/* file before it can be */
READ DATA FROM DISPLAY FILE /* processed. */
PROCESS INPUT DATA FROM DISPLAY FILE
WRITE TO DISPLAY FILE /* Write with Invite */
END
ELSE /* Entry is from Job A. */
/* This entry contains */
/* the data from Job A, */
/* so no read is required*/
/* before processing the */
/* data. */
PROCESS DATA QUEUE ENTRY FROM JOB A
LOOP BACK TO RECEIVE ENTRY FROM DATA QUEUE
.
.
.
END