Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put a Record Format Into an array

Status
Not open for further replies.

Fooch

Programmer
Dec 19, 2005
63
0
0
US
I swear I knew a way to do this, but I can't remember it or find it. What I want to do:

There is a file, at the end of the record is a list of 20 fields, all defined the same. I want it so that as soon as I read a record, my array is populated with those 20 fields. I don't want to have to move each one of them individually. I swear there was a way to define a field with a keyword or soemthing that was based on a record format and once the format was populated, so was the field. The field could be a DS that I could OVERLAY with an array and all 20 would have their values...but I can't remember how.

Is this possible?
 
I think this is what you want
D SalesData DS
D Qtr1
D Qtr2
D Qtr3
D Qtr4
D QtrSales Overlay(SalesData)
D Like(Qtr1) Dim(4)

Qtr1,2,3,4 are fields in the input record. QtrSales is the array. Note there is NO definitions in the Qtr1,2,3,4 fields.
 
That's not what I am looking for. I don't want to string out 20 fields like that. I was thinking something along the lines of:

D List DS ExtFmt(FileFormat)
D Record 500
D LibList 10 0 OVERLAY(Record:300) DIM(20)

But the ExtFmt is not valid. This won't work. But this is the basic thought of what I want to do. I could do embedded SQL as well if that was possible.
 
You need to define your DS with EXTFILE and the filename, not Extfmt.

Solum potestis prohibere ignes silvarum.

 
ExtFile only works with an actual file. That keyword is not valid with a DS. There some other way to do it?
 
Well, you might be able to define the file as "program-described", then define RECORD as the entire record. Then the DS idea might work.

You said 20 lines is too much coding - what would it need to be ? Most workarounds would prob need 20 lines or more.
 
I'd use sql to do that. Here's what I should do in my program.
Replace the description of List20 and x with their according values.

Code:
D MyFileDS      e ds                  Extname(MyFile)          
D  List20                        5p 0 Overlay(MyFileDS:[i][b]x[/b][/i])  DIM(20) 
/free
Exec sql Declare csr cursor for            
          Select * from MyFile;           
                                           
Exec sql Open  csr;                        
                                           
DoU sqlstt = '02000';                      
    Exec sql Fetch from csr into :MyFileDS;  
    if sqlstt = '02000';                   
       leave;                              
    endif;                                 
Enddo;                                     
                                           
Exec sql Close csr;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top