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 last published in February 2001

Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close