CL Menu question

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.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

_b_hConnect With a Mentor Commented:
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!
dhenderson12Author Commented:
Another option would be to prompt the user for these two values, if I can do that with CL.

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.

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

dhenderson12Author Commented:
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.

dhenderson12Author Commented:
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.
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.

dhenderson12Author Commented:
Yes, it is there with the attribute DSPF.

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.
dhenderson12Author Commented:
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.
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.

All Courses

From novice to tech pro — start learning today.