want to know the data queue created or not, before receive the data queue in RPGLE

Posted on 2010-01-03
Last Modified: 2013-12-06
In my RPGLE, First step i need to send data to debit server program this will be running in batch as a background process, in this data queue will be created and the necessary data will be sent to the data queue using QSNDDTAQ.
Second step i will be displaying the popup till i get response from the batch process(through data queue), so i need to know whether the dtaq created in the batch process or not, to receive the dtaq, so i want to check the whether the data queue object created or not.


Call Debit server program
Call Display popup

Debit server program:(Batch process)
Sending request to another application
expecting response
Got the response
create the dtaq
qsnddtaq the response to the display popup pgm.

Display popup pgm:
Display the popup with invite keyword
it has to receive the response through the data queue, so i need to know whether the data queue created in the batch process, before start doing QRCVDTAQ.

Question by:karthikgayathri
    LVL 34

    Accepted Solution

    One easy method is to use the CHKOBJ command to verify that the data queue exists.  Something like the sample below.  Chkobj can throw the following errors.  If you want to test for specific errors, you can use a MONITOR block.

    CPF9801 Object &2 in library &3 not found.
    CPF9802 Not authorized to object &2 in &3.
    CPF9810 Library &1 not found.
    CPF9815 Member &5 file &2 in library &3 not found.
    CPF9820 Not authorized to use library &1.
    CPF9830 Cannot assign library &1.
    CPF9899 Error occurred during processing of command.

    There are other methods, as well. For example, you can call the QUSROBJD API.  If your program is going to call this very frequently, the QUSROBJD call is probably more efficient than calling the CHKOBJ command via the QCMDEXC.

    Or you can just call the QRCVDTAQ API - it will also return an error if you pass the name of a data queue that doesn't exist.

    - Gary Patterson.

    callp(e) qCmdExc (cmd : %len(cmd));
    if %error
      'Missing library, object, or authority

    Open in new window

    LVL 5

    Expert Comment

    Garys code correctly answers the question that was asked.

    When I do that kind of data queue processes I have the client create their own queue prior to making the request.  That way you KNOW the queue will be present.  You can just hang on the queue read right away.

    Steve Bowdoin
    LVL 16

    Expert Comment

    by:theo kouwenhoven
    Hi Steve,

    An other approach is creating the DTAQ in CL before starting the RPG program:

    Just create the DataQ and catch the error if it exist.

               CRTDTAQ DTAQ(MyLib/MyDTAQ) MAXLEN(50)
               MONMSC CPF0000

    The MONMSG will suppres the error if the DTAQ exist.
    so after these 2 lines It will be there.

    LVL 16

    Expert Comment

    by:theo kouwenhoven
    Did it work ????
    LVL 16

    Expert Comment

    by:theo kouwenhoven
    there are more then one road to rome, isn't there?
    LVL 34

    Expert Comment

    by:Gary Patterson
    In the original question, the author specifically indicated that that it is the server program's job to create the data queue and populate it.  

    In that particular case, creating the queue in the client could break the server, which is why I instead provided a relatively low-risk method for checking for the existence of the data queue in the client, rather than suggesting creating the queue where it could possibly interfere with the functionality of the server program.

    I agree that, in general, it doesn't matter if the client or the server creates the queue, but in the particular case described in this question, and without seeing the server code, I think the best answer is to block on the client side and wait for the server to create and populate the queue.

    - Gary


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, ( because one time I did this and I essentially had a bricked …
    Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now