• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Guru Odds and Ends: Readers Respond

    April 30, 2018 Ted Holt

    I appreciate the comments and feedback that readers have contributed. Some of you sent it my way via the Contact page at IT Jungle. Others emailed me directly. Yet others left comments at the end of the articles themselves. I am always grateful for your knowledge and wisdom, however I receive it.

    Knowing that you are very busy and don’t have time to revisit the articles we have published, I’ve collected some of that feedback for your edification. Please feel free to add to the body of knowledge.


    Had to chuckle when I read Sorting Options For CPYTOIMPF, Ted. Your “wonderful utility” is my bête noire! I hate it with a passion. It is the reason why the very first Open Access handler I ever wrote was to produce CSVs directly — so I could avoid it!

    — Jon

    Bête noire? À chacun son goût!


    I had many interactive programs using GOTO to control program navigation (I supported a help screen and many command key functions) and finally wrote a program to strip out the GOTOs. IMO, the resulting programs are harder to follow unless your source is carefully and consistently indented, which means you’re using RDi. (And if not, why?) If you use GOTO for calculation loops, you’re not a programmer or even a good coder – you’re a very bad coder.

    I believe a “proper program” has a single entry point and a single exit point. So, peppering your code with RETURNs may be convenient but it’s not a best practice. Finally, IBM has addressed the issue!

    My solution has been to put my exit code in a subroutine within the procedure. It appears to work fine.

    — Reeve

    Reeve wasn’t the only one to suggest putting an exit subroutine in a subprocedure. Good idea, but obsolete now! Here’s another one:

    I, too, am looking forward to using ON-EXIT. I was intrigued with your “last legitimate use of GOTO” concept. I know that it’s water under the bridge, but I would have gone with a “the last legitimate use of EXSR” concept. The subroutine to that procedure would have all the local variables available to it and the RETURN could be performed in it. It could have all been written in free format.

    I remember when a new release came out, it was like Christmas Day. Opening the box and going straight to the RPG manual, we couldn’t wait to start using the new op codes and features. Our software vendor still generates code at 6.1, so I feel like I’m a bit behind because I’m not actively using full free format. There’s a surfer term for a person who acts and dresses like a surfer, but doesn’t surf. It’s a hodad (hoe-dad). I feel like an ILE hodad at times.

    — Matt


    Thanks for writing The Three Ways To Insert. I had never seen the use of a data structure in an update statement. I will add it to my tool box and make sure to use it.

    — Ken

    Why the seemingly random assignment of the ID column for the last three rows of your sample table? Wouldn’t this typically be auto-generated?

    — Andy

    It depends on requirements, Andy. If the ID is a meaningless value, such as a surrogate key, then you could have the computer generate it. But if it is an identifier that the corporate office assigns, then you must specify the values.

    In this imaginary scenario, we can pretend that corporate has selected those warehouse ID’s for historical reasons. That is, those are the ID numbers that everyone who works in those warehouses is used to, and also the IDs used as foreign keys in the data that comes from those systems. I thought this example was less complicated with assigned IDs than it would have been with generated ones.


    The easiest way to Remove Unwanted Trailing Blanks With LPEX — type a blank in the source and press CTRL+S.

    –– Peder

    Thanks for that information, Peder. Now we have two ways to get rid of those annoying blanks.


    Regarding Faster Fetching, Revisited: When I first started using SQL embedded in RPG code, I was not a big fan of reading a record at a time. So I quickly learned about fetching multi-rows. Not only is it faster, it seems much easier to process. I usually do the fetch into a multiple-occurrence data structure with an eternally-described data structure when I need most of the data in a file. This makes coding easier for me. I will keep using this tried and proven method.

    — Al

    I don’t think using a MODS is a bad way or a wrong way. The data structure array is newer in RPG, and I think the syntax is easier. But if I understand correctly, one way is as good as another.


    Regarding SQL Facts of UNION and ORDER BY: For Fact 7, you can use the union as a sub-query to allow the use of an expression for the ordering. An extra layer, but it gives you the result you are looking for.

    — S Sims

    select * from 
       (select . . . 
        union all
        select . . . ) as b
    order by
       case when state = ‘MN’
          then 0 else 1 end
    

    Thanks, S Sims. You’re right, and I didn’t think of that technique when I was writing the article. I just wanted to point out a place where expressions would not work. But I’m glad you mentioned it, because that was the technique I needed for a project I was working on at the moment.

    For more ideas on this topic, see the comments of illustrious thinkers Rob Berendt and Birgitta Hauser at the end of SQL Facts Of UNION And ORDER BY, Take Two.


    In response to SQL Table Functions Can Do Non-function Things, readers were kind to point out that I had reinvented the wheel yet again.

    Thanks for the kind words. Building these services into DB2 for i is fun for us because we get a lot of warm feedback from clients. For the topic of library list, you could also consider using QSYS2.LIBRARY_LIST_INFO. We even return the full SQL schema name, should it exist.

    https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzajq/rzajqviewliblinfo.htm

    — Scott Forstie, IBM

    To see my library list from Run SQL Scripts I do this:

    SELECT * FROM QSYS2.LIBLIST

    –Rusty

    LIBLIST is an alternate name for LIBRARY_LIST_INFO.

    It’s good that I wrote this utility. I work on a lot of systems, and soon came across two that did not have LIBRARY_LIST_INFO. All’s well that ends well.


    Readers left two good comments in response to Susan Gantner’s article, Confessions Of A Recovering RDi Outline Addict.

    I use the Fast View a lot as well, but when I find I am using the outline more frequently than normal I pull it out (I think the term for it is Detach) and stick it on my second monitor. Thanks for the tip on hiding the unreferenced definitions! I didn’t know that one and it will save a lot of time!

    — Steve

    I, too, love Outline view, and have spent a lot of time working out how to get the most out of it. F3 for Open Declaration is a particular favourite so I am glad you mentioned it – but did you know that there is another, often-faster way to invoke it than F3 or right-click menu? If you hold Ctrl and then mouse-over the name, the name becomes a hyperlink. A left-click without releasing Ctrl will then Open Declaration. Annoyingly Ctrl+Left-Click on its own won’t do it, there must be mouse movement after holding Ctrl and before left-clicking.

    — Jamie.


    That’s enough for today. I’ll cover more feedback and follow up some other time.

    Thanks to all who contributed. Your comments improve these articles, and that improves the lives of your fellow readers.

    RELATED STORIES

    Sorting Options For CPYTOIMPF

    Eliminate The Legitimate Use Of GOTO, Take Two

    The Three Ways To Insert

    Remove Unwanted Trailing Blanks With LPEX

    Faster Fetching, Revisited

    SQL Facts of UNION and ORDER BY

    SQL Facts Of UNION And ORDER BY, Take Two

    SQL Table Functions Can Do Non-function Things

    Confessions Of A Recovering RDi Outline Addict

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: 400guru, FHG, Four Hundred Guru, IBM i, RPG

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Multiple Security Vulnerabilities Reported In IBM i Sundry IBM Announcements For Power Systems

    One thought on “Guru Odds and Ends: Readers Respond”

    • Jamie says:
      April 30, 2018 at 6:01 am

      Thank you for including my comment about Ctrl+Left-Click for Open Declaration in RDi.
      However as of RDi 9.6, it no longer works. Instead when you mouse over and get the new detailed tooltip, that tooltip already includes hyperlinks to the definitions. And in the case of nested DS’s, it includes a hyperlink to every parent DS definition too.

      Reply

    Leave a Reply Cancel reply

TFH Volume: 28 Issue: 32

This Issue Sponsored By

  • ASNA
  • COMMON
  • ARCAD Software
  • Software Concepts
  • WorksRight Software

Table of Contents

  • Goodbye, Java Enterprise Edition. Hello, Jakarta EE
  • Sundry IBM Announcements For Power Systems
  • Guru Odds and Ends: Readers Respond
  • Multiple Security Vulnerabilities Reported In IBM i
  • IBM i PTF Guide, Volume 20, Number 16

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle