I am not sure on your level of experience with PCF programming, but you might find this MQTC session on PCF programming helpful in writing a PCF program and also debugging your issue.
https://www.mqtechconference.com/sessions_v2015/MQ_PCF.pdf
I have written some PCF programs myself, and they are not trivial to do. I started with one of the PCF samples that IBM MQ provides in their sample code, and that was very helpful.