We help IT Professionals succeed at work.

Monitor QSYSOPR MSGQ

2,801 Views
Last Modified: 2013-12-06
I would like to write a CL program that will monitor the QSYSOPR MSGQ for inquiry messages (messages needing a response).  If it finds one, I would like to send an email (SNDDST) with the 'Message' (Message 'LBE9001' in called program '$CBLDUMP' (C D F G).) is the Subject and the 'Cause' is the body of the email.

Does anyone know a good/easy way to do this?

I appreciate your help.
Comment
Watch Question

Barry HarperConsultant
CERTIFIED EXPERT

Commented:

Generic logic goes like this:

Use the RCVMSG command to receive the messages from the QSYSOPR message queue.
If the return type is '05', then it is an inquiry message that you want to process.
Loop back to receive more messages

If you need more detailed example, let me know!
Barry
Matthew RoessnerSenior Systems Programmer

Author

Commented:
I was starting with something like what I have laid out below.

Essentially I want to monitor the QSYSOPR message queue for any messages needing a reply. If it finds one, I want to email our datacenter. I want the subject of the email to be the Message (as indicated in my post) and the Body of the email to be the Cause of the message (typically when you do a F1).  After the email is sent, I want to continue to monitor for INQ messages...

I am not sure which indentifier to use within the RCVMSG command for those variables.  

Also, I know the variables have to be of the correct type. I just guessed with CHAR...

Will the code below get me to where I need to be? Obviously I need to add the &SUBJECT and &BODY into the RCVMSG command somewhere.

Thanks Barry...
PGM                                             
                                                
/*DECLARE VARIABLES */                          
         DCL  &SUBJECT        *CHAR     120     
         DCL  &BODY           *CHAR     7500    

MONITOR:                                                             
                                                                     
            RCVMSG     MSGQ(QSYS/QSYSOPR) MSGTYPE(*INQ) WAIT(*MAX) +                      RMV(*NO)                                    
                                                                 
            SNDDST     TYPE(*LMSG) TOINTNET((email@test.com)) +  
                         DSTD(&SUBJECT) LONGMSG(&BODY) +             
                       USRID(SERVER AS400)                         
                                                                     
         GOTO CMDLBL(MONITOR)

Open in new window

Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Matthew RoessnerSenior Systems Programmer

Author

Commented:
Does the MSGTYPE of *INQ not filter out all the messages appropriately?

Thanks for the information.  I am not sure of the impact, but I was hoping to just let this program run all the time to always be monitoring the QSYSOPR MSGQ so that any time a message would come in....it would send the email to our Datacenter.  In that case...it would not end unless we would be doing an IPL...
Barry HarperConsultant
CERTIFIED EXPERT

Commented:
Sorry, I overlooked that. You may want to receive all messages in your program because there may be important, non-inquiry messages that you decide to email out as well.
Matthew RoessnerSenior Systems Programmer

Author

Commented:
Thanks for the help Barry. You definitely helped out and answered all my questions

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.