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
Last Wiki Answer Submitted: November 12, 2007 3:02 pm by Teckgeck170 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
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?
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.
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.
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?
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.
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