TechTalk: Using Predefined Messages

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Q: If you have messages defined with multiple parameters-like FILE, LIB and MEMBER parameters-how do you actually pass the variable data into those parameters from a CL program? Those parameters aren't really defined variables within your CL program. I can see how having just the &1 variable would work with the MSGDTA parameter, but how would it handle multiple variables?

A: Every time you have predefined substitution variables in a message description, the message description knows the format and length of each variable. Suppose you want to create a message description in MYLIB/MYMSGF which goes like this:

Program &1 in &2 not found.

This message description is to have an ID of PGM0001. This is the command you use to create the message description:

 ADDMSGD MSGID(PGM0001) + MSGF(MYLIB/MYMSGF) + MSG('Program &1 in &2 not + found.') + FMT((*CHAR 10) (*CHAR 10)) 

This means that, when you send PGM0001 with the Send Program Message

(SNDPGMMSG) command, the MSGDTA parameter's value will be assigned as follows:

the first 10 characters to &1, the next 10 characters to &2. Therefore:

 SNDPGMMSG MSGID(PGM0001) + MSGF(MYLIB/MYMSGF) + MSGDTA('PGM1 PRODLIB') + MSGTYPE(*DIAG) 

...sends PGM0001 as a diagnostic message, and will read: Program PGM1 in PRODLIB not found.

Optionally, you can use a CL variable in the MSGDTA parameter and set its value before running SNDPGMMSG. See 3. The &PGM and &LIB objects are both TYPE (*CHAR) LEN(10).

Optionally, you can use a CL variable in the MSGDTA parameter and set its value before running SNDPGMMSG. See Figure 3. The &PGM and &LIB objects are both TYPE (*CHAR) LEN(10).


TechTalk: Using Predefined Messages

Figure 3 Using Predefined Messages

 DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) /* LEN(80) as example */ : CHKOBJ OBJ(&LIB/&PGM) OBJTYPE(*PGM) MONMSG MSGID(CPF9801) EXEC(DO) CHGVAR VAR(&MSGDTA) VALUE(&PGM *CAT &LIB) SNDPGMMSG MSGID(PGM0001) MSGF(MYLIB/MYMSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) RETURN ENDDO 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: