• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Tell Me About Your Exports

    July 30, 2008 Ted Holt

    I ran into an interesting situation recently. I was attempting to tie service program B to existing RPG program A, so that A could use some of the service program B’s routines. Guess what? Program A wouldn’t compile. The experience brings up a good point about procedure prototyping in RPG.

    To use a subprocedure requires a procedure prototype. The prototype defines the subprocedure’s interface–the list of parameters, how each parameter is defined, and so forth. RPG programmers commonly use the /COPY and /INCLUDE directives in order to include prototypes in the modules that need them. We have talked about this process before.

    If A is to use B’s subprocedures, then, A must have the prototypes of B’s subprocedures. However, A does not have to know about all of B’s subprocedures. The reason my program A wouldn’t compile is that A had too much information about B’s subprocedures.

    It turned out that only some of B’s subprocedures were exported. The others were for internal use within module B. However, the copybook contained prototypes for all of B’s subprocedures. A would not compile because it contained a subroutine that had the same name as one of B’s internal (non-exported) subprocedures.

    Here, then, is the moral to the story: The copybook for a module should include only prototypes for exported procedures. The prototypes for other procedures should be defined in the module source itself. In this way, other modules will not know about subprocedures that are for internal use only.

    Here’s an example. Module B has three subprocedures–Reverse, Proceed, and MoveIt. Two of them–Reverse and Proceed– are exported, so their prototypes are in a copybook called B in source physical file PROTOTYPES. However, the prototype for the MoveIt routine is included in the module’s source code, since MoveIt is for use only within the module.

       // *** member B, file QRPGLESRC
    
    H option(*srcstmt: *nodebugio) nomain
    
    D/copy prototypes,B
    
    D MoveIt          pr
    <...code omitted ...>
    
    P Reverse         b                   export
    <...code omitted ...>
    
    P Proceed         b                   export
    <...code omitted ...>
    
    P MoveIt          b      
    <...code omitted ...>
    

    The copy member–member B in source physical file PROTOTYPES–includes prototypes for Reverse and Proceed only.

       // *** member B, file PROTOTYPES
    
    D Reverse         pr
    <...code omitted ...>
    
    D Proceed         pr
    <...code omitted ...>
    

    Other modules won’t know that B includes a MoveIt subprocedure, therefore they will not choke if they have identifiers (subroutines, variables, etc.) named MoveIt.

    When I moved the prototype for the internal subprocedure out of the copybook and into the service program module’s source code, I was able to compile A. Program A is running with B’s subprocedures. Everything is copacetic.

    RELATED STORY

    Properly Placed Procedures



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Rocket Software

    Unlock the full potential of your data with Rocket Software. Our scalable solutions deliver AI-driven insights, seamless integration, and advanced compliance tools to transform your business. Discover how you can simplify data management, boost efficiency, and drive informed decisions.

    Learn more today.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    COMMON:  Join us at the Focus 2008 workshop conference, October 5 - 8, in San Francisco, California
    Bug Busters Software Engineering:  High availability software that won't break the bank
    Computer Keyes:  KeyesOverlay rapidly converts standard *SCS printer files into PDF documents

    IT Jungle Store Top Book Picks

    Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
    Getting Started with PHP for i5/OS: List Price, $59.95
    The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket Developers' Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    iSeries Express Web Implementer's Guide: List Price, $59.00
    Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    WebFacing Application Design and Development Guide: List Price, $55.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    The All-Everything Machine: List Price, $29.95
    Chip Wars: List Price, $29.95

    Mike Borman Lands the CEO Job at Avocent Q&A with IBM’s Ross Mauri: Talking Power Systems and Power7

    Leave a Reply Cancel reply

Volume 8, Number 28 -- July 30, 2008
THIS ISSUE SPONSORED BY:

WorksRight Software
Profound Logic Software
COMMON

Table of Contents

  • Tell Me About Your Exports
  • So That’s What My Database Looks Like
  • Admin Alert: Moving i5/OS Resources on the Fly

Content archive

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

Recent Posts

  • 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
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

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