You Can View User Feedback To This Tip
This code will build a set of "DS" D-Specs for each record format based on DSPFFD (Display file Field Description) of the
display or database file. The code will be added to the bottom of the RPGILE source.
Code
Click here to view the code.
USER FEEDBACK TO THIS TIP
- Wouldn't it be a lot easier to use an externally
described data structure. It will always match the current file layout
since it is not hard coded. When you read a record from your file the
data structure is automatically loaded.
D MyFileDS E Ds ExtName(MyFile)
You can even add the prefix key word to create a data structure that
matches your file but now all the field names in this data structure
start with "sv". Helpful when you want to save the data in a record
before displaying it on a screen for possible changes.
D MyFileSvDS E Ds ExtName(MyFile) Prefix(sv)
Julie Hills
- There is an alternative way to create a DS with a file's fields.
You define an externally described DS in your RPG program, and voila!
Assuming that the external file's name is CUSTFILE, the RPG 3 code to create a data structure called CUSTDS is:
ICUSTDS E DSCUSTFILE
The RPG 4 code is:
D CUSTDS E DS EXTNAME(CUSTFILE)
Shalom Carmel
==================================
MORE INFORMATION ON THIS TOPIC
==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.