Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Put a Record Format Into an array

Put a Record Format Into an array

Put a Record Format Into an array

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?

RE: Put a Record Format Into an array

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.  

RE: Put a Record Format Into an array

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.

RE: Put a Record Format Into an array

You need to define your DS with EXTFILE and the filename, not Extfmt.

Solum potestis prohibere ignes silvarum.

RE: Put a Record Format Into an array

ExtFile only works with an actual file. That keyword is not valid with a DS. There some other way to do it?

RE: Put a Record Format Into an array

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.

RE: Put a Record Format Into an array

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.


D MyFileDS      e ds                  Extname(MyFile)          
D  List20                        5p 0 Overlay(MyFileDS:x)  DIM(20)
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';                   
Exec sql Close csr;  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close