CL Menu question

Posted on 2006-06-09
Last Modified: 2008-02-26
I have a small CL program that extracts records from a journal file based on a start date and an end date.  I pass these two values to the CL when I call the program.  How can I do this from a display file?  I am going nuts trying to find any examples of doing this,  all I can find are examples of menus to pass a numbered option.  

I am offering 500 points because I've got to get this done in the next couple of days.
Question by:dhenderson12
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
  • 5
  • 5

Author Comment

ID: 16873104
Another option would be to prompt the user for these two values, if I can do that with CL.
LVL 13

Expert Comment

ID: 16873492

One way to handle this is to use selective prompting characters on a command.
The selective prompting characters are:
      ??  => show the keyword, allow the parm to be changed
      ?*  => show keyword, do not allow change
      ?-  => do not show show the keyword
As an example, cut and paste this command to create a physical file in qtemp:
? CRTPF ?*FILE(QTEMP/A) ??RCDLEN(132) ?-TEXT('temporary file')
The file name is shown, but cannot be changed.
The record length is shown and can be changed.
The text is not shown.
You could apply this to the DSPJRN command in your CL.

You could also create a simple menu by using STRSDA to design a menu. Then you can design the screen and then specify the commands that run behind a given menu option. If you want to go this direction and need more details, please post back.


Author Comment

ID: 16874749
Will STRSDA let me create a menu like this?

Enter the Start Date and press Enter.

Start Date: _________  (mm/dd/yyyy)

F3 Exit

This is the type of menu I'm trying to create.

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 13

Accepted Solution

_b_h earned 500 total points
ID: 16875221
You might to learn a little Screen Design Aid (SDA) for the future. I created an example that shows the output of SDA to get you started.

This source is for a display file designed in SDA:
*************** Beginning of data **************************************************
     A*%%TS  SD  20060609  223159  BH         REL-V4R2M0  5769-PW1                
     A                                      DSPSIZ(24 80 *DS3)                      
     A          R MENUFM                                                            
     A*%%TS  SD  20060609  223159  BH         REL-V4R2M0  5769-PW1                
     A                                      CF03(03)                                
     A                                  1  2DATE                                    
     A                                      EDTCDE(Y)                              
     A                                  1 14TIME                                    
     A                                  1 29'My First Menu'                        
     A                                      DSPATR(UL)                              
     A                                  1 57SYSNAME                                
     A                                  7  9'Enter the Start Date and press Ent-    
     A                                      er'                                    
     A                                 10  9'Start Date:'                          
     A            SDATE          8S 0B 10 23                                        
     A                                 10 35'(mm/dd/yyyy)'                          
****************** End of data *****************************************************
Copy this into a QDSSSRC file, member name DATESCREEN, with type DSPF
You create the display file using option 14 in WRKMBRPDM, or the CRTDSPF command.
The numbers in front of each line are the row and column of the field.
You can play around with SDA by using option 17 from WRKMBRPDM to change the screen. It may be a bit confusing at first, but will be worth it if you do other programming.

This is a simple CL to use the above screen:
*************** Beginning of data **********************************************
             /* DECLARE THE DISPLAY */                                          
             DCLF DATESCREEN                                                    
             /* CHECK IF F3 WAS PRESSED TO EXIT   */                            
             IF         COND(&IN03 = '1') THEN(DO)                              
             GOTO       CMDLBL(ENDPGM)                                          
             /* INSERT OTHER LOGIC HERE, SUCH AS DATE EDIT */                  
             IF (&SDATE *NE 0) THEN(DO)                                        
             /* IN VARIABLE NAMED SDATE FROM THE DISPLAY FILE       */          
****************** End of data *************************************************Copy this source to a QCLSRC file, member name DATEMENU, of type CLP
Compile it using option 14 from WRKMBRPDM, or the CRTCLPGM command
Make sure your library list contains the library where the display file is.

To run the program:

Post back any questions!

Author Comment

ID: 16878520
ok, I created the two files.  The display compiled without problem, but the cl file failed to compile saying that &IN03 and &SDATE were referenced but not declared, and that the display file could not be found.  I added the library to my library list and even modified the line to read  "DCLF   DAN/DATESCREEN".  

I don't know if it should make a difference, but I'm using V5R3.  I really appreciate all your help.  I'm trying to find a redbook that helps with display files but haven't had any luck (I seem to batting 0 at this point).  Any guidance is appreciated.
LVL 13

Expert Comment

ID: 16878687
Did the display file compile to DAN/DATESCREEN? Please confirm by using:
Adding the library qualifier on the DCLF should have worked. The undeclared variables error will go away when the CL compiler finds the display file.

I will test the code on V5R3 to confirm that it works there. I created it on a lower level box.

You can find the DDS (Data description specifications) for Display files in the Infocenter at:
Infocenter, then Programming, then DDS, then Display Files

There is a manual for Screen Design Aid there as well:
Infocenter, then Programming, then Development Tools, then ADTS, then ADTS for AS/400: Screen Design Aid
Help is available inside SDA as well.


Author Comment

ID: 16878860
Yes, it is there with the attribute DSPF.

LVL 13

Expert Comment

ID: 16878891
So display file DAN/DATESCREEN is there, and the CL has DCLF DAN/DATESCREEN, yet the CL compiler does not find it....hmmm
Can you email the compile listing to the email address in my profile? I am not sure what is causing this.

Author Comment

ID: 16878957
OK, I'm a moron.  I created the cl as cl, not clp.  I deleted the original file, created a new file as clp, and it compiles and runs like it should.

One last question:
I noticed that the input field only accepts numbers.  How should I go about formatting the input for nn/nn/nnnn?  I found the documentation on display files at the IBM site and I have just started reading it.
LVL 13

Expert Comment

ID: 16879289
To allow SDATE to be a date in mm/dd/yyyy format, compare this section of code with the display file above:
     A                                 10  9'START DATE:'        
     A            SDATE           L  B 10 23                      
     A                                      DATFMT(*USA)          
     A                                 10 35'(MM/DD/YYYY)'        
Note that SDATE will now be 10 characters instead of 8 numeric.

Thanks for the grade and the points.....and no, you're not a moron.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

734 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