iSeries / AS400 FAQ : (Category) Programming : (Category) CL : How can I get information out of a system message?
Q. In a CL program, what’s the best way to get the job number of a job that was just submitted. This is what we are currently doing… SBMJOB CMD(CALL PGM(program)) RCVMSG MSGTYPE(*LAST) MSG(&RMSG) MSGID(&MID) IF COND(&MID *EQ ‘CPC1221’) THEN(DO) CHGVAR VAR(&JOBNO) VALUE(%SST(&RMSG 5 6)) ENDDO This works fine, but sometimes the message text will be in Spanish and the job number is in a different position. Is there a better way to do it so that it doesn’t matter what language is used???? A. You’re very close! Instead of using the MSG() parameter, use the MSGDTA() parameter. MSGDTA() contains the substitution data, not the “finished” message. Do a DSPMSGC CPC1221, option 1 and you’ll see Job &3/&2/&1 submitted to job queue &4 in library &5. Those ‘&1’, etc. notations are parameter markers. They say that the program sending the message can substitute actual data in those places. Now look at option 2 and you’ll see Field Data Type Length &1 *CHAR 10 &2 *CHAR 10 &3 *CHAR 6 &4 *CHAR 10 &5 *C
Related Questions
- iSeries / AS400 FAQ : (Category) Programming : (Category) CL : How can I determine the IP address my session is using?
- iSeries / AS400 FAQ : (Category) Programming : (Category) CL : Where can I find the list of messages I can monitor?
- iSeries / AS400 FAQ : (Category) Programming : (Category) CL : How can I get information out of a system message?