• 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
    Rocket Software

    Introducing Rocket Software’s Solutions for IBM®i: Ignite Your Business Potential!

    Unlock the true power of your IBM® i platform with Rocket Software’s cutting-edge solutions. Embrace innovation and streamline operations with our comprehensive tools to propel your business forward.

    Explore Rocket Software Application Modernization solutions to learn how you can optimize your IBM i infrastructure to deliver enhanced user and developer experiences from a modern, agile environment:

    • Rocket DevOps: Simplify compliance reporting and user access to critical systems.
    • Rocket Process Insights: Build a data-informed, smart modernization plan with bottom-line results.
    • Rocket API: Unlock critical data and deliver fast ROI with robotic process Automation (RPA) for IBM i.
    • Rocket Modern Experience: Modernize UI/UX application for productive outcomes.
    • Rocket iCluster: Ensure uninterrupted operation for your IBM i applications.
    • Rocket Terminal Emulator: Access host-based systems from browsers or mobile devices.
    • Rocket MFA: Build a layered defense against password vulnerabilities.

    Modernization. Without Disruption.
    Rocket Software

    Learn more

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Use the Full-Screen Debugger with OPM Programs Reader Feedback and Insights: Modernizing RPG II Programs

    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

    • Shield Builds on Success with Nagios for IBM i
    • Why You Should Be Concerned About the MGM ‘Vishing’ Attack
    • IBM Bolsters Database Security with Guardium 12.0
    • Four Hundred Monitor, September 27
    • The IBM i Marketplace Survey Needs Your Input
    • Rocket DevOps Now Supports VS Code
    • DR Testing As A Service: One More Thing That You Don’t Have To Do
    • The First Step In DevOps Is Not Tools, But Culture Change
    • As I See It: IT Come Home
    • IBM i PTF Guide, Volume 25, Number 39

    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 © 2023 IT Jungle