ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Referencing Fields from an Externally Described File

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

  • Referencing Fields from an Externally Described File

    I am brand new to RPG programming.

    Code:
    F/SPACE 2                                                      
    FVShpPerf  IF   E           K Disk    Prefix(sp)               
    FVenshipp  O    E             Printer Prefix(rpt) OfLInd(*IN90)
    With the code above I am trying to define an external table file and prefix it. However when I try to set any fields from the Venshipp print file, like so:

    Code:
    Z-ADD     0             rptRptTot
    I get a compile error stating: the name or indicator is not defined. This happens with all fields from Venshipp.

    Am I missing something obvious here? My understanding of RPG is once you define an external files you can make reference to its fields, am I defining the file incorrectly?

  • #2
    Re: Referencing Fields from an Externally Described File

    is rpttot a field in the printer file?

    Also, dont use z-add / move ... Learn RPG Free from the start.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Referencing Fields from an Externally Described File

      Guess I accidentally made my reply a face book comment.... huh.... Here it is again.


      Bryce Stock ยท Freelance Graphic & Web Designer at Freelance Graphic & Web Designer
      Thanks for the suggestions DeadManWalks. Turns out I didn't understand that there was working variables in the Cspec that needed assigned the correct value. So the hunch I had about the issue when asking this question ended up being totally wrong.

      As for RPG Free and Z-Add. I know that Z-Add is bad to use and that RPG Free is the newer/better. I didn't decide to use Z-Add or learn RPGLE over Free, I am in a training for my work, most of their programs are still written in RPGLE and some I'm sure many of them use Z-Add as well.

      Thank you for your help, its good to know I have this forum as a resource when I need it.

      Comment


      • #4
        Re: Referencing Fields from an Externally Described File

        For an output-only file, the fields only get defined in the program if you have a WRITE operation to the record format.

        Comment


        • #5
          Re: Referencing Fields from an Externally Described File

          Whoa, I just noticed that there's a section at the bottom for comments (from Facebook) as well as the thread at the top. I wonder what I've been missing in other threads in this forum. I usually stop reading when I get to the "reply" box.

          For maximum confusion, replying to Bryce's comment in the Comments section would be a Facebook reply. But replying in the normal thread at the top would lose the connection between the comment and the reply. Yikes!

          Comment


          • #6
            Re: Referencing Fields from an Externally Described File

            When I learned RPG we would do:

            RPTTOT SUB RPTTOT RPTTOT

            Because it would made smaller compiled code (compared to Z-ADD) in order to fit into the 64kb limit of the S/34 !!

            Comment


            • #7
              Re: Referencing Fields from an Externally Described File

              If you would like to make the code more modern, try using "qualified" instead of "prefix". This enables you to use stuff like eval-corr, which works very nicely for copying fields en-masse, so you don't have to have "rptField1 = spField1, rptField2 = spField2, etc."

              Just a suggestion... prefix still works, it/s just a bit old-school.

              Comment


              • #8
                Re: Referencing Fields from an Externally Described File

                "RPG free" isn't a separate language from RPGLE, it's part of it. So the only thing preventing you from using it would be shop standards, and the general ickiness of using a different style of code than the code that's already there. When I'm modifying old-style RPGLE, I stick to the existing style if I'm just changing or adding a few lines. I use free-form if I'm writing a whole new subroutine or procedure. Occasionally, I'll re-format a section of code to be free-form if I'm making significant changes to code where there are too many levels of nesting of IF/FOR etc (2 is sometimes too many).

                Although even if I was writing in fixed-form, I'd use EVAL over Z-ADD and MOVE. (Hopefully nobody is working in a shop where there's a shop standard that says no EVAL or IF. *shudder*)

                Comment


                • #9
                  Re: Referencing Fields from an Externally Described File

                  I use free format - but I rarely use the EVAL keyword ... it seems redundant to me 'EVAL commission = salesamt * pct;' vs just 'commission = salesamt * pct;' Unless one needs to use the extenders it just seems redundant...

                  Comment


                  • #10
                    Re: Referencing Fields from an Externally Described File

                    Originally posted by Rocky View Post
                    I use free format - but I rarely use the EVAL keyword ..
                    Hmmm... Barbara was recommending that if the OP is required to use fixed format, that he uses EVAL...

                    Comment


                    • #11
                      Re: Referencing Fields from an Externally Described File

                      I agree with Barbara. I generally stick to the standard of the program that I'm modding... unless it's a big change and vendor software. Then I use /free. If it's in-house programs, and depending on it's size and spaghettiness (GOTO, etc.) , then I convert it the program to /free.
                      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