Messages by the application on the screen at botton line.

Posted on 2004-05-03
Medium Priority
Last Modified: 2007-12-19
i m making a small program in RPG n i want to give some messages at the bottom line of the display
can u tell me what are the ways in which i can do this and please give some explanatory example based on each one of that since i m new to this tech.
Question by:mayankgangrade
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 27

Expert Comment

ID: 10980618

I'm not sure you've given enough information. There are different ways depending on the environment.

Does the RPG program have a display file that it's doing I/O against? If so, does the display file define a message line? Does it define a message subfile? If no display file, what will be on the screen when the program is called? Will it be a system display or will it be called from another program? If called from another program, what does that program do with display files? Or is everything done with UIM panel groups or DSM APIs? (Or is it an EPM environment?)

When you send the message out, do you want it to show immediately? Do you want it to remain on the screen after the program ends or is it temporary?

Okay, simple start... You can send *STATUS messages to the the *EXT program message queue. This can be done with a SNDPGMMSG CL command or by calling the Send Program Message (QMHSNDPM) API. The SNDPGMMSG command can be in a small CL program that can be called by your RPG program; just pass in the message data you want to send. It'd be better in the long run if you learned the API, but the CL is an easy start.

Maybe that's all you need to know. It generally works for many circumstances.



Author Comment

ID: 10983770
i m using a display file with RPG n i have not defined any message lines in the display file since i don't know how to do that. can we do it without calling a  CL program ?
LVL 27

Expert Comment

ID: 10989270

With the record-level keyword RTNCSRLOC(&RCD &FLD &POS), you can get info about the cursor location when the user presses <Enter>. With the record-level keyword CSRLOC(LINNBR POSNBR), you can set the position where the cursor should be on an output operation.

However, when the user presses <Enter>, the cursor might not be in the field that you want to position the cursor in. The user might have typed into FLD1, <Tab> to Fld2, typed in FLD2, then moved back to FLD1 to correct a character. When <Enter> is pressed, the display file will report that the cursor is in FLD1.

You still need to track which fields had data entered into them. Your program logic will need to decide what to do next. The CSRLOC() keyword can be used on output if you don't want to use indicators for DSPATR(PC), but you'll need to keep track of the actual locations of your display fields.


Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

LVL 27

Expert Comment

ID: 10989279
Whoa, my apologies... I typed that previous item into the wrong window... Please ignore it.

LVL 27

Accepted Solution

tliotta earned 200 total points
ID: 10989874

Okay, correct window this time (I think).

Even though you haven't specified a message-line, one was automatically assigned. One problem is that different display emulators can handle message-lines in different ways. I suppose most developers prefer to take control by adding a "message subfile" to their display file. It looks something like:

     A          R @MSESFL                   SFL
     A                                      SFLMSGRCD(24)
     A            @MSMKY                    SFLMSGKEY
     A            @MSPGQ                    SFLPGMQ
     A          R @MSESFLC                  SFLCTL(@MSESFL)
     A                                      SFLSIZ(0002)
     A                                      SFLPAG(0001)
     A                                      OVERLAY
     A  88                                  SFLEND
     A  88                                  SFLDSP
     A  88                                  SFLINZ
     A  92                                  SFLDLT
     A            @MSPGQ                    SFLPGMQ

That defines a single-line subfile on line 24 of the display. Because SFLSIZ>SFLPAG, it can hold up to 9999 messages and can be scrolled through.

This is essentially what you see on many system displays.

The @MSPGQ field usually can hold the name of the program that opened the display file; this is the program message queue where messages are taken from for the display. The @MSMKY field can hold a message key, but many programmers leave it alone.

The combination of keywords is often what's important rather than the content of those fields.

By specifying keywords SFLMSGRCD() and SFLINZ and executing an output operation for the subfile with indicator 88 on, the messages on the program's message queue are moved into the message subfile and displayed. So you send any messages you want displayed to the program's message queue and then tell the subfile to display them.

The message subfile gives you some direct control over how messages display in your own DSPFs. Under some circumstances, you have no DSPF or you need a generic solution -- that is the alternative where you'll most likely send a *STATUS message to the *EXT message queue (The 'external' message queue of the job). That message will generally display wherever the current message line is defined.

LVL 14

Expert Comment

ID: 10994985
The best way is Tom's solution using message subfiles - this gives the programm the most flexability and requires only 1 error indicator per field on the screen.
One thing to has not posted is how to get the message onto the screen.
If you are using RPG and not RPGLE the easiest way is via a CL and a message file (CRTMSGF and WRKMSGD to create and manage the message file)
The following CL is one I use to use (it may not be the best)

Pass the mesasge ID and Message file - a blank message removes all messages.

PGM  PARM(&MSGID &MSGF)                                
DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)              
DCL        VAR(&MSGF) TYPE(*CHAR) LEN(10)              
IF         COND(&MSGID *NE '       ') THEN(DO)          
SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGF)                    
MONMSG CPF0000                                          
ELSE       CMD(DO)                                      
RMVMSG     PGMQ(*PRV) CLEAR(*ALL)                      


An easier way to display a mesage - I do not like this method but it is easy.
*in60, when on, will show msg001 in msgfile MYMSGF and switch off *in60
*IN61, when on, will  show the text and turn off *in61
*in62, when on,  will display the contents of field MTXT and switch off *in62 (MTXT is set in the RPG)

A            ORDNDS    R        B  3 18REFFLD(ORDN)                        
A  60                                  ERRMSGID(MSG0001 MYMSGF  60)      
A  61                                  ERRMSG('Order number outside range' 61)
A  62                                  ERRMSGID(CPF9898 QCPFMSG 62 &MTXT)

A            MTXT          78   P      

another method is the old s/36 way - this is quite flexible but will only show 1 message at a time but has the advantage of not locking the screen and again only requires 1 error indicator per screen field.

A            MSGID          7A  H                                      
A            MSG           78A  O 24  2MSGID(&MSGID MYMSGF)          
A                                      DSPATR(HI)                      

There are probably many more ways.

I wold go via the message subfile way - it may take a bit longer to master but it is well worth the effort (you can also access the second level help as per as/400 messages).

LVL 16

Expert Comment

by:theo kouwenhoven
ID: 11003176
hi mayankgangrade,

Most of the given samples are only working for interactive programs.
If you like to do it also for batch programs, stick to the sample of Dave,
or just send an e-Mail in stead of a Message by the SNDDST command.

Have fun


Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question