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

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    Sponsored by
    Lightedge

    Your IBM Power Cloud Strategy Should Start With “Why?”

    Moving IBM i to the cloud isn’t just an infrastructure decision.

    A hardware refresh, data center exit, IBM i skills gap, disaster recovery requirement, or broader cloud initiative can each lead to a very different architecture.

    At Lightedge, we start by understanding what you’re trying to accomplish. Then we look at the workload, application dependencies, resiliency requirements, operating model, and long-term strategy to determine where that workload belongs.

    Managed IBM Power cloud? IBM Power Virtual Server? DR in the cloud? A hybrid architecture connecting IBM Power with AWS or Azure?

    There isn’t one right answer for every IBM i environment.

    Start with the business requirement. Understand the workload. Then decide where it belongs.

    Explore IBM Power cloud, managed services, and hybrid solutions from Lightedge.

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) 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 So That’s What My Database Looks Like

    Leave a ReplyCancel 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

  • IBM i PTF Guide, Volume 28, Number 34
  • It Is Time Once Again To Take The IBM i Marketplace Survey
  • PHP’s Evolution On The IBM i Platform Continues
  • Protecting IBM i Data For The AI Revolution
  • Guru: Two More Small But Handy RPG Enhancements: LIKE(*EXT) And %LOOKUPNE
  • IBM i Integration Gives Costco Shoppers Real-Time Inventory
  • IBM i PTF Guide, Volume 28, Number 33
  • IBM “Price Harmonization” Increases For Power Systems Coming In The New Year
  • Code For i Continues To Grow. Here Is What’s New
  • PowerSC: Your One-Stop Shop For Security On IBM i – And Beyond

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