Volume 8, Number 18 -- May 7, 2008

Accurate Program References

Published: May 7, 2008

by Ted Holt

I came across a situation recently that I thought some of you might find of interest. It has to do with program references (i.e., which objects a program uses) and conditional compilation. If you use a documentation package, whether homegrown or commercial, you may rely on program references without being aware of it.

Here is my situation. As part of a conversion project, I have an RPG program that uses conditional compilation directives to select one of two SQL commands, like this:

D zKey            s              3a
D zData           s              5a

     *inlr = *on;
 /if defined(SomeCondition)
     exec sql
        select key, data
          into :zKey, :zData
          from table1
         where key = '1A';
     exec sql
        select key, data
          into :zKey, :zData
          from table2
         where key = '2A';

I used the CRTSQLRPGI command to compile my program. Guess what? No matter how SomeCondition was set, the DSPPGMREF command showed that my program used both files--TABLE1 and TABLE2. For my project, reporting that both files are in use is unacceptable.

My problem is that I was using the default RPGPPOPT(*NONE) on the CRTSQLRPGI command. A value of *NONE causes the SQL precompiler to process the source before the RPG compiler sees it. Since the SQL preprocessor doesn't understand conditional compilation, it was passing both SQL commands to the compiler.

The solution is to add the RPGPPOPT(*LVL1) parameter to the CRTSQLRPGI command. Doing so forces the RPG compiler to process the conditional directives before sending the source to the SQL precompiler.

My project is back on track. Thanks to Barbara Morris of the RPG Compiler Team at IBM Toronto for her help with this tip.


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

Sponsored By

Camp Help/Systems

                                                            · Exclusively for System i users
                                                            · Automated Operations
                                                            · Business Intelligence
                                                            · Hands-on pre-camp workshops
                                                            · Learn from the experts
                                                            · Learn from other users
                                                            · Maximize your ROI

Click Here

Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Edwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

COMMON:  Join us at the Focus 2008 workshop conference, October 5 - 8, in San Francisco, California
MoshiMoshi:  An Interactive Experience for the System i Community. See Episode 1 now!
Help/Systems:  Explore operations automation and BI, June 17 - 20, 2008, Minneapolis, MN


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

The Four Hundred
IBM Previews "Blue Business" SMB System Sales Approach

Micro Focus to Acquire NetManage for $73.3 Million in Cash

Power Systems: The Feeds and Speeds

There's No i in Future, But Is There a Future in i?

IBM Cuts CPU Prices on Power5 and Power5+ Servers

The Linux Beacon
The Linux Ecosystem to More than Double to $49 Billion

IBM Goes Stateless and Cooler with iDataPlex Servers

IBM Previews "Blue Business" SMB System Sales Approach

As I See It: That Competitive Bug

Power Systems: The Feeds and Speeds

Four Hundred Stuff
GDCM Seeks to 'Defrag' the Data Center for Higher Efficiency

Bsafe Updates Security Tools for i OS

GeneXus Brings Web 2.0 Home with Version X

Terminix Overcomes Hurdle to New B2B System, Thanks to LANSA

NSPI Launches CBU as a Service Offering

Big Iron
Micro Focus to Acquire NetManage for $73.3 Million in Cash

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
May 3, 2008: Volume 10, Number 18

April 26, 2008: Volume 10, Number 17

April 19, 2008: Volume 10, Number 16

April 12, 2008: Volume 10, Number 15

April 5, 2008: Volume 10, Number 14

March 29, 2008: Volume 10, Number 13

The Windows Observer
Operations Manager 2007 Goes Cross-Platform, Hooks Into Tivoli, OpenView

Micro-Hoo: Where Does It Stand Now?

Record Revenues for Microsoft, But Forecast Downgraded

Message for Windows XP Fans Seeking to Save OS: Get Over It

Beta of BizTalk Server R3 Expected Later This Year

The Unix Guardian
Sun Books a Small Loss on a Tiny Revenue Decline, Cuts Jobs

Solaris 10 5/08 Supports Legacy Containers, Xeon Features

Sun Taps Splain to Run Microelectronics, Buys Montalvo Carcass

As I See It: That Competitive Bug

Vision Moves Product and Business Plans Forward

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar


Profound Logic Software
WorksRight Software

Printer Friendly Version

Accurate Program References

Replace the Contents of a Physical File That Has Triggers

Admin Alert: How to Recreate/Restore a System Distribution Directory

Four Hundred Guru


From the IT Jungle Forums
Java Messages

Restrict *cmd to specific user

Copying recs from a subfile to a file and keeping highlights

Imbedded SQL



Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement