Array definition: getting number of elements and sizes

Use this program to define arrays or finding number of elements:

***************************************************************** 
* Defining & Array's, getting number of elements & sizes 
***************************************************************** 
* 
DArray          S           10A   dim(10) 
DArrayOne          S          1    dim(10) 
DArrayTwo          S         1    dim(%elem(ArrayOne)) 
* 
DTableOne          S          1    dim(26) ctdata 
* 
DMultOccurDS      DS           occurs(%elem(TableOne)) 
D  Field                    1 
* 
DValue           S           15  9 
*----------------------------------------------------------- 
*  Value = 100 
*----------------------------------------------------------- 
C           Eval      value = %size(ArrayOne:*All) 
* 
*----------------------------------------------------------- 
*  Value = 10 
*----------------------------------------------------------- 
C           Eval     value = %elem(ArrayTwo) 
* 
*----------------------------------------------------------- 
*  Value = 24 
*----------------------------------------------------------- 
C           Eval      value = %elem(TableOne) 
* 
*----------------------------------------------------------- 
*  Value = 24 
*----------------------------------------------------------- 
C           Eval      value = %elem(MultOccurDS) 
* 
C           Return 
** TableOne 
ABCDEFGHIJKLMNOPQRSTUVWXYZ


 

This was first published in February 2001

Dig deeper on RPG iSeries programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close