<i>i tried using RCVMSG but it dint wor out.</i>
RCVMSG is a correct way to do it in CL. If it didn’t work out, then you need to show us what you did so we can determine what was wrong.
If you are working in a language such as RPG, the correct method would be to use the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/QMHRCVPM.htm”>Receive Program Message (QMHRCVPM) API</a>. The API can also be used in CL, but the RCVMSG command might be easier to use.