• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Odds and Ends

    November 8, 2002 Timothy Prickett Morgan

    Dear Readers:

    Here, by popular demand, are more “Odds and Ends.” I hope you find something here you like.

    — Ted

    Question:

    I’m trying to read a table by key in a CL program, and I am having trouble. I know there has to be a way to do this, but I keep getting either the first record in the table or an error message that states ‘key not found.’ Can you provide an example of a CL program that reads a file randomly by key?

    Answer:

    It sounds as if the Receive File (RCVF) command didn’t find a matching key. I suggest you use *KEYAE instead of *KEY on the Override with Database (OVRDBF) command. Then after you RCVF, use an IF to make sure you got the record you wanted. I have seen some weird stuff happen when using *KEY:

    In the following example, the program attempts to read a record whose key value matches the value in &PCAT. When a record is read, its key field, &CATEG, is compared to &PCAT to see if the proper record was found.

    PGM        PARM(&PCAT) 
    
    DCL        VAR(&PCAT) TYPE(*CHAR) LEN(2) 
    DCLF       FILE(CATEGORIES) 
    
    OVRDBF     FILE(CATEGORIES) POSITION(*KEYAE 1 *N &PCAT)
    RCVF 
    MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(EOF))
    
    IF         COND(&CATCODE *EQ &PCAT) THEN(DO)
    /* a matching key was found -- do whatever */
    ENDDO
    

    Question:

    Work with User Profiles (WRKUSRPRF) command will not load a list of user profile names into a database file. Is there some other way to do this?

    Answer:

    Use the Display Object Description (DSPOBJD) command. I think a lot of us forget this command exists, since so many object-specific commands have *OUTFILE capabilities:

    DSPOBJD OBJ(*ALL) +
       OBJTYPE(*USRPRF) +
       OUTPUT(*OUTFILE) +
       OUTFILE(QTEMP/X)
    

    Question:

    I am entering two 130-byte note fields on a screen and then using them as parameters on a Submit Job (SBMJOB) command. The system throws away the trailing blanks and appends the following fields to them. Do you know why this happens and how to fix this problem?

    Answer:

    The problem is that you are using a variable that is longer than 32 bytes as a parameter to a CALL command in the CMD parameter of the SBMJOB command. The system discards the trailing blanks. There are several ways to solve this problem, but the easiest one is to pass one extra non-blank byte. In your case, pass two 131-byte values and make sure the last byte of each one in not blank. Here’s an example:

    dcl   &msg     *char 130
    dcl   &msgparm *char 131
    
    chgvar &msgparm (&msg *cat 'X')
    
    sbmjob cmd(call somepgm (&msgparm))
    

    The called program will define the parameters as 130 bytes, as always, not 131 bytes.

    Question:

    I am trying to get this API to work, and I can’t get the receiver variable to work correctly. I know there is a trick to using API’s, but can’t remember it.

    d  InputData      ds
    d   BytesRet                     4b 0
    d   BytesAvail                   4b 0
    d   Outque                      10
     * .... some source code omitted 
    c                   call      'QSPROUTQ'
    c                   parm                    InputData
    c                   parm                    RecieverLength
    c                   parm                    FormatName
    c                   parm                    OutQueueName
    c                   parm                    ErrorCode
    

    Answer:

    This is a common mistake with APIs. The BytesRet, BytesAvail, and other binary variables are supposed to be four-byte integers. You have coded them as four-digit integers, which is not the same. This will solve your problem:

    d   BytesRet                     4i 0
    d   BytesAvail                   4i 0
    

    Question:

    We have a junior programmer who messed up an RPG Source member without using our change management system. He then tried to correct his own mistake and only proceeded to make things worse.

     

    My question is, can I restore a specified member from tape from the QRPGSRC file?  I know how to restore the whole library, but I really only need one member from the QRPGSRC File.

    Answer:

    Restore Object (RSTOBJ) command allows you to restore individual file members. You’ll need to use the FILEMBR parameter.

    RSTOBJ OBJ(QRPGSRC) +
       SAVLIB(saved-lib) +
       DEV(TAP01) + 
       OBJTYPE(*FILE) + 
       FILEMBR((QRPGSRC (member-name))) +
       RSTLIB(another-lib)
    

    I recommend you restore to another library, and then copy the restored member to the production library.

    — Ted

    Sponsored By
    ADVANCED SYSTEMS CONCEPTS

    Business Analytics
    – Practical –
    – Cost Effective –
    – Easy to Deploy –

    SEQUEL FYI

    User Quote:
    “I love SEQUEL FYI because it lets me look at the data any way I need to see it, instantly. This is the easiest tool to manage complex product relationships that I have ever seen.”

    SEQUEL FYI offers outstanding OLAP business intelligence functionality for a fraction of the cost of comparable solutions.

    Read More > View Streaming Video

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 86 -- November 8, 2002

    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

    Reader Feedback and Insights: Overlooking the Obvious Omitting Parameters in RPG Programs and Modules

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 86

This Issue Sponsored By

    Table of Contents

    • Reader Feedback and Insights: Overlooking the Obvious
    • Odds and Ends
    • Omitting Parameters in RPG Programs and Modules

    Content archive

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

    Recent Posts

    • Q&A With IBM’s New GM Of Power, Hillery Hunter
    • When IBM i Skills Become A Resilience Risk
    • Guru: Load A Varying-Dimension Array With One SQL Fetch
    • You Have To Speak IBM’s Language If You Want To Be Heard
    • Raz-Lee Revs iSecurity Suite With 2026 Updates
    • The Big Easy: Connecting The Dots On Big Blue’s AI Strategy For IBM i
    • From Migration To Maturity: The Cloud Reality For IBM i Shops
    • COMMON Dances To A Fresh New Tune In New Orleans
    • Eradani Touts Native Git Connection As AI Tools Spread
    • IBM i PTF Guide, Volume 28, Number 17

    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