Home > AS/400 Tips > iSeries administrator tips > Dynamic memory can replace the "work" file
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

Dynamic memory can replace the "work" file


Ron Turull
09.27.2006
Rating: -4.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



Ron Turull
We've been talking a lot about the details behind using dynamic memory to construct and manipulate dynamic arrays. This is not the only use for dynamic memory. Indeed, the uses are nearly endless. One simple example involves using dynamic memory to replace the common "work" file.

More Information
Dynamic memory in V5: Harness the power

  • Part 1

  • Part 2

  • Part 3

  • Part 4

  • Part 5

  • Defining the problem

    A "work file" is a temporary physical file that a program can use for many purposes. However, when the program stops running, the work file is typically deleted. Usually, we resort to work files when we need some temporary storage the size of which will be changing. A work file is often used when an array is needed -- often an array of data structures -- but the programmer anticipates the number of elements will exceed the 32,767-limit. If you think about it, a file is just like a data structure array (i.e., an array where each element is an identically-defined data structure); a file is an array of records where each record is an identically defined data structure.

    In most (if not all) cases, a work file design can be converted to a dynamic array design. You can even define the program data structure based on a file (e.g., the work file).

    The advantages

    The main benefits of using dynamic memory are:

    1. The program will be much more efficient (i.e., run faster) because of the elimination of the system overhead involved with file initialization and file I/O.

    2. Eliminating the hassles involved with work files. These include making sure that the empty template file doesn't get deleted by accident and eliminating the need to create a temporary work file in QTEMP from the template file (and possibly eliminating the CL program that does it).

    3. Everything is contained in one program (this stems from number 2 above).

    Is the design compatible?

    The required data access method is the litmus test for determining if dynamic memory can be used instead of a work file. If the design relies heavily on keyed access using CHAIN, SETGT, READE, and similar I/O op-codes, then it may not be a good candidate for dynamic memory. However, with the recently introduced %SubArr RPG built-in function (V5R3), sorting dynamic arrays has become much easier, so even keyed access may not be an impediment. Give it some thought and see New built-in function simplifies dynamic array handling for more information.

    -----------------------------------
    About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.


    Rate this Tip
    To rate tips, you must be a member of Search400.com.
    Register now to start rating these tips. Log in if you are already a member.


    Submit a Tip




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    iSeries administrator tips
    Analyze the health of your IBM i server with iScore
    Researching high availability for your System i shop
    Translating Linux for IBM i admins: Using GUI to make it easy
    Translating Linux for IBM i admins: Working with jobs and networking
    OpenOffice: What to know before making the transition from Microsoft Office
    OpenOffice: An enterprise open source solution
    Database performance comparisons on IBM i
    Translating Linux for IBM i admins: User profile commands
    Modern System i reports using Client Access
    Tips for installing Lotus Domino server on a System i partition

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



    iSeries Security - Security Tools, Physical Security and System Security
    HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts