• 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
    ARCAD Software

    [Webinar] Git on IBM i: A True Look at What It Takes

    Ready to bring your IBM i development into the modern DevOps era? Join Jeff Tickner, CTO North America, and Alan Ashley, Sr. Solutions Architect, for a practical look at what it really takes to migrate to Git on IBM i and how to do it right.

    What you’ll discover:

    • Modern DevOps approaches to bring teams together and boost efficiency with flexible Git options
    • Bi-directional push/pull operations and pipeline automation
    • Best practices based on years of real-world experience
    • ARCAD’s seamless and highly optimized Git integration in action

    Whether you’re evaluating Git for the first time or planning your migration strategy, this session will provide a clear, actionable path forward.

    Register Now!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Proper CL Error-Handling Admin Alert: Hitting the Limits of the QNTC File System

    Leave a Reply Cancel reply

Content archive

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

Recent Posts

  • More Power Systems Price Hikes, This Time They Are “Directional”
  • AI Is Not Just For Developers, It Is For Everyone At Your Company
  • Guru: Finding Data In The Forest – Exploring Three-Part Naming In SQL
  • Former IBMer’s New Book Puts The Midrange In The Spotlight
  • Have You Tried To Buy A Server Lately?
  • GenAI Is The Death Of Deterministic Project Budgeting
  • PTC Adds Support For VS Code With Implementer 12.7
  • Guru: Single Threading A Program Execution
  • As I See It: Push Back
  • IBM i PTF Guide, Volume 28, Number 21

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