I created a message subfile for displaying errors in a program, but the problem is that messages are displaying in the job log instead of the display screen. Also, I gave overlay to display screen, cleared the PGMQ before writing the message control. What is the actual problem? Please help!
Software/Hardware used:
I-SERIES
ASKED:
September 9, 2011 1:53 PM
UPDATED:
March 31, 2012 4:52 PM
To start, please show the code that sends the message. Or review the details of the joblog message to see what program the message was sent to.
Show the SFL and any SFLCTL entries for the message subfile.
Normally, a message subfile will be associated with a specific program message queue. The name of queue will be the name of the program and will be identified with the SFLPGMQ keyword. In order for it to pick up messages, the messages must be sent to the appropriate program message queue.
There can be many program message queues in a job at the same time, but a given message subfile will only be associated with one of them.
Your program should place the name of the program message queue into the field identified by the SFLPGMQ keyword. Please show any code that might set that field.
Tom
thanks for reply
this is my RPGLE program
C CALL ‘TPW002C’ (clear messages)
C MOVEL ‘N’ @CPY 1
C DOW @CPY=’N’
C WRITE CTLMSG1
C EXFMT RECCPY
C IF *IN03=*ON
C LEAVE
C Endif
C EXSR @VALID3
C ENDDO
C @VALID3 BEGSR
C MOVEL ‘N’ @FLGC 1
C IF WSPID2=*BLANKS
C MOVEL ‘Y’ @FLGC
C SETON 31 (error indicator)
C MOVEL ‘I’ MSGOPT
C MOVEL ‘MSG0001′ MSGID
C MOVEL ‘ERRMSG’ MSGF
C EXSR @SEND
c endif
C @SEND BEGSR
C MOVEL ‘*DIAG’ MSGTYP
C MOVEL PN PGMQ1
C MOVEL ‘KRGUNN’ MSGLIB
C CALL ‘TPW004C’ (cl for sndpgmmsg command)
C PARM MSGID 7
C PARM MSGF 11
C PARM MSGDTA 62
C PARM MSGOPT 1
C PARM MSGLIB 10
C PARM MSGTYP 8
C PARM PGMQ1
C ENDSR
these are my cl
1) TPW002C FOR CLEAR MESSAGES
PGM
RMVMSG PGMQ(*PRV) CLEAR(*ALL)
ENDPGM
2)TPW004C FOR SNDPGMMSG
PGM PARM(&MSGID &MSGF &MSGDTA &MSGOPT &MSGLIB +
&MSGTYP &PGMQ)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&MSGF) TYPE(*CHAR) LEN(11)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(62)
DCL VAR(&MSGOPT) TYPE(*CHAR) LEN(1)
DCL VAR(&MSGLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGTYP) TYPE(*CHAR) LEN(8)
DCL VAR(&PGMQ) TYPE(*CHAR)
MONMSG MSGID(CPF0000)
IF COND(&MSGOPT *EQ ‘I’) THEN(SNDPGMMSG +
MSGID(&MSGID) MSGF(&MSGLIB/&MSGF) +
MSGDTA(&MSGDTA) TOPGMQ(*SAME (*)) +
MSGTYPE(&MSGTYP))
IN MESSAGE SUBFILE I ALREADY DECLARE THE NAME OF PGMQ IS PGMQ1 IN BOTH RECORD FORMAT OF MESSAGE SUBFILE ALSO INSERT PROGRAM NAME IN PGMQ1 AT *INZSR SUBROUTINE ….
THIS IS MY JOB LOG
PROJECT ID CAN NOT BE BLANK
4>> DSPJOBLOG
IT SHOW THE MESSAGE IN JOB LOG THAT WHEN I PRESS F1 TO THAT MESSAGE IT SHOWS FOLLOWING INFO..
Message ID . . . . . . : MSG0001 Severity . . . . . . . : 00
Date sent . . . . . . : 09/09/11 Time sent . . . . . . : 23:24:43
Message type . . . . . : Diagnostic
From . . . . . . . . . : KRGUNN CCSID . . . . . . . . : 65535
From program . . . . . . . . . : TPW004C
From library . . . . . . . . : KRGUNN
From module . . . . . . . . : TPW004C
From procedure . . . . . . . : TPW004C
From statement . . . . . . . : 1100
To program . . . . . . . . . . : TPW004C
To library . . . . . . . . . : KRGUNN
To module . . . . . . . . . : TPW004C
To procedure . . . . . . . . : TPW004C
To statement . . . . . . . . : 1100
Time sent . . . . . . . . . . : 23:24:43.578656
THIS MY MESSAGE SUBFILE
A R SUBMSG1 SFL
A*%%TS SD 20110909 063040 KRGUNN REL-V5R4M0 5722-WDS
A SFLMSGRCD(24)
A MSGKEY SFLMSGKEY
A PGMQ1 SFLPGMQ(10)
A R CTLMSG1 SFLCTL(SUBMSG1)
A*%%TS SD 20110909 074711 KRGUNN REL-V5R4M0 5722-WDS
A 60 SFLDSP
A 61 SFLDSPCTL
A 64 SFLINZ
A 63 SFLCLR
A 62 SFLEND
A SFLSIZ(0020)
A SFLPAG(0001)
A PGMQ1 SFLPGMQ(10)
Program TPW004C sends messages to TOPGMQ(*SAME (*)). So it sends to the program message queue for TPW004C.
But TPW004C is gone as soon as the CALL finishes.
You have this statement in your program before you call TPW004C:
I can’t see what value you have in PN.
You use PGMQ1 as an input parameter in your call to TPW004C, but you don’t use that parameter. If you had the name of your RPG program in PN and you used PGMQ1 in the SNDPGMMSG command, you would get closer to having your messages in your RPG program’s message queue.
Actually, you should throw the TPW004C program away. Instead, just call the Send Program Message (QMHSNDPM) API. The system already has a program to do what you want TPW004C to do. There’s no reason to write a program when one already exists on the system that does what you need.
Further, the QMHSNDPM API knows where to send the message if you use a null pointer or ‘*’ as the value for the Call stack entry parameter. When you call a different program to run SNDPGMMSG, you change the call stack. That changes where SNDPGMMSG sends its messages. You have to add code to cause the message to go to where you need it to go.
There might be more, but that might be enough for now.
Tom
Thanx sir,
but i already move my program name to PGMQ1 in * inzsr subroutine also i try that statement
C MOVEL PN PGMQ1
before calling my sndpgmmsg CL also i check the value of PGMQ1 it shows my program name i.e. TPW003R but i won`t understand how and where to use the value of PGMQ1 in sndpgmmsg command use in cl.
…it shows my program name i.e. TPW003R…
That’s fine, but that’s not where TPW004C is sending messages. It’s sending to TOPGMQ(*SAME (*)). That sends the messages to the wrong program queue.
You can change TPW004C to send to the program queue for TPW003R instead. You pass the value in, but then you don’t use it for the SNDPGMMSG command.
Still, I’d simply stop using TPW004C, and I’d call the API. That eliminates the need to write the TPW004C program at all. You could also call the Remove Program Messages (QMHRMVPM) API with its basic parm values and eliminate TPW002C.
Tom
ok sir now i am trying to use as you mention earlier that QMHSNDPM but still it doesn’t disply the messages
my rpgle is as follow
DSNDMSG PR EXTPGM(‘QMHSNDPM’)
DMSGID 7A CONST
DMSGF 20A CONST
DMSGDTA 80A CONST
DMSGDTALEN 8B 0 CONST
DMSGTYP 10A CONST
DPGMQUE 10A CONST
DPGMNBR 8B 0 CONST
DMSGK 4A
DERRCOD 116A
D****************************************************************
DMSGID S 7A INZ(‘MSG0001′)
DMSGF S 20A INZ(‘ERRMSG KRGUNN ‘)
DMSGDTA S 80A INZ(*BLANKS)
DMSGDTALEN S 8B 0 INZ(0)
DMSGTYP S 10A INZ(‘*DIAG’)
DPGMQUE S 10A INZ(‘TPW004R’)
DPGMNBR S 8B 0 INZ(1)
DMSGK S 4A INZ(*BLANKS)
D**********************************************************************
DRMVMSG PR EXTPGM(‘QMHRMVPM’)
DRmv_PgmQue 10A
DRmv_StkCnt 8B 0
DRmv_MsgKey 4A
DRmv_Remove 10A
DERRCOD 116A
D**********************************************************************
DRmv_PgmQue S 10A INZ(‘*’)
DRmv_StkCnt S 8B 0 INZ(0)
DRmv_MsgKey S 4A INZ(*BLANKS)
DRmv_Remove S 10A INZ(‘*ALL’)
D**********************************************************************
DERRCOD DS INZ
DErByteProv 9B 0 INZ(0)
DErByteAval 9B 0 INZ(0)
DErExceptId 7A
DErReserved 1A
DErExcptDta 100A
D**********************************************************************
NOW THIS IS MY ACTUAL LOGIC I.E C spec
C DOW *IN03=*OFF
C EXSR @CHK
C EXFMT CTLMAIN
C EXSR @RESET
C IF *IN03=*ON
C LEAVE
C ENDIF
C IF *IN06=*ON
C EXSR @PRINT
C ENDIF
C EXSR @VALID
C ENDDO
@VALID =IS ENTER KEY VALIDATION WHERE I CALL THAT PROCEDURE TO SEND MESSAGE. FOR FIRST TIME I WANT TOSEND JUST 1 MESSAGE TO MESSAGE SUBFILE.
C @VALID BEGSR
C MOVEL ‘N’ @FLGE 1
C MOVEL ‘N’ FLGOPT 1
C Z-ADD *ZEROS RES 2 0
C EVAL X=1
C DOW X<=MAXRRN
C X CHAIN SUBMAIN
C IF WSOPT<>*BLANKS
C MOVEL ‘Y’ FLGOPT
C SETON 59
C UPDATE SUBMAIN
C LEAVE
C ELSE
C EVAL X=X+1
C ENDIF
C ENDDO
C* HERE IS LOGIC TO SEND MESSAGE
C IF WSDID<>*BLANKS AND WSSDAT=*ZEROS
C IF FLGOPT=’Y’
C SETON 3133 (ERR INDICATOR)
C MOVEL ‘Y’ @FLGE
C EVAL MSGDTA=’PROJECT ID CAN NOT BE BLANK’
C EVAL MSGDTALEN=%LEN(%TRIM(MSGDTA))
C EXSR @SEND
C WRITE RECFTR
C WRITE(E) CTLMSG
C ENDSR
C @SEND BEGSR
C CALLP SNDMSG (MSGID:
C MSGF:
C MSGDTA:
C MSGDTALEN:
C MSGTYP:
C PGMQUE:
C PGMNBR:
C MSGK:
C ERRCOD)
C ENDSR
IN @RESET I CLEAR THE MESSAGES
C @RESET BEGSR
C SETOFF 313233
C CALLP RMVMSG(Rmv_PgmQue:
C Rmv_StkCnt:
C Rmv_MsgKey:
C Rmv_Remove:
C ERRCOD)
C ENDSR
THIS IS MY JOB LOG
4 > DSPJOBLOG
Ownership of object QRNFER in QTEMP type *USRSPC changed.
Ownership of object QRNFEF in QTEMP type *USRSPC changed.
Ownership of object TPW004R in QTEMP type *MODULE changed.
Ownership of object TPW004R in KRGUNN type PGM changed.
AUT and USRPRF parameter values were ignored.
Replaced object TPW004R type *PGM was moved to QRPLOBJ.
Program TPW004R placed in library KRGUNN. 00 highest severity. Created on
09/14/11 at 02:55:57.
PROJECT ID CAN NOT BE BLANK
PROJECT ID CAN NOT BE BLANK
WHEN I PRESS F1 TO ABOVE LINE THEN IT SHOWS ME
Message ID . . . . . . : MSG0001 Severity . . . . . . . : 00
Date sent . . . . . . : 09/14/11 Time sent . . . . . . : 02:56:05
Message type . . . . . : Diagnostic
From . . . . . . . . . : KRGUNN CCSID . . . . . . . . : 65535
From program . . . . . . . . . : TPW004R
From library . . . . . . . . : KRGUNN
From module . . . . . . . . : TPW004R
From procedure . . . . . . . : TPW004R
From statement . . . . . . . : 1315
To program . . . . . . . . . . : TPW004R
To library . . . . . . . . . : KRGUNN
To module . . . . . . . . . : TPW004R
To procedure . . . . . . . . : _QRNP_PEP_TPW004R
To statement . . . . . . . . : *N
PLZ HELP ME SIR AM TRYING THIS FROM LAST WEEK
First, let’s get rid of all of those ‘B’ data types. You really don’t want to start using those for APIs. Get all of those changed over integer data types. In nearly all cases, you’ll want those defined this way:
There will eventually be likely exceptions where you’ll use ‘U’ instead ‘I’, and possibly a 5-digit length or even a 20-digit length instead of 10 digits. But lots of things will go smoother if you just use “10I 0″ for anything you see documented as BINARY(4).
Here are some suggested changes:
DSNDMSG PR EXTPGM('QMHSNDPM') D MSGID 7A const D MSGF 20A const D MSGDTA 80A const D MSGDTALEN 10i 0 const D MSGTYP 10A const D PGMQUE 10A const D PGMNBR 10i 0 const D MSGK like( MsgKey ) D ERRCOD like(ERRCODDS) DRMVMSG PR EXTPGM('QMHRMVPM') D Rmv_PgmQue 10A const D Rmv_StkCnt 10i 0 const D Rmv_MsgKey 4A const D Rmv_Remove 10A const D ERRCOD like(ERRCODDS) D ERRCODDS DS INZ D ErByteProv 10i 0 INZ(116) D ErByteAval 10i 0 INZ(0) D ErExceptId 7A D ErReserved 1A D ErExcptDta 100A D MsgKey S 4A INZ(*BLANKS)With those, here is a sample CALLP that would clear the program message queue for TPW004R:
C callp RMVMSG('*':0:' ':'*ALL':ERRCODDS)That’s all there is to that.
And we can show an example of sending an *INFO message to the TPW004R program message queue. This will send a CPF9897 message from QSYS/QCPFMSG. It will use “Here’s my message” for the message data which is 17 bytes of data:
C callp SNDMSG('CPF9897':'QCPFMSG QSYS': C 'Here''s my message':17:'*INFO': C '*':0:MsgKey:ERRCODDS)You can format that so that each parm is on a separate line if you wish.
Look those over to see what makes sense and what needs more explanation. There’s a chance that something get messed up during copy/paste, but it all came from a test function that I built from your code. It ought to be close. We can fix any details.
Tom