Loop in RPG for addition of repeated values

44 views Asked by At

Can someone tell me how to add the values of a repeated item in RPG,consider I have the same employee record repeatedly in File with his allowance data,i want to sum up his allowance,then what should I do in RPG?

1

There are 1 answers

0
Harley G. On

if the file you are reading is Keyed by employee # or some such, you can load a "key". RPG400 looks like ....

Move *OFF *IN30

key SETLL Filename

*IN30 DOWEQ *OFF

KEY READE Filename *IN30

*IN30 *IFEQ *ON

      LEAVE

      ENDIF       

"add your tot to a running accum"

   ENDDO