I am trying to learn IBM RPG and rewrite a program for my employer. I need a way to see whether my variables are getting assigned to the values i expect them too but i dont know how to output something to my screen to just display the values. Is there a way to send a break message containing the variables in the RPG program, not the CL program? Thanks
4 Answers
There are several debuggers available to you which can not only show the contents of variables, but alter them as well. I prefer to use RDi as my editing environment, and the graphical debugger that comes with it is superb.
There are several green screen debuggers, documented here at the Midrange wiki. The IBM i command STRDBG is used for ILE programs (and OPM if they're compiled with OPTION(*SRCDBG)) and the STRISDB command is often used with older, OPM programs.

- 7,558
- 22
- 25
-
2If RDi (nor WDSC) isn't available, then a version of the [System i5 (graphical) Debugger](http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_61/rzamq/rzamqmain.htm?lang=en) can be used through System i Navigator and 'Run SQL scripts'. And if Navigator isn't available, the System i5 Debugger can be downloaded from the server and installed as a stand-alone on a PC. Both Navigator and the System i5 Debugger are free to use. – user2338816 Oct 03 '14 at 01:06
Use the display (DSPLY) op-code
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/rzasd/sc092508935.htm%23zzdsply
dsply 'Hello World';
dsply 'value is:' + %char(myNumber);
dsply myString;
//the above don't pause, you'll see the message pop up and go away,
// but it will be in the joblog. If you want to wait:
dsply myString '*EXT' myResponse;

- 21,637
- 1
- 20
- 44
-
1Buck makes a good point...depending on how much / often you're checking, using a debugger may be a better way to go. – Charles Sep 19 '14 at 19:38
The suggestion of a Debugger is the best one. I work in RPG400(pre ILE). For that, i can list the steps I use. Hopefully this might be a help if you arent doing ILE Or RPG4. I have an RPG program, ABRKR being called by ABROADC (the CL). Im going to debug ABRKR and NOT step thru the CL, I know that works. Disclaimer: Green screen programming coming.
- On the command line, type STRISDB & press F4
Type in the name of the program, library .....(yatta yatta)
Press ENTER to finish it up.... Im calling the ABROADC. Notice the Invoke Program
- Press ENTER to start the ball rolling
Once in the program, press F5 to Start stepping thru the program
you can step thru your code 1 line at a time by pressing F5
to check a variable value, position the cursor on the variable & press F11
Press ENTER or F12 to back out of the detail screen.
Press F3 to exit the debugger... OR ...
Position the cursor to any line you want, press F13 (shift F1) to jump to that line of code. If you found what you wanted & want the program to run to its end, just jump to the *INLR or LR indicator where you turn it on & press ENTER. The job will run to completion.
My apologies to everyone who hates fixed format, and old tech. I am making an effort to answer the question.

- 64
- 6
Charles almost get it.
With dsply just add a blank after de value and will pop up the message and will stay there until you hit enter!
dsply 'Hello World' ' ';
dsply 'value is:' + %char(myNumber) ' ';
dsply myString ' ';

- 724
- 4
- 11