• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • The ARCHIVE Utility

    March 22, 2006 Ted Holt

    The code associated with this story is available for download here.

    I’m happy to present a utility I wrote that has proved to be useful to my employer. It’s called ARCHIVE, and it provides an easy way to make a backup copy of a physical file member, just in case something goes wrong during a job.

    Before I present the ARCHIVE utility, let me explain why I wrote it. In a perfect world, all database files would be journaled and all database-processing programs would run under commitment control. If anything were to be found amiss–which would never happen in a perfect world–the changes would be backed out of the database, as if the program had never run. However, this is not a perfect world. Many iSeries shops run software systems that were designed before journaling was available (or at least before anybody learned how to make it work.) Retrofitting journaling and commitment control into an old application is not an easy task, nor is it as critical as most of the projects that users dream up for us to do.

    It’s also good to consider that rollback is not always a viable option. Sometimes things go wrong, but no one finds out that the bad database changes took place until after other, good database changes have occurred. In such cases, the best one can often do is to list the changes that took place and reverse the database changes by hand through the application.

    A common practice that I have seen and used is to copy a database file member to a backup file at a critical point in a job stream, perhaps before updates take place or the file is cleared.

    CPYF FROMFILE(SOMEFILE) +
       TOFILE(SOMEFILEBK) +
       MBROPT(*REPLACE)
    MONMSG MSGID(CPF2817) +
       EXEC(CLRPFM SOMEFILEBK)  /* SOMEFILE IS EMPTY */
    

    In this example, a program runs that updates file SOMEFILE. File SOMEFILEBK contains the data of SOMEFILE as it was before the updates took place. If there are questions about the data, a user can query SOMEFILEBK.

    The CPYF approach is fine, but limited in that only one backup is retained. Sometimes it is good to have the last several versions of a file. And that is why I wrote ARCHIVE. It provides an easy way to keep one or more versions of a database file.

    The ARCHIVE utility consists of two objects: a command named ARCHIVE and a CL program named ARCHIVECL. The ARCHIVE command has the following parameters.

    Parameter

    Description

    Default
    value

    FILE

    The file
    containing the member to be backed up.

    Required

    MBR

    The member
    to be backed up.

    *FIRST

    ARCHIVE

    The archive file to contain the backup member.

    Required

    ARCHIVEMBR

    The name
    of the member in the archive file.

    *GEN

    By default, you backup the first member of a file into a new member of the archive file. The last parameter tells the name of the new archive member. You can backup to a certain member. For example, you might backup to member B4ME, before month-end, during month-end processing. But if you use the default value, *GEN, the ARCHIVE utility will create a member name. It looks like garbage, but the file-member comment tells the name and library of the saved file and the date and time when it was archived.

    Suppose you have a transaction file named XACTS that you want to back up during a batch run. First, create the archive file.

    CRTDUPOBJ OBJ(XACTS) +
       FROMLIB(SOMELIB) +
       OBJTYPE(*FILE) +
       TOLIB(*FROMLIB) +
       NEWOBJ(XACTSARC)
    

    Second, tell the archive file how many backups it is to hold. In this example, I assume 35 backups.

    CHGPF FILE(SOMELIB/XACTSARC) MAXMBRS(35)
    

    Last, add the archive command to your application at the appropriate place.

    ARCHIVE  FILE(SOMEFILE) ARCHIVE(SOMEFILEBK)
    

    Now when you arrive at work only to find that the nightly accounts receivable update messed up the balance that customer XYZ owes your company, you’ll be able to go through the archives for clues.

    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

    Xperia:  Fully integrated suite of applications for small- to mid-sized companies
    Bytware:  Network security, anti-virus, monitoring, notification/alerts, file recovery, & compliance
    COMMON:  Join us at the Spring 2006 conference, March 26-30, in Minneapolis, Minnesota

    Azul Systems Sues Sun Over Java Licensing The OS/400 Cooperative

    One thought on “The ARCHIVE Utility”

    • Sean McGovern says:
      May 14, 2020 at 11:45 am

      We’ve been using this program since 2006, but just come to light that there is a bug! Date format is not checked for Day portion, meaning that it doesn’t generate member name correctly for date formats other than MDY.

      Reply

    Leave a Reply Cancel reply

Volume 6, Number 12 -- March 22, 2006
THIS ISSUE SPONSORED BY:

T.L. Ashford
Patrick Townsend & Associates
WorksRight Software

Table of Contents

  • The ARCHIVE Utility
  • A Java Developer’s First Deployment on the iSeries
  • Admin Alert: Moving Printer Devices and Remote Outqs Between Systems

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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