Follow the steps given below
1. Create a data queue.
CRTDTAQ DTAQ(Mylib/Mydataq) TYPE(*STD) MAXLEN(124) FORCE(*YES) SIZE(*MAX2GB 1000) TEXT('My first data queue')
2. Define a data structure in your RPG program. Please remember that, data structure is used to read and write data into the data queue according to an order. For our convenience we are defining 124 length data structure.
3. By calling the below mentioned program, you will be able to write data into the data queue.
Call 'QSNDDTAQ'
Parm Dataqueue (Name of the data queue)
Parm lib (Library of the data queue)
Parm len (Length of the data queue)
Parm Dtq_struct (Data structure)
4. Write another program to retrieve data from the data queue.
Call 'QRCVDTAQ'
Parm Dtqnam (Name of the data queue)
Parm Dtqlib (Library of the data queue)
Parm Dtqfldlen (Length of the data queue)
Parm Dtqfld (Data structure)
Parm Dtqwait (Amount of time to wait if no record exist in the data queue)