× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: RPG conversion program
  • From: "Scott Klement" <infosys@xxxxxxxxxxxx>
  • Date: 04 May 1999 17:52:54 -0500

Hi Sherry...

     Sounds to me like you've already got a VERY good handle on
what you need to do.  I'm not sure what you're looking for in the
way of "live advice", but I'll take a crack at it anyway :)

Here are the thoughts of what this program is going to take to
write, as it occurs to me...

1)  You'll need F-specs set up to read from one file, and write to
    the other file.

2)  Since you'll have two files, in different libraries that will
    probably both have the same name, you'll also need to make
    the compiler see them as different files (otherwise it doesnt
    know which one you're reading from, and which you're writing to])
    So, you'll give them different names on your F-spec, and
    the override one of them from the command prompt, or from a CL
    program.

3)  Since they are, really, the same file, they'll probably have
    he same record format name.   The compiler isnt able to deal
    with two files with the same record format name, so you'll
    need to rename one of them in your RPG program.

4)  All the fields in the file will probably be the same name
    as they were before.   In fact, the only difference between
    your files will probably be the dates -- but they'll probably
    keep the same fieldnames, anyway.  This means that you'll have
    two different definitions for each date field, one from the old
    file and one from the new.  You'll need to rename one or the
    other so the definitions don't conflict.

5)  I'm not entirely certain if, by "*ISO dates" you mean an 8-digit
    number in *ISO format, or if you mean an actual date data type
    with the DATFMT(*ISO) keyword...  I'll assume in this example
    that you're dates are defined as 8S 0 in your new DDS, and 6S 0
    in your old DDS.  This is the way that I do it, since the date
    data type is difficult to use in my legacy S/36 programs.



First, you need to make your test file in your test library.  I'd
do this by simply changing the 6S 0 in my OLD DDS to 8S 0, for each
date, and then building the new file (we'll call it MYFILE) in the
test library with:

     CRTPF FILE(TESTLIB/MYFILE) SRCFILE(SOURCELIB/QDDSSRC)

We'll write an RPG program to convert the data from the old to new...
So, here's a sample of that RPG program:

      * MYFILE is my old, non-Y2K safe file
     FMYFILE    IP   E             DISK
      * MYFILE2 is my new, Y2K safe file
     FMYFILE2   O  A E             DISK    RENAME(MYFMT:MYFMT2)

     D TempDate        S               D

      * I can't have MYDATE1 and MYDATE2 in both files because
      * they're different.  I rename the old ones, here...
     IMYFMT
     I              MYDATE1                     OLDDATE1
     I              MYDATE2                     OLDDATE2

      * convert first date
     C     *YMD          test(d)                 OLDDATE1
     c                   if        *IN10 = *ON
     c                   eval      MYDATE1 = *LOVAL
     c                   else
     C     *YMD          MOVE      OLDDATE1      TempDate
     c     *ISO          MOVE      TempDate      MYDATE1
     c                   endif

      * convert second date
     C     *YMD          test(d)                 OLDDATE2
     c                   if        *IN10 = *ON
     c                   eval      MYDATE2 = *LOVAL
     c                   else
     C     *YMD          MOVE      OLDDATE2      TempDate
     c     *ISO          MOVE      TempDate      MYDATE2
     c                   endif

      * write to new file.
     c                   write     MYFMT2


If I try to compile this source member, it won't work because there
is no external description for "MYFILE2", its actually called MYFILE
but is in a different library than the other "MYFILE".  So, before
I try to compile my program, I type:

OVRDBF FILE(MYFILE) TOFILE(PRODLIB/MYFILE)
OVRDBF FILE(MYFILE2) TOFILE(TESTLIB/MYFILE)

now I can compile my program with CRTRPGMOD/CRTPGM or CRTBNDRPG
as I normally do.

Then, probably DLTOVR FILE(MYFILE MYFILE2), unless you want to run
it immediately.


When you do want to run the program, you type this, again:

OVRDBF FILE(MYFILE) TOFILE(PRODLIB/MYFILE)
OVRDBF FILE(MYFILE2) TOFILE(TESTLIB/MYFILE)

and then:
CALL (program-name)

and finally:
DLTOVR FILE(MYFILE MYFILE2)


Now take a few minutes to inspect your file in your test library and
make sure everything worked correctly :)

I didn't do the code for the "exception report" that you're referring
to.   To add that in, you'll need an F-spec defining your printer
file.  I use program-defined output specs for my reports, I dont know
what your company does...  but thats what I use, so I'd add this code:

At the end of your F specs, add this line:
     FQSYSPRT   O    F  132        DISK    OFLIND(*INOF)

After each time you assign *LOVAL to a date, do this:
     C                   except    Error1
or
     C                   except    Error2

And create output specs for the report, at the end...
     OQSYSPRT   H    1P                     2  3
     O         OR    OF
     O                                           50 'Bad Dates in -
     O                                              date conversion'

     O          E            Error1
     O                                            8 'MYDATE1='
     O                       OLDDATE1            15

     O          E            Error2
     O                                            8 'MYDATE2='
     O                       OLDDATE2            15


Hope that helps]

Scott Klement
Information Systems Manager
Klement's Sausage Co, Inc.


"Sherry McMahon" <smcm@frontiernet.net> wrote:
> I would appreciate any help on writing a conversion program to
> change the dates in an existing physical file to *ISO dates in a new
> data file.  My idea is to create a new physical file with new date
> fields and in an RPG program rename the fields, TEST(D) on any
> dates, move the 6,0 ymd dates into the new *ISO field, if a bad
> date, set it to *loval, write the bad dates to an exception(?)
> report, and move all the new fields from the PF to the same name PF
> in a test lib.  I feel I have a fairly good idea of what I want to
> do but darned if I'm sure of how to go about it.  It must be pretty
> obvious I'm a new programmer and could use some examples on how to
> set the RPG up, the proper way to test the dates and how to write
> the exception report. I've read the books, been to the IBM site but
> would appreciate some 'live' advice.  Thank you all in advance for
> your time and patience.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.