You are here: Development Standards > OSAS Standards > Data File Conversion > xxCNVT.yyy Program

# xxCNVT.yyy Program

For help in upgrading your conversions, use the skeleton program named SDSKCNVT in the progSD directory of the Software Development Utilities. There are two ways to use this program to upgrade your existing conversion programs to work in the new chained format. Method 1 merges pieces from the skeleton program into your existing conversion program. Method 2 merges the main conversion lines from your existing program into the skeleton program. Either method produces the same result.

Method 1

1. Rename your current conversion program xxCNVT.yyy.
2. Change line 1 to read SETERR ERRORTRAP.
3. Remove the verification and error log logic from your program. Resource Manager will now perform the verify and print the error log automatically. The verification and error log logic is traditionally located at lines 89–110 and lines 1000–1999.
4. Check that all your main conversion lines are between lines 2000 and 3999. If your main lines go beyond this, renumber these lines. You can renumber these lines into the 1000 block because it is no longer needed for verification, resulting in a workspace from lines 1000–3999.
5. If you need to copy files rather than convert them, write down the file names that will be copied.
6. Check your program for custom code in these line ranges. The merge will overwrite these sections:

Lines 4000-4399 | copies files
Clines 4500-4599 | new file open logic
Lines 4600-4899 | writes out to the error log
Lines 5300-5399 | error trapping
Lines 8400-8499 | GENERROR
Lines 9000-9155 | GENDATE
Lines 9990-9999 | QUIT logic
If you have custom code in these areas, renumber it to an unused area.

7. Use the list above to merge in the pieces from the SDSKCNVT program.
8. Change file opening logic as follows:
   old: GOSUB 5200
   new: GOSUB 4500
9. Change file error message logic as follows:
   old: GOSUB 5695
   new: LET LOG=1; GOSUB 4800
10. Change any other messages that have been used on the error log, based on the chart below.

Number | Log Message
1 | <filename> does not exist. It could not be converted.
2 | <filename> had an invalid date. It was changed to (Blank).
3 | <filename> does not exist. It could not be copied.
4 | Orders exist in the order file. File was not converted.
5 | <filename> at key <keyp> has an invalid address. The address was not converted.
6 | <filename> at key <keyp> is an invalid record. The record was not converted.
7 | An error occurred while converting the record at key <keyp> in file <filename>. This record was skipped.
8 | An error occurred while converting the record <keyp> in file <filename>; the data was converted and conversion continued.
9 | Error opening <sourcdir>FAMA+STBL(“CID”) file. Cannot create credit amount for retired asset record.
10 | Cannot find <R0$(1,14)> in the Asset Master file. Cannot create GL account and accumulated eligible deduction.
11 | Error reading <OLDRO$> in <sorcdir>FAMA+STBL(“CID”) file. Cannot create credit amount for retired assets.
12 | Error loading APRCDx table. Cannot create v4.0 recovery period fields.
13 | Error writing new APRCDx table to v4.0 FATB.
14 | Error opening the old FATAX file or the v3.20 credit tables.
15 | Depr. table ID not translated. Current value remains and must be changed by user.
16 | Error opening FAMAx file. Cannot create GL account and accumulated or eligible accumulated.
17 | The <keyp> subassembly is serialized or lotted and has been changed to an item type.
18 | <filename> at key <keyp> has an invalid state code.
99 | ERR = <errnum>, the line number was <line>, the program name was <prog$>, and the key of the data file was <keyp>.

11. Any other messages that are not in the chart can be printed by setting MSG$ before calling RMCNVTLG.PUB.
12. To copy files, GOSUB 4200 and use the following logic for each of the file:
13. LET F$=“<filename>“+STBL(“CID”); GOSUB COPYFILE
14. Change line 9997. For the last program in the chain (the current version),
    `LET PGM1$=“RMCONVER”`
    to let the driver know that the application is finished. For all other programs in the chain,
    `LET PGM1$=APPLDIR$+FILENAME$; REM “the next conversion program in the chain”`

Method 2

1. Rename the skeleton program (SDSKCNVT) to xxCNVT.yyy.
2. Check that all your main conversion lines are between lines 2000 and 3999. If your main lines go beyond this, renumber these lines.
3. If you need to copy files rather than convert them, write down the file names that will be copied.
4. Check your program for custom code in these line ranges. The merge will overwrite these sections:

Lines 4000-4299 | copies files
Lines 4500-4599 | new file open logic
Lines 4600-4899 | writes out to the error log
Lines 5300-5399 | error trapping
Lines 8400-8499 | GENERROR
Lines 9000-9155 | GENDATE
Lines 9990-9999 | QUIT logic
If you have custom codes in these areas, renumber it to an unused area.

5. Merge the main conversion lines and any custom code from your existing conversion program into the skeleton. Generally this is lines 2000–3999 and any other custom routines that do not fall into the ranges of code used by the skeleton program.
6. Change file opening logic as follows:
   old: GOSUB 5200
   new: GOSUB 4500.
7. Change file error message logic as follows:
   old: GOSUB 5695
   new: LET LOG=1; GOSUB 4800
8. Change any other messages that have been used on the error log, based on the chart above under Method 1.
9. To copy files, GOSUB 4200 and use the following logic for each file:
   `LET F$=“<filename>“+STBL(“CID”); GOSUB COPYFILE`
10. Change line 9997. For the last program in the chain (the current version),
    `LET PGM1$=“RMCONVER”`
    to let the driver know that the application is finished. For all other programs in the chain,
    `LET PGM1$=APPLDIR$+FILENAME$; REM “the next conversion program in the chain”`
11. If desired, change any conversion sections to use the new standard for converting a data file. Starting at version 7.5, OSAS introduced a new mechanism for converting a single data file, given 2 templates: the prior version’s template, and the current version’s template. Use the program “GENCVTTP.PUB to perform this proces. A sample code section follows:
    0010 LET CHAN=UNT,F$="INVE"+STBL("CID")
    1580 REM "----- ARCUx File"
    1590 LET F$="ARCU"+COMP$,RETURNLINE=9; GOSUB 4500; IF FAIL THEN GOTO 1720
    1600 REM LET F$=DESTDIR$+"ARCU"+COMP$+".EM",TASK=0,F0=75,GENOPEN.CRYP=0; GOSUB GENOPEN
    1610 READ (FILE[OLDTPLCH],KEY="ARCU")*,TPL$; DIM OLDARCU$:TPL$
    1620 READ (OSTPLCH,KEY="ARCU")*,TPL$; DIM NEWARCU$:TPL$,DEFAULT$:TPL$, PAD$:TPL$,ALIGNMENT$:TPL$
    1630 RET9:
    1640 LET COPY.CHAN1=SOURCECH,COPY.CHAN2=DESTCH
    1650 LET DEFAULT.STAT$="A",DEFAULT.RSV5$=FILL(48),DEFAULT.RSV6$=FILL(50)
    1660 LET COPY.SPECIAL$=STBL("ARDIR")+"ARCNVT.750::CUSTOMER_FILE"
    1670 CALL "GENCVTTP.PUB",FILE[ALL],COPY$,OLDARCU$,NEWARCU$,DEFAULT$, PAD$,ALIGNMENT$,MSG$,OSGUI$
    1680 IF MSG$<>"" THEN GOSUB ERRORLOG
    1690 LET RETURNLINE=10
    1700 RET10:
    1710 CLOSE (SOURCECH); CLOSE (DESTCH)
    This code sample works as follows:

- 1590 - Opens up the ARCUx file
- 1610 - Reads the old template from OSTPL.700 and dimensions OLDARCU$ to that string

- 1620 - Reads the current tempate from OSTPL and dimensions NEWARCU$, DEFAULT$, PAD$, and ALIGNMENT$ to that string
- 1640 - Sets the proper channels of the old and new file into the COPY template
- 1650 - Set DEFAULT.STAT$ (customer status) to “A” (for active), and sets two reserved fields to 48 and 50 spaces respectively
- 1660 - Sets a special program to call when converting each record of the ARCUx file
- 1670 - Calls GENCVTTP.PUB to conver the file
  See the section on GENCVTTP.PUB in chapter 3 for a definition on each template used by GENCVTTP.PUB.