About Run Time Arrays

695 pts.
Tags:
I-Spec
RPG
RPGLE
Runtime arrays
Hi, Can anyone help me how can i use Run time ARRAYS in RPGLE PROGRAM and give me some examples to load array with records from file,when i am trying to define file in 'I' spec it is giving me compile time error please can any one give complete program example to work with runtime arrays
ASKED: August 4, 2008  5:41 AM
UPDATED: August 4, 2008  3:47 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

Your file should be defined in the F spec. Why are you defining it in the I spec?

Regards,

Martin Gilbert.

Declare the file in F specs as externally defined

D Specs or I Specs can be used to map an array over the fields in the physical file
D testds ds
D SlsArray 10S 2 Dim(12)
D JanSales 1 10S 2
D FebSales 11 20S 2
D …
D DecSales 111 120S 2

When you read a record that contains the fields JanSales…DecSales the values will be available in the array fields SlsArray(x) and if you change the values in the SlsArray and update or write the record those values will be in the file in the fields JanSales … DecSales

PhilL

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
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
  • graybeard52
    Here is an example how you can load the array QtrSales with data from a file containing fields Qtr1, Qtr2, Qtr3, Qtr4
         FArrayFile IPE  E             Disk                                 
         FQsysPrt   O    F  132        Printer                              
         D                                                                  
         D Total           S             11P 2                              
         D                                                                  
         D SalesData       DS                                               
         D   Qtr1                                                           
         D   Qtr2                                                           
         D   Qtr3                                                           
         D   Qtr4                                                           
         D   QtrSales                          Overlay(SalesData)           
         D                                     Like(Qtr1) Dim(4)            
         D                                                                  
         D                                                                  
         IArrayRF       01                                                  
         C                   Xfoot     QtrSales      Total                  
         C                                                                  
         OQsysPrt   D    01                                                 
         O                       Qtr1          J                            
         O                       Qtr2          J                            
         O                       Qtr3          J                            
         O                       Qtr4          J                            
         O                       Total         J                            
      
    3,115 pointsBadges:
    report

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
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

Thanks! We'll email you when relevant content is added and updated.

Following