To read messages from a WebSphere MQ queue, use the following code:
CALL 'MQGET'
    USING by value HCONN, by value HQUEUE,
    by reference MSGDESC, by reference GETMSGOPTS,
    by value BUFFER-LEN, by reference BUFFER-REP, 
    by reference DATA-LEN,
    COMPCODE, REASON
            in the following modes:
INPUT Mode:
| Variable | Description | Definition | 
|---|---|---|
| HCONN | S9(9) BINARY handle to queue manager | User-defined | 
| HQUEUE | S9(9) BINARY handle to queue | User-defined | 
| BUFFER-LEN | S9(9) BINARY length in bytes of buffer area | User-defined | 
| DATA-LEN | S9(9) BINARY length in bytes of data in the message | User-defined | 
OUTPUT Mode:
| Variable | Description | Definition | 
|---|---|---|
| BUFFER-REP | Area to contain the message data | User-defined | 
| COMPCODE | S9(9) BINARY returns the completion code | User-defined | 
| REASON | S9(9) BINARY returns the reason | User-defined | 
I-O Mode:
| Variable | Description | Definition | 
|---|---|---|
| MSGDESC | Structure describes the attributes of the message required and the attributes of the message retrieved | cmqmdv.cpy | 
| GETMSGOPTS | Options that control the action of MQGET For example, if you want to read a specific message, then you can specify the option MQMO_MATCH_CORREL_ID which causes only messages with the specified correl-id to be retrieved. | cmqgmov.cpy |