• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Closing Files in ILE Service Programs

    May 5, 2004 Hey, Ted

    We’re moving all our new development to RPG IV and ILE, and as part of this process we are looking at putting our commonly used processes into service programs. Many of these functions require access to database files. For example, one function would retrieve the price of an item according to the area in which it is being sold, the date for which the price is applicable, and whether any discounts have been set up. This is quite a complicated procedure, and we want a simple function we can call that will prevent us having to code it separately each time.

    We have put this calculation into a subprocedure, which uses the passed parameters to retrieve the correct information, using three files. This subprocedure then has been put into a service program, and so far, so good–the price is returned to the program. The problem becomes apparent when the calling program ends– the three files used within the service program are still open. I assume the files are open because there is no program cycle processing that will ever close them. Short of manually opening and closing these files (which I guess would be very inefficient), I can’t see any way around this problem. Am I missing something obvious?

    –Simon

    The files will remain open until the activation group in which they are open is destroyed. If you assign the service program and the calling programs to the proper activation groups, you won’t have to explicitly close the files.

    When you create the service program, specify ACTGRP(*CALLER) to make the service program run in the caller’s activation group. This is the default setting for service programs.

    Here is the key: make sure that calling programs do not run in the default activation group. The usual way to achieve this objective is by creating them to run in either a *NEW or named activation group. It’s okay to create calling programs with ACTGRP(*CALLER) if they will always run under programs that run in *NEW or named activation groups. The problem with running your service program in the default activation group is that the only way to destroy the default activation group, and thereby to close your files, is by ending the job.

    There are two ways to destroy an activation group: one is to end the job that contains the activation group, and the other is to use the Reclaim Activation Group (RCLACTGRP) command.

    For more information about activation groups, see “What You Should Know About Activation Groups” and “ILE Strategies.”

    –Ted

    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

    JBM Systems Adds Form Design Tool to Document Suite IBM eServer i5 and i5/OS Announcement Roundup

    Leave a Reply Cancel reply

Content archive

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

Recent Posts

  • POWERUp 2025 –Your Source For IBM i 7.6 Information
  • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
  • Guru: Creating An SQL Stored Procedure That Returns A Result Set
  • As I See It: At Any Cost
  • IBM i PTF Guide, Volume 27, Number 19
  • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
  • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
  • i-Rays Brings Observability To IBM i Performance Problems
  • Another Non-TR “Technology Refresh” Happens With IBM i TR6
  • IBM i PTF Guide, Volume 27, Number 18

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