how flexible are your calcu...1

Upload: nairarung

Post on 01-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 How Flexible Are Your Calcu...1

    1/6

  • 8/9/2019 How Flexible Are Your Calcu...1

    2/6

  • 8/9/2019 How Flexible Are Your Calcu...1

    3/6

    Business Strategy

    Competitive Advantage

    Consolidation

    Executive Perspective

    Green IT

    Migration

    Open Source

    ROI

    Infrastructure

    Blades

    StorageSystems Management

    Case Studies

    Distribution

    Healthcare

    Manufacturing

    Services

    Web 2.0

    Cloud

    Social Media

    Trends

    Collaboration

    IBM AnnouncementsIBM Research

    Open Source

    Social Media

    What's New

    Product News

    AIX

    MAINFRAME

    POWER

    Newsletters

    About Us

    Subscribe

    Current Issue

    Archive

    IBM i

    ALL EDITIONS

    ADMINISTRATOR

    DEVELOPER

    TRENDS

    TIPS & TECHNIQUES

    CASE STUDIES

    Flexible are Your Calculations? | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/enewsletterexclusive/1706

    9/27/2010

  • 8/9/2019 How Flexible Are Your Calcu...1

    4/6

    STORAGE

    PRODUCT NEWS

    ENDPGM

    BUYER'S GUIDE

    Developer> RPG

    How Flexible are Your Calculations?RPG programming techniques to help you solve unsolvable problems.

    September 2007 | by Jon Parisand Susan Gantner

    Print Email

    In this EXTRA article, we want to introduce some RPG programming techniques and hopefully make you think about ways to combine them to solve

    unsolvable problems. One such case is how to provide user-controlled, spreadsheet-style calculations within an RPG program.

    Weve addressed this problem several times in the past, but on this occasion the trigger was a request during a customer training class for a simpler

    approach to pricing calculations. The customers existing solution was inflexible and required significant effort to introduce new pricing schemes. The

    end users (bless their little cotton socks) simply wanted to enter the names of the variables and the required calculation steps entered into a database.

    The program would then retrieve these details, apply them to a set of data and report the results. The calculation steps were very similar to how we

    used to perform math in RPG/400 (e.g., add two variables, store the result in a temporary field, then multiply the temporary by a third field and so

    on). Had it been an option to write the new program in PHP, for example, this requirement wouldnt have presented much of a problem such tasks

    are simpler to handle in an interpreted language. But, naturally, the required solution needed to be integrated into an RPG application!

    While a comprehensive solution to problems like this isnt really practical, RPG provides the basic tools to handle the requirement providing the

    problem space is constrained. We'll discuss what we mean by that later. The problem has two basic elements. First, we need to be able to select the

    actual calculation performed (add, subtract, etc.) based on the database entry. Second, we need to perform the selected calculation on fields whose

    names were also supplied in the database entry.

    Let's look at the calculation aspect first. Suppose you wanted to accommodate the basic add, subtract, divide and multiply operations. You might be

    tempted to do something like this:

    Next page: >>

    Page 1 23456

    Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

    More Articles From Jon Paris

    Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.

    More Articles From Susan Gantner

    Flexible are Your Calculations? | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/enewsletterexclusive/1706

    9/27/2010

  • 8/9/2019 How Flexible Are Your Calcu...1

    5/6

    Advertisement

    WEBINAR -- RPG OA and Beyond from looksoftware Tuesday, September 28, 2010, 10 am BST (Europe)

    Wednesday, September 29, 2010, 2 pm EST (USA)

    Browse products and services for Developer.

    Advertisement

    Flexible are Your Calculations? | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/enewsletterexclusive/1706

    9/27/2010

  • 8/9/2019 How Flexible Are Your Calcu...1

    6/6

    Maximize your IT investment with monthly information from THE source...IBM Systems MagazineEXTRA & Marketplace eNewsletters.

    SUBSCRIBE NOW.

    View past IBM i EXTRAs here

    Related Articles

    Even More Flexible Calculations

    E-Newsletter Exclusive | In the September EXTRA e-Newsletter, Jon Paris and Susan Gantner shared some solutions to &qout;unsolvable&qout;

    RPG problems with a technique for flexible calculations. Now they delve deeper with a more complex example, making a sequence of calculations

    not only possible but simple to create and use.

    RPG - Anchoring Your Team

    Cover Story | Alternate approaches to extending your RPG applications.

    The State of Modernization

    Cover Story | Bruce Vining talks modernization with Jon Paris and Susan Gantner

    RPG for the Web

    iSeries EXTRA: By Now, the Case for RPG IV Should Be a No-Brainer

    E-Newsletter Exclusive

    IBM i

    AIX

    MAINFRAME

    POWER

    Homepage

    About Us

    Contact Us

    Subscriptions

    Editorial Calendar

    Advertise With Us

    Reprints

    Privacy Policy

    Terms of Service

    Sitemap

    IBM Systems Magazine is a trademark of International Business Machines Corporation. The editorial content of IBM Systems Magazine is placed on

    this website by MSP TechMedia under license from International Business Machines Corporation.

    2010 MSP Communications, Inc. All rights reserved

    Flexible are Your Calculations? | IBM i | IBM Systems Magazine http://www.ibmsystemsmag.com/ibmi/enewsletterexclusive/1706