• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Omitting Parameters in RPG Programs and Modules

    November 8, 2002 Timothy Prickett Morgan

    Hey, Ted:

    I have a program that can receive four parameters. The first one is mandatory, and the last three are optional. If I call the program and pass parameters 1, 2, and 4 to it, the %parms built-in function tells me that three parameters were passed. How does the program know which three it is getting? Thanks!

    — Doug

    You can’t skip a parameter. If you pass three parameters, they are parameters 1, 2, and 3; number 4 will be undefined.

    The only way to skip parameter 3 is to specify OPTIONS(*OMIT) in its D spec. The value *OMIT allows you to pass the special value *OMIT as a parameter value. OPTIONS(*OMIT) is only allowed with parameters that are passed by reference. That includes parameters with the CONST keyword, which are passed by read-only reference.

    You can use the *OMIT value along with *NOPASS, but to keep it simple; I do not include *NOPASS in the following example.

    Here is the RPG source code for RPG module OMITPARMEE (Omit Parameter Callee):

    D calledproc      pr                  extproc('OMITPARMEE') 
    D   p1                          10a   const                 
    D   p2                          12a   const                 
    D   p3                           6a   const options(*omit)  
    D   p4                           2a   const                 
                                                                
    D calledproc      pi                                        
    D   p1                          10a   const                 
    D   p2                          12a   const                 
    D   p3                           6a   const options(*omit)  
    D   p4                           2a   const                 
                                                                
    D somevalue       s              6                          
                                                                
    C                   if        %addr(p3) = *null             
    C                   eval      somevalue = *all'*'           
    C                   else                                    
    C                   eval      somevalue = p3                
    C                   endif  
    C                   return
    

    Notice that the third parameter has the OPTIONS(*OMIT) keyword. If the caller passes the special value *OMIT, the address of the parameter will be null. For that reason, the module checks for a null address and does not use the value of the third parameter if the address is null.

    Here is module OMITPARMER (Omit Parameter Caller):

    D calledproc      pr                  extproc('OMITPARMEE') 
    D   p1                          10a   const                 
    D   p2                          12a   const                 
    D   p3                           6a   const options(*omit)  
    D   p4                           2a   const                 
                                                                
     /free                                                      
         callp calledproc ('ABC': 'DEFG': 'HIJKLM': 'NO');      
         callp calledproc ('ABC': 'DEFG': *OMIT   : 'NO');      
         *inlr = *on;                                           
     /end-free                                                  
    

    Notice the *OMIT value in the second CALLP.

    — Ted

    Sponsored By
    inFORM DECISIONS

    ELIMINATE THE COSTS OF PRE-PRINTED FORMS, LABOR AND POSTAGE WITH
    inFORM Decisions iDocs™ ‘Suite’

    iSeries based e-Forms, e-Checks, e-Mail, e-FAX, and Document Retrieval from the Web are available as individual modules or as a complete e-Document processing ‘Suite’.

    Click to Download the Complete Suite or Individual Modules today
    www.inFORMDecisions.com

    or call (800) 858-5544

    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

    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

    • Public Preview For Watson Code Assistant for i Available Soon
    • COMMON Youth Movement Continues at POWERUp 2025
    • IBM Preserves Memory Investments Across Power10 And Power11
    • Eradani Uses AI For New EDI And API Service
    • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
    • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
    • Fresche Overhauls X-Analysis With Web UI, AI Smarts
    • Is It Time To Add The Rust Programming Language To IBM i?
    • Is IBM Going To Raise Prices On Power10 Expert Care?
    • IBM i PTF Guide, Volume 27, Number 20

    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