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

    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

  • EvolveWare Makes Progress With RPG Code Modernization Using AI
  • Why The IBM i Market Needed Another VTL Option
  • What Price Power?
  • Cloud Revenues Saved By The GenAI Boom
  • IBM i PTF Guide, Volume 27, Number 44
  • Power Systems Grows Nicely In Q3, Looks To Grow For All 2025, Too
  • Beta Of MCP Server Opens Up IBM i For Agentic AI
  • Sundry IBM i And Power Stack Announcements For Your Consideration
  • Please Take The IBM i Marketplace Survey
  • IBM i PTF Guide, Volume 27, Number 43

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