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
  • 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.

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.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now