ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Uses of Program Described File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Uses of Program Described File

    Hi. I have come across an old program in our IBM i shop, where they described a Physical file (Fields are defined using DDS) as Program-described file (mentioning Input only, Total record length and key fields length) in the File Declaration Specifications in a RPGLE program. And declared a Data Structure for that file.
    I like to know what is the advantage of Program described files in this case, when it could have been easily declared as an externally described file without needing to mention record length and key fields length at the file declaration level ??
    Is there any performance advantage in declaring a file as Program-described when the file has more fields/record length ?

  • #2
    There can be advantages to using DS I/O in some cases. For example decimal data errors will not occur on the Read/Chain but rather only if the field in error is used. Also it can be faster in (say) a batch process - particularly when there are a large number of fields but only a few are needed.

    DS I/O was originally only enabled for program described files. I think it wasn't until about V5R2 that it was enabled for externally described files. I don't know when the program was written but even if it was post V5R2 it is highly likely that it was written by someone who didn't stay up-to-date or who was simply copying another program without thinking too much.

    Does that help?

    Comment


    • #3
      Hi Jonboy,

      Thanks for your explanation. This largely explains.

      However, I have a question on this statement "particularly when there are a large number of fields but only a few are needed."

      Because what I think is , when we open a file specifically for Input alone, RPG program cycle will fetch only the fields from the respective database file which we specify/use in the program. It doesn't read all the fields. We can very much see that happening during Debug process.

      Comment


      • #4
        Good point. It does actually read the whole record but it does indeed not copy the unused fields. I always forget that.

        So that only really leaves the possibilities that the programmer was trying to avoid decimal data errors, didn't know what they were doing, or possibly that the program was written before the external descriptions were developed.

        Comment

        Working...
        X