I'm posting this to alert anyone who's got large multivalued attributes they may want to sum in AQL.
A friend of mine logged a case recently where a correlative using the S() function would hang when the file has any items where the attribute in question has more than 32,768 values. Engineering confirmed that this is an AQL limitation because it's using a 16-bit signed variable to track the value count. This variable is used in many places in AQL, and it would be a huge task to rearchitect.
In the course of debugging this, Engineering came up with a workaround by using CALL in the correlative. This not only removed the 32,768-value limit, but it is also MUCH faster.
Example of the correlative that hangs (using multivalued attribute 9 in the example):
008 A;S(9)
Example of the correlative that works (again using multivalued attribute 9 in the example):
008 call bp sumbal
Might be a good idea to fully path the subroutine being called. Example of a subroutine in an account called "orders" in a file call "pgms":
008 call orders,pgms, sumbal
Subroutine being called from the correlative:
subroutine sumbal(rval)
values = access(3)<9>
valMax = dcount(values,@vm)
rval = 0
for x = 1 to valMax
rval += values<1,x>
next
return
------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
------------------------------