|
||||||||
|
|
![]() |
|
|
|
|
||
|
Odds and Ends Dear Readers: To end the year 2003, here are some miscellaneous tips. I hope you find something useful. Even more, I hope that 2004 will be the best year ever for all of us. --Ted Question: I am trying to avoid the output from the RUNSQLSTM command. I searched on the Internet and found your issue from October 5, 2001. I execute the RUNSQLSTM from within a CL ILE program. I have created the output queue and put the OVRPRTF before the RUNSQLSTM, but the problem is that RUNSQLSTM outputs to a file whose name is that of the source member. If you look for that file, you find it does not exist, so I think that processing of the command involves some kind of override. Answer: You have an override problem, but not because the spool file bears the same name as the SQL source member. Look at the report that is produced when RUNSQLSTM runs and you will see that the system is using printer file QSYSPRT. The problem is that your program is an ILE program, but program QSYS/QSQCHEM, the command-processing program for the RUNSQLSTM command, is an OPM program. When you mix ILE and OPM programs, you have to account for the differences in activation groups. You did not tell me what activation group your program was compiled to run in, but it's obviously something other than the default activation group. To fix your problem, you need to make your ILE program issue the type of override that an OPM program would issue. You do this by adding parameter OVRSCOPE(*CALLLVL) to the override in your ILE CL program. OVRPRTF QSYSPRT OUTQ(QUSRSYS/GARBAGE) OVRSCOPE(*CALLLVL) Question: There is a way to force the user to press F3 or F12 to exit PDM. I have seen it done. Can you tell me how? Answer: Within PDM, press F18 to display the defaults. Scroll to the second display and change the Exit Lists on Enter option to N. Question: What is the trick to reading a source physical file from an RPGLE program? I'm receiving an undefined record type message when I read in the first record. Answer: Describe the file internally; that is, use input specs or a data structure. The system won't check the record format name to make sure it matches the file your program was compiled against. I prefer to use a data structure rather than input specs. The source code begins in position 13 (the first 12 bytes are reserved for the sequence number and date). The following code snippets should help you get started.
Fsrcin if f 1024 disk usropn
D dsin ds 1024 qualified
D srcseq 6s 0
D srcdat 6s 0
D srcdta 1012a
C read srcin dsin
Notice that Factor 2 of the READ operation names the data structure into which the data is placed. For output, you can specify a data structure name in Factor 2 of the UPDATE and WRITE op codes. Question: How do I include deleted records when making a copy of a file? Answer: Specify FROMRCD(1) and COMPRESS(*NO) in the CPYF command. The FROMRCD parameter forces an arrival sequence copy. CPYF FROMFILE(A) TOFILE(B) FROMRCD(1) COMPRESS(*NO) Question: How do I force someone to key a numeric value into a Qshell script? Answer: In V5R2, you can use the declare utility to assign a data type to a variable. The following command declares n to be an integer variable. declare -i n If a user enters a value that does not fit the assigned data type, Qshell throws and error and sets the return code ($?) to 1. Question: I am trying to test the validity of a date in a free-format RPG specification, but it's not working. test(de) *usa0 %subst(s2NewOvr:1:8); The error says, "*RNF5507 30 a 037600 A semi-colon is not specified at the end of a free-format specification." Do you know what's wrong? Answer: What you're doing is logical, but is not allowed. The problem is that you've used a built-in function, %subst, in Factor 2. I know it appears that there is no Factor 2 in free-format RPG, but there is: It's a free-format Factor 2. Use EVAL to copy the data into a temporary variable. Test the variable. TempDate = %subst(s2NewOvr:1:8); test(de) *usa0 TempDate; Question: Why would I ever want to specify a value other than *NOMAX in the MAXPOS parameter of the Create Command (CRTCMD) command? Answer: Users will be forced to enter the keywords for parameters past the last one represented by the value in MAXPOS. That gives you the flexibility to insert new parameters in front of existing ones at a later time. A rule of thumb is to put the required parameters at the beginning of the command and make them keyword-optional, but put optional parameters at the end of the command and make them keyword-required. Keep in mind that that is just a rule of thumb. Question: I am new to the CODE editor and am having trouble doing things that seem so simple to me in SEU. Is it just me, or is CODE less intuitive? For example, how do you insert a new first line in a source member? If I put the cursor on the first line and press Enter, CODE inserts a new second line. This brings me to my Christmas wish list. I'd like Santa Claus to bring me a cross reference of SEU and CODE commands. Answer: CODE is definitely a different animal. I hesitate to compare it to SEU, since what seems so obvious when using SEU may be nothing more than having used that editor since the 1980s. Anyway, to answer your question, press the Escape key to move the cursor to the command entry box at the bottom of the screen. Type splitjoin and press Enter. Press Escape to return to the source member. I think a case could be made that this process is less intuitive than its SEU counterpart, but I wouldn’t give up on CODE. I like the Undo feature too much. By the way, when you get to the LPEX editor, you'll get to learn another set of commands. Instead of splitjoin, you'll type add before.
Editors: Howard Arner, Joe Hertvik, Ted Holt, David Morris,
Managing Editor: Shannon Pastore
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message. |
|
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |