When the job is submitted, message ID CPC1236 will be sent to that message queue. When the job finishes, message ID CPF1241 will be sent to that message queue for a normal completion and CPF1240 will be sent for abnormal completion.

You can have a program that receives the messages from the message queue. This program could be scheduled to run

If CPF1241is found, then your program can go ahead and call PGMB. If only CPC1236 is found, your program might retrieve the status of JOBA to see if it’s active; when it finishes, you can check the message queue again to see if it completed normally.