ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Variable file names

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

  • Variable file names

    We have a program that we run once a month that records YTD information. The file is named YTDRCV18 and is a valid externally described file on the system. Every year we make a new new copy of the file, renaming it YTDRCVnn where nn is the current year. At the end of this year we will create a new file named YTDRCV19, and modify/recompile the program that uses it. How can I modify the RPGLE program to determine the correct file name base on *MONTH without having to modify it and recompile it every year

  • #2
    You could perform an OVRDBF to point to the new file, but this has to be done before the file is opened, either in a front end CL or in the RPG program with USROPN on the file.

    Comment


    • #3
      Wouldn't it be better to determine the file name based on *YEAR?

      Add keywords USROPN and EXTFILE(ytdRcvFilename) to your file definition, and add a 10 A variable called ytdRcvFilename.

      Then code like this, assuming that the internal name of your file is "ytdRcv".
      Code:
      ytdRcvFilename = 'YTDRCV' + %editc(*year : 'X');
      open ytdRcv;

      Comment


      • #4
        Originally posted by Barbara Morris View Post
        Wouldn't it be better to determine the file name based on *YEAR?

        Add keywords USROPN and EXTFILE(ytdRcvFilename) to your file definition, and add a 10 A variable called ytdRcvFilename.

        Then code like this, assuming that the internal name of your file is "ytdRcv".
        Code:
        ytdRcvFilename = 'YTDRCV' + %editc(*year : 'X');
        open ytdRcv;
        This is exactly what I am looking for

        Comment

        Working...
        X