ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Renaming only 1 field before writing to output format

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

  • Renaming only 1 field before writing to output format

    I have a program that uses a data base file for input/output and a dspf that also has a field with the same name as one in the data base file, but different length. How can rename that field and not the other fields in the dspf record format

  • #2
    I always would go to use qualified fields. For DB files but also DSPFs.

    For DSPF you would code it like this:
    Code:
    dcl-f yourdspf Workstn qualified SFILE(SFL_1:d_SFL_1_ds.RRN);
    
    dcl-ds d_CTL_1_ds likerec(YOURDSPF.CTL_1: *all) inz;
    dcl-ds d_SFL_1_ds likerec(YOURDSPF.SFL_1: *all) inz;
    ?

    Comment


    • #3
      Originally posted by andreas.prouza View Post
      I always would go to use qualified fields. For DB files but also DSPFs.

      For DSPF you would code it like this:
      Code:
      dcl-f yourdspf Workstn qualified SFILE(SFL_1:d_SFL_1_ds.RRN);
      
      dcl-ds d_CTL_1_ds likerec(YOURDSPF.CTL_1: *all) inz;
      dcl-ds d_SFL_1_ds likerec(YOURDSPF.SFL_1: *all) inz;
      ?


      The above errors are caused by the fact that TRANSDSPF.HEADER3 contains a field that is defined with a different length in another file used in the program.SoI am attempting to rename that field in TRANSDSPF.HEADER3. So the F spec for TRANSDSPF is ignored

      Click image for larger version

Name:	image.png
Views:	47
Size:	5.4 KB
ID:	159326

      Comment


      • #4
        This is the reason why I recommend to use qualified data structures.
        If fields are in qualified DS, it doesn't matter if another field with the same name has different attributes.

        Comment


        • #5
          Is there a reason why you can't change the field name in the display file source and recreate the display file?

          Comment


          • #6
            Originally posted by Brian Rusch View Post
            Is there a reason why you can't change the field name in the display file source and recreate the display file?
            Thats what I ended up doing

            Comment

            Working...
            X