ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Qualified DS + Display files on V5R2

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

  • Qualified DS + Display files on V5R2

    I'm hoping someone can help me come up with a decent way to handle this.

    Basically, I've got about 30 physical files and a display file. For each physical file, I've got a D spec as below:


    PHP Code:
         D ARQ           e ds                  qualified extname(AVRQXX)
         
    D                                     inz(*Extdft
    I have a display file with a number of record formats, and each record format contains most of the fields found in one of the 30 physical files. Some of the physical files may have fields named identically to each other with different data types/lengths.

    Basically, my question is - after doing a chain or read to populate the example ARQ data structure, what is the easiest way to populate all of the corresponding fields on the display file, without using EVAL-CORR or Exfmt with a third data structure parameter, as these are unsupported on V5R2?

    I'm hoping for something a bit more elegant than:

    FIELD1 = ARQ.FIELD1;
    FIELD2 = ARQ.FIELD2;
    ....
    FIELDX = ARQ.FIELDX;

    This is probably a pretty easy question, but some rudimentary Googling and forum searching didn't strike on a solution that didn't use one of the aforementioned off-limits items.

    Thanks!

  • #2
    Re: Qualified DS + Display files on V5R2

    if the fields are always in the same order then use a DS to hold the actual data then use ARQ = otherDSname should work.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Qualified DS + Display files on V5R2

      What would the D spec look like for otherDSName, then, to link it to the display file fields?

      Comment


      • #4
        Re: Qualified DS + Display files on V5R2

        As far as the display file, you will have to perform a READ and a WRITE in order to use the data structures. (At least, I think you can do this as far back as V5R2.)

        Both of these issues (using the eval-corr and exfmt opcode with data structures) are a good reason why to get your OS to at least V6.1. Although you can do this under V5R4, V6.1 / V7 contain a ptf that allows you to specify *ALL on the LikeRec keyword for display files, so that one data structure will work for both reading and writing to the display file.

        At least for now, I would probably recommend moving each qualified field into he resulting qualified data structure.

        ie: DS1.Field1 = DS2.Field1;

        Once you are able to use the eval-corr opcode, then you can replace all of the data structure eval statements to a single eval-corr.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: Qualified DS + Display files on V5R2

          Oh, trust me, I'd love nothing more than to go to V6R1. Unfortunately, working at a software vendor, I've got to develop for as far back as is remotely feasible - I imagine you know all about that. V5R2 is where the line in the sand got drawn for this version of the product, sadly.

          Comment


          • #6
            Re: Qualified DS + Display files on V5R2

            Apparently READ and WRITE don't work in V5R2 with externally defined data structures...

            Comment


            • #7
              Re: Qualified DS + Display files on V5R2

              Here's a method I learned at a COMMON session with Ron Harvey:

              1) The screen field names are the same as the file names.
              2) The file is defined in the F-Specs with a prefix.
              3) Create two data structures using the File
              * One has a prefix X -- to correspond with the File in the F-Specs
              * The other has no prefix -- to correspond with the Fields on the Screen
              4) Use the two Data Structures to move info back and forth between the file & the screen as needed.

              Like so:
              Code:
                   FMyFile    UF   E           K Disk    Prefix(X)
              
                    * Double define screen fields & file fields
                   D FileDS        E DS                  ExtName(MyFile)  Prefix(X)
                   D ScreenDS      E DS                  ExtName(MyFile)
              
                    /FREE
              
                       Chain (myKey) MyFile;
              
                       // Move fields from File Fields to Screen Fields
                       ScreenDS = FileDS;
              
                       //-----> Process screen logic goes here
              
                       // Move fields from Screen Fields to File Fields
                       FileDS = ScreenDS;
                
                       // Then update file.
              http://www.linkedin.com/in/chippermiller

              Comment


              • #8
                Re: Qualified DS + Display files on V5R2

                I don't believe that solution would work for me - I have multiple fields in different record formats in the display file with identical names, such as WEIGHT, which are REFFLD to different physical file fields, and have different lengths - sometimes WEIGHT is a 6,1 packed decimal, and sometimes it's an 8,2, for example. I wanted to end up with a qualified data structure for the display file record formats to prevent having to uniquely name display file fields which are different data types/lengths.

                It's been a while since I worked with display files, and now I'm remembering why I disliked them.

                Comment


                • #9
                  Re: Qualified DS + Display files on V5R2

                  Originally posted by Chipper View Post
                  Here's a method I learned at a COMMON session with Ron Harvey:

                  1) The screen field names are the same as the file names.
                  2) The file is defined in the F-Specs with a prefix.
                  3) Create two data structures using the File
                  * One has a prefix X -- to correspond with the File in the F-Specs
                  * The other has no prefix -- to correspond with the Fields on the Screen
                  4) Use the two Data Structures to move info back and forth between the file & the screen as needed.
                  Watch out for date format handling for the display file.
                  Regards

                  Kit
                  http://www.ecofitonline.com
                  DeskfIT - ChangefIT - XrefIT
                  ___________________________________
                  There are only 3 kinds of people -
                  Those that can count and those that can't.

                  Comment

                  Working...
                  X