AS400 Mid Range/How to create a display file
Expert: Concise Systems/Laird Scranton - 11/1/2000
QuestionMy AS400 mod 720 has RPGIV on it. I am trying to create a CL program that will use a display file to ask the user for parameters. And then pass the parameters to a SQL query to create a simple report. I don`t know how to create the display file or maybe there is a better way to do it. Any help will be appreciated.
AnswerRoy - I apologize for the lateness of my answer to you - I was called away on a family health emergency and am now just getting to my e-mail.
It's not really pratical to give you an adequate tutorial here on creating a display file, but here's a start:
As an example, let's assume that you are creating a display file called DISPLAY in a library called TEST. You will need to create a QDDSSRC source file in TEST library with the CRTSRCPF command.
From the QPGMMENU programmers menu, select option 9 (Design display format using SDA) then press ENTER. Then select option 1 (Design screens). Fill in the requested options as shown below, then press ENTER.
Source file.....QDDSSRC
Library.......TEST
Member..........DISPLAY
On the "Work with Display Records" screen, select option 1 to add a record format, which we will call PROMPT, then press ENTER. You will see the "Add New Record" prompt. Press ENTER. You will now be presented with a blank screen on which to design your input fields and literals. To add a literal, key the literal within single quotes in the spot you want it to appear, then press enter. Example:
'This is the first literal:'
To add an alphameric parameter field, key a plus sign (+), followed by a lower-case B (b) - one for each character of the field, then press ENTER. An example of a seven-character alphameric field would be:
+bbbbbbb
To enter the field name associated with the field, key a question mark (?) in front of the field, then press ENTER. A prompt will apepar for the field name, length and text.
Since you want to use these parameter fields as variables in a sequel command, it may be best to define them all as alphameric.
To move field left or right on the screen, key the character < or > to the left or right of the field, then press enter. To move it more than one space, use more than one < or >. To delete a field, key a D in front of the field and press ENTER. There are many other move-type options available in an SDA manual.
When the screen appears as you want it, press CMD 3. Select option 1 to save the work and press ENTER. On the "Work with Display Records screen, press CMD 3. On the "Save DDS - Create Display File screen, key any text information needed to describe the display file, then press ENTER. The screen format will automatically compile.
In the CL program, you'll need at least the following two lines. The first one declares the display file to the CL program. The second one executes the display format:
DCLF DISPLAY
EXFMT
The field names from the display file are available in the CL program with an ampershend preceding the field name. Example:
PARM01 (in the display file) is know as
&PARM01 to the CL program.
You should not declare &PARM01 in the CL program - it will already know the definition of each field from the display file when you compile the CL program.
Some QUERY and SQL statements will accept actual field names as parameters, some may not.
I hope that gets you started!
Laird Scranton
Concise Systems