Issues with activation group

26 Views


Let's go over specific examples where activation group issues can cause SETLL, READ, or CHAIN to behave unexpectedly or cause file access errors in ILE RPG programs on IBM i.


๐ŸŽฏ Common Activation Group Issues Affecting SETLL, READ, CHAIN

Symptom Likely Cause
READ returns wrong data or fails Shared open data path (ODP) from previous call
CHAIN doesn't find a record File is open in another activation group
SETLL + READ skips records Stale file cursor from earlier call
RNX1216 (file open or level check) File already open in another activation group

๐Ÿงพ Example 1: SETLL Skipping Records Due to Reused Activation Group

Setup:

  • Program ORDERPGM reads ORDERPF by key (CUSTID)

  • Compiled with ACTGRP('ORDERS')

setll custID ORDERPF;
read ORDERPF;

Problem:

You run the program once, then again in the same job. The second run:

  • Reuses the activation group

  • The ODP (Open Data Path) from the first run is still active

  • Cursor is not at the beginning → SETLL doesn't reposition properly

Result:

  • READ returns unexpected records or nothing at all


โœ… Fixes:

  1. Recompile ORDERPGM with:

    ctl-opt actgrp(*new);
    

    Ensures fresh activation group and ODP on each run.

  2. Or manually close the file at the end of the program:

    close ORDERPF;
    

๐Ÿงพ Example 2: CHAIN Fails After File Definition Changes

Setup:

  • Program CUSTOMERPGM does CHAIN to CUSTOMERPF

  • Program was compiled before the file changed

  • Runs in a named activation group

Problem:

You recompile CUSTOMERPF, but not CUSTOMERPGM. When the program is called again:

  • It runs in the existing activation group

  • Tries to use the old file format ID

  • Fails with:

    RNX1216 โ€” Level check error occurred on file CUSTOMERPF
    

โœ… Fixes:

  • Always recompile programs that use changed files

  • Use *NEW or call RCLACTGRP to force new file load:

    RCLACTGRP ACTGRP(CUSTOMERGRP)
    

๐Ÿงพ Example 3: Multiple Programs Use Same File in Conflicting Groups

Setup:

  • Program A: actgrp('SALES') → opens ORDERS

  • Program B: actgrp('REPORTS') → also opens ORDERS

Problem:

If ORDERS is opened with different share/open rules, or fields differ, IBM i may:

  • Conflict on record format level ID

  • Fail with errors like:

    RNX1217 โ€” Program not found or not loaded
    RNX1216 โ€” File already open or level check
    

โœ… Fixes:

  • Use shared activation group if programs must share files:

    ctl-opt actgrp('ORDERS');
    
  • Or ensure complete isolation with *NEW


๐Ÿ” Summary Table

Symptom Cause Solution
READ skips records Reused ODP in shared actgrp Use *NEW, or CLOSE file
CHAIN fails after file change Format mismatch Recompile, use RCLACTGRP
File open error File opened in different group Use consistent activation group
Wrong data returned Leftover file cursor Reset ODP or actgrp

 

Post Comments