|
Are you sure the records are not being selected? I insert a CPFRMQRYF command and then look in that file to see if it is empty or not. Sometimes my problem is that I didn't select the records I thought I selected, other times I have selected the right records and then inadvertently ignored my selection. The next step I do is to get something, anything, everything, selected. After that its just fiddlin'. Nothing is more frustrating than spending hours solving the wrong problem, eh? --------------------------------- Booth Martin http://www.martinvt.com --------------------------------- -------Original Message------- From: RPG programming on the AS400 / iSeries Date: 06/22/05 09:28:39 To: rpg400-l@xxxxxxxxxxxx Subject: OPNQRYF with variable key names Can anyone help? I have an RPG pgm that allows the user to select up to 3 sort fields for their data of 8 possible choices. I had thought the best way (and easiest to maintain) would be to use parameters for the KEYFLD that would just populate the names of the fields that define the sort. When the program runs, the OPNQRYF returns no records. Here is an example of what the statements look like in the CL pgm. OVRDBF FILE(SA0025WK) SHARE(*YES) IF COND((&OPT1 *NE '1') *AND (&OPT2 *NE '1') + *AND (&OPT3 *NE '1')) THEN(OPNQRYF + FILE((SA0025WK)) KEYFLD((&SFLD1) (&SFLD2) + (&SFLD3))) IF COND(&OPT1 *EQ '1') THEN(OPNQRYF + FILE((SA0025WK)) KEYFLD((&SFLD1 *DESCEND) + (&SFLD2) (&SFLD3))) When that didn't work, I created an RPG program (after seeing some suggestions to others problems) that would create the entire OPNQRYF and execute that statement. Once again, I didn't get any records when the following RPG program tried to read the file. When I debug the RPG pgm, the OPNQRYF statement looks perfect but still has problems. Is there something I am missing? Has anyone done something like this before? Here is the pgm that creates the OPNQRYF in RPG: D Length S 15P 5 D Command s 100 * d cmd1 S 33 * *************************************************************** c eval cmd1 = 'OPNQRYF FILE((SA0025WK)) KEYFLD((' c eval command = %trim(cmd1) + fld1 * c if opt1 = '1' c eval command = %trim(command) + ' *DESCEND' c endif * c if opt2 = ' ' c eval command = %trim(command) + '))' c else c eval command = %trim(command) + ') (' + fld2 c if opt2 = '1' c eval command = %trim(command) + ' *DESCEND' c endif c endif * c if opt3 = ' ' c if opt2 <> ' ' c eval command = %trim(command) + '))' c endif c else c eval command = %trim(command) + ') (' + fld3 c if opt3 = '1' c eval command = %trim(command) + ' *DESCEND' c endif c eval command = %trim(command) + '))' c endif * C Eval Length = %Size(Command) C Call 'QCMDEXC' 55 C Parm Command C Parm Length * c move *on *inlr c return *************************************************************** c *InzSr begsr * *********** c *entry plist c parm opt1 1 c parm opt2 1 c parm opt3 1 c parm fld1 6 c parm fld2 6 c parm fld3 6 * * c endsr Thanks for any advise that anyone has! Marla Snow msnow@xxxxxxxxxxxxxxxxxx -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. .
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.