Using External Datastructure in RPG

295 pts.
Tags:
AS/400
RPG
In RPG why do we use External Data Structure? Does it puts all the fields in contingeous memory?

Answer Wiki

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

an externally defined data structure is used to allow a pre-defined (normally field level definition) to be used to map the data in a data structure rather than defining it explicitly in the program

therefore if you want a data structure where the information is in the same format as one of your files then you could identify this to an rpg program using the following D spec

D DataStructure DS Likerec(Format)

this is for example particularly useful when describing key data structures, qualified data structure or input/output data structures for file handling

Discuss This Question: 3  Replies

 
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
  • Estela
    What if the the two files (Input and output) differ in one field only and the field is in the middle of the output file? Example: InFile = contains Field1 to Field100 OutFile = contains Field1 to Field101, where OutFile.Field1 to Outfile.Field50 are equal to InFile.Field1 to InFile.Field50, OutFile.Field51 is not on InFile, OutFile.Field52 to Outfile.Field10 are equal to InFile.Field51 to InFile.Field100 Can we break externally defined data structure for both files? Can they have subgroup?
    10 pointsBadges:
    report
  • Splat
    If you're looking to do a single data-structure to data-structure move, the dissimilarity will cause you issues. You should be able to substring the data structure if you're looking to minimise the move operations. I tend to use external data structures based on the incoming file to facilitate before/after images of the data being manipulated; with the prefix keyword at the data structure level to identify the field data, I can easily do before/after field comparisons or simply compare the data structures to see if any changes have been made. I've also used external data structures to standardise parameter lists. The file defining the external data structure doesn't have to actually hold data.
    6,765 pointsBadges:
    report
  • TomLiotta
    Can we break externally defined data structure for both files? Can they have subgroup? What release are you running? Newer op-codes such as EVAL-CORR might make it irrelevant. Also, a data structure helps enforce data types in memory. Numeric fields from files are brought into RPG programs and stored in program memory implicitly as packed-decimal values, regardless of the data type in the database. If the data type format is important, you can use the DS to enforce it. Also, a DS provides a 'name' for the entire set of fields. Some operations can benefit from being able to reference and copy or compare an entire record image in a single operation. Tom
    125,585 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