RPG: The ENTER Statement

If you use Report Generator (RPG), you may not know about the super-powerful ENTER statement. If you don’t use RPG, this might whet your appetite!

ENTER prompts for a variable – like a date or customer number -- when you run a report. You can even use ENTER to let the user decide where to output a report – to the screen or to a different output device.

Here’s a report specification based on the sample #FILES and data supplied in the QCD directory on your system; an explanation of each report line follows:

   10000 LOG TERMINAL,,ERRORS
   10100 DICTIONARY QCD
   10200 INPUT EMPLOYEE.MASTER 
   10300 ENTER YOURDEV,LENGTH=5,PROMPT=' Enter output device:' 
   10400 IFDEF YOURDEV EQ ''
   10500       DEFINE OUT=SYS.TERM$;5
   10600 ELSEDEF
   10700       DEFINE OUT= YOURDEV;5
   10800 ENDDEF 
   10900 PRINTER OUT
   11000 PRINT EMPLOYEE.NUMBER
   11100 RUN MENU 
10000 The LOG command specifies where report processing messages are displayed; TERMINAL displays them on the screen and ERRORS limits the messages to errors only
10100 The DICTIONARY command specifies what #FILES to use; QCD is the sample directory provided with Report Generator
10200 The INPUT command specifies the primary file to use.
10300 The ENTER command asks for some piece of information when the report is run; PROMPT tells RPG what to display to the user. So, when this report is run, RPG prompts:
Enter output device:

10400
to 10800

These lines are an introduction to using IF statements. If the user doesn’t enter an output device, the report is displayed on the screen. If they do enter one, like a spooler or printer, it is used. Line 10500 uses a system variable. System variables can also provide the current date or other data.
10900 The PRINTER command tells RPG where to send report output; here, it uses information developed by the IF statement
11000 The PRINT command specifies the data to output
11100 The RUN command RPG what to run when the report is complete.

You can set up PowerShift menus to allow users to run an RPG report, enter data that the report prompts for, and then return to PowerShift. Great examples of variables to prompt for are beginning and ending dates or ranges of order numbers, customer numbers, etc.
Hint! If you always want to run a report based on the current date or the beginning and ending dates for the current month, you don’t even need to prompt the user! Simply use the system date to calculate the needed dates.

Learn more about the Report Generator statements used above (and others!) through its online help. Simply run *REPORTS and press F1. Be sure to check out Appendix E, Tips and Tricks -- it provides sample specifications that email reports and direct output to different file formats.

Report Generator is a tremendously powerful tool! Contact the Qantel Helpdesk or call us at 630.300.6999 to schedule an introductory webinar to learn about it or in-depth training class to hone your skills.