End-of-Year Odds and Ends
December 14, 2011 Ted Holt
It’s hard to believe that another year is coming to an end, but it’s happening yet again. Let’s wind up 2012 with some odds and ends. I hope you find something useful.
In response to Message Received, But Not Understood, Michael wrote:
I have used the CMPDTA parameter on the MONMSG command to provide this filter. See CPF2817.
Here is an illustration of Michael’s suggestion:
CPYF FROMFILE(&FRLIB/&FRFILE) + TOFILE(&TOLIB/&TOFILE) FROMMBR(&FRMBR) + TOMBR(&TOMBR) MBROPT(*REPLACE) CRTFILE(*NO) MONMSG MSGID(CPF2817) CMPDTA(CPF2861) EXEC(DO) /* to-file doesn't exist */ /* do something */ ENDDO MONMSG MSGID(CPF2817) CMPDTA(CPF2869) EXEC(DO) /* from-file is empty */ /* do something */ ENDDO MONMSG MSGID(CPF2817) EXEC(DO) /* catch all */ /* do something */ ENDDO
It is true that the message data of CPF2817 contains the ID of the diagnostic message that tells why CPYF failed, but putting the ID of a diagnostic message in the first seven bytes of the message data of an escape message is not a convention of IBM i. Since looking at the comparison data works for CPF2817, there’s no reason not to use that technique in this case. I think the RCVMSG technique I published is better because it works in all situations.
In response to VALUES: A Truly Useless DDS Keyword, Skip Marchesani wrote:
Just in case you are not aware, you can also use ALTER TABLE on the physical file created using DDS to add the check constraint to the PF.
Thanks for letting me know, Skip. I was not aware.
Faithful reader Duane wrote:
Maybe when you are looking for something to write about, you could give us a refresher on the difference between CA and CF command keys. There are still people who use display files and not a GUI.
Duane had written earlier, asking why he was having a certain problem with a display file. In a certain case, the data that he had entered into an input field was being lost. The problem turned out to be that he had defined the F2 key as CA02, not CF02.
I have always used CF unless I had a reason to use CA. The only time that CF has not worked for me is when I was using validity-checking keywords, such as COMP and RANGE, and did not want to save data when bailing out of a screen. CA ignores validity-checking, but CF requires that keyed data be valid, even if you don’t intend to do anything with the keyed data. Let me illustrate.
Here’s a display file.
A DSPSIZ(24 80 *DS3) A R SCREEN01 A CF03(03) A 1 35'Some Screen' A COLOR(WHT) A 3 5'Type something:' A SOMETHING 8 I 3 21 A RANGE('A' 'B99999') A 5 5'Or press F3 to exit.'
Here’s a CL program to drive it.
pgm dclf qad3090d dountil &in03 sndrcvf rcdfmt(screen01) enddo endpgm
If you call this program and press F3 without keying anything, the program will shut down. However, if you key anything at all, the system will check the validity of the data, and if whatever you keyed (even if you only keyed blanks) does not fit in the specified range, the program will not end.
Whenever you want to exit a screen without saving any of the keyed data, use CA, not CF.
On December 2, Mike wrote:
I just wanted to let you know that I was looking for a way to pass parameters to RUNSQLSTM. I found your article, and it’s EXACTLY what I needed! Thank you so much! The sed example was especially helpful. I’m not a Unix guy, so it would have taken me days to figure out on my own. You guys are a great resource.
It was good of Mike to write, since the article to which he refers was published in 2002. That’s over nine years ago! I am proud of the amount of material we’ve built up over the past 10 years. I frequently Google for tips that I’ve run when I can’t remember how to do something or when someone asks me a question that I know we’ve answered.
In response to Wow! I Could Have Had Long Column Names!, Richard wrote:
I did know the aliases, but it was news to me that IBM i had a free built-in graphical debugger. No, not the Rational one, but a free, built-in debugger. You could have knocked me down with a feather, as they say. Anyway, if it’s news to you or not, there is a lovely article on the Developerworks i microsite here. Enjoy!
We’ve not written a lot about that debugger, Richard, and I much prefer it to the green-screen debuggers. Kevin Vandever wrote about the graphical debugger in 2003 in the old Midrange Programmer newsletter. (See The Java-Based iSeries System Debugger. We really should write more about it. Does anybody out there have some good tips for the graphical debugger?
I’d like to end with a personal note. After all, anything fits in an odds-and-ends article, right?
It’s been a hard year for the Holts. As if the everyday challenges of being an IT manager and raising teenagers weren’t enough, both my wife and I had serious medical problems. While I was trying to deal with all this drama, someone whom I had never harmed decided to send out spam that appeared to come from the contact page of www.itjungle.com. Gmail picked up spam and decided that anything from that email address, including your correspondence, was unworthy of my attention. I noticed that the volume of email coming from readers had dropped, but with so much real life going on, I didn’t think to look into it.
On December 7, I discovered that your responses were going to my spam folder. I don’t know how long it had been going on. Talk about kicking a guy when he’s down. I felt heartbroken, because I really do appreciate and look forward to your comments, questions, and feedback. (Those of you who never hear back from me may find that a little hard to believe. I don’t blame you.)
Your email is what keeps this newsletter going. I can’t answer all the questions I receive. I try to find other people to answer the ones I can’t answer, but that doesn’t always work out. But I can find answers to enough questions to fill Four Hundred Guru twice a week, which is sufficient.
So, if you’ve sent me a question within the past few months, didn’t hear back from me, and still need some help, please send your question again. I will do my best to help as many people as I can, and if I can publish your question and the answer to it, your fellow professionals will benefit as well.
I wish all of you the merriest of Christmases (or whatever holiday you celebrate). May 2012 be the best year ever for all of us.