Why do you use RPG instead of RPGLE for program B? If you convert program B to RPGLE you could use this program (B) more efficiently.
I’m also not sure whether using primary files in RPGLE is still more efficient. In RPG this was true, but in RPGLE I believe that the benefits of primary processing are less than they used to be.
Are you using commitment control in any of these programs?
All of Martin’s comments/ideas plus
you say “1 chain to a file and if it’s sucessful??ly” — are you using the data from this file or just record existance? could this chain be replaced by SETLL using the %EQUALS?
The dynamic call to program B for each of the million records to be processed is a lot of overhead. Expanding on Martin’s idea, if you convert program B into RPGLE, you could bind them together as one program object and eliminate the overhead of the dynamic call.
You would compile program A and B as modules and change your CALL statement in program A to a CALLP and add a prototype in order to call program B (bind by copy). Or to bind by reference, you could create a service program from the program B module and bind that service program to program A.