jump to navigation

Convert any iSeries database file to CSV format July 2, 2006


Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /homepages/26/d120742039/htdocs/Norm/iseries/wordpress/wp-content/plugins/technotag.php on line 30

Here is a utility that will convert any iSeries database file to CSV (Comma Seperated Values) format with a delimiter of your choice. You can choose the delimiter
because it is very possible to have a comma in a description. So choose wisely.

I was forced to write this utility and here is why. I had a project to transfer data files from the iSeries 400 to a server that was running California Software Baby 400 system.

Seems simple enough just use the CPYFRMSTMF command or the CPYFRMIMPF right?
Yeah I thought so too. Well as I tried to use these commands as I have used them before and they work just fine if you have a good database file. But IBM did not think of everything
that programmers can do to a database file.

In my case I ran across (and not in just one file) packed numeric data. So what is the problem you ask? The data length of these packed fields were 1 bytes and 2 bytes. Why would you pack a 1 byte numeric field or even a 2 byte numeric field? The above mentioned command did not stop but they did not work either. Can you guess what they did? ……. Ok times up, they took those fields and extended them by 1 byte so the 1 byte packed became 2 bytes and the 2 bytes became 3 bytes. No matter what I did I could not get the file converted correctly on iSeries.

So either I can write a 100 or so programs (which I decided not to do) or write a utility to do all the work for me. Which is what I did and I am sharing this with whoever wants to use it. Feel free to use it and to make what ever changes you need for your use.

All the work is done in QTEMP. The process creates a work file call CVFILEO and a
temporary library with QRPGLESRC and a temporary program called CVPGM. The temp library is the use name with a ‘@’ in front of it. Example: if the user name is kfoland
the library name will be @kfoland.

So we have one work file called CVFILEO.
One command called CVF2CSV. Compiled to call CV0CL.
Two CL programs CV0CL and CV1CL.
Two RPGLE programs CV1 and CV2.

The simple process is as follows:

1. Delete temp files
2. Create duplicate object CVFILEO into QTEMP
3. Display field description on the incoming file into a file called CVFILE
4. Call CV1 to get the record length and call CV1CL to build the flat file with the given
record length.
5. Create the temp library.
6. Create QRPGLESRC in the temp library
7. Add the physical file member CVPGM to QRPGLESRC in the temp library
8. Call CV2 to read the incoming file and to create the temp program CVPGM.
9. Compile CVPGM
10. Call CVPGM
11. Copy the flat file from QTEMP to the out going file.

To get started, compile the file, command and the programs.

Prompt up the command and fill out the parms or just call CV0VL with the following parms.

PARM(&FILE &LIBR &TFILE &TLIBR &DEM)

where

&FILE = database file to be converted
&LIBR = library were the database file is located
&TFILE = name you want for the converted file
&TLIBR = library where the converted file will be
&DEM = the delimiter you want to use. Choose wisely

After the process runs you can check out the temp library and the program that was created in QSYS as the library will get deleted at the beginning of the process. You can change this if you want to delete the library at the end of the process. The process will delete any files or libraries in QTEMP as it runs.

This has help me so I hope it can help others as well.


  1. /********************************************/
  2. /* COMMAND NAME IS CVF2CSV                                   */
  3. /* This command will call CV0CL to convert a database file*/
  4. /* to CSV format with your choice of delimiter                 */
  5. /********************************************/
  6.  
  7.              CMD        PROMPT(‘Convert File to CSV Format’)
  8.              PARM       KWD(FROMFILE) TYPE(*CHAR) LEN(10) +
  9.                           PROMPT(‘Enter File to Convert’)
  10.              PARM       KWD(FROMLIBR) TYPE(*CHAR) LEN(10) +
  11.                           PROMPT(‘Enter Library for Input File’)
  12.              PARM       KWD(TOFILE) TYPE(*CHAR) LEN(10) +
  13.                           PROMPT(‘Converted File Name’)
  14.              PARM       KWD(TOLIBR) TYPE(*CHAR) LEN(10) +
  15.                           PROMPT(‘Library for Converted File’)
  16.              PARM       KWD(DELIMITER) TYPE(*CHAR) LEN(1) DFT(‘~’) +
  17.                           PROMPT(‘Delimiter’)

  1. /******************************************/
  2. /* CL name is cv0cl                                                  */
  3. /* CL to run the process to convert a file passed to csv */
  4. /* file format                                                          */
  5. /******************************************/
  6.  
  7.              PGM        PARM(&FILE &LIBR &TFILE &TLIBR &DEM)
  8.              DCL        VAR(&LIBR)   TYPE(*CHAR) LEN(10)
  9.              DCL        VAR(&FILE)   TYPE(*CHAR) LEN(10)
  10.              DCL        VAR(&TLIBR)  TYPE(*CHAR) LEN(10)
  11.              DCL        VAR(&TFILE)  TYPE(*CHAR) LEN(10)
  12.              DCL        VAR(&USER)   TYPE(*CHAR) LEN(10)
  13.              DCL        VAR(&WLIBR)  TYPE(*CHAR) LEN(10)
  14.              DCL        VAR(&DEM)    TYPE(*CHAR) LEN(1)
  15.              DCL        VAR(&LENGTH) TYPE(*CHAR) LEN(5)
  16.              DCL        VAR(&MSGID)  TYPE(*CHAR) LEN(7)
  17.              DCL        VAR(&MSG)    TYPE(*CHAR) LEN(100)
  18.              DCL        VAR(&MSGF)   TYPE(*CHAR) LEN(10)
  19.              MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
  20.              RTVJOBA    USER(&USER)
  21.              CHKOBJ     OBJ(&LIBR/&FILE) OBJTYPE(*FILE)
  22.              DLTF       FILE(QTEMP/CVFILE)
  23.              MONMSG     MSGID(CPF0000)
  24.              DLTF       FILE(QTEMP/CVFLAT)
  25.              MONMSG     MSGID(CPF0000)
  26.              DLTF       FILE(QTEMP/CVFILEO)
  27.              MONMSG     MSGID(CPF0000)
  28.              CRTDUPOBJ  OBJ(CVFILEO) FROMLIB(KFOLAND) OBJTYPE(*FILE) +
  29.                           TOLIB(QTEMP)
  30.              DSPFFD     FILE(&LIBR/&FILE) OUTPUT(*OUTFILE) +
  31.                           OUTFILE(QTEMP/CVFILE)
  32.              OVRDBF     FILE(CVFILE) TOFILE(QTEMP/CVFILE)
  33.              OVRDBF     FILE(CVFILEO) TOFILE(QTEMP/CVFILEO)
  34.              CALL       PGM(CV1) PARM(&LENGTH)
  35.              IF         COND(&LENGTH *NE ‘00000′) THEN(DO)
  36.              CHGVAR     VAR(&WLIBR) VALUE(‘@’ *TCAT %SUBSTRING(&USER +
  37.                           1 9))
  38.  
  39. /* create the temp library for the temp program             */
  40.  
  41.              DLTLIB     LIB(&WLIBR)
  42.              MONMSG     MSGID(CPF0000)
  43.              CRTLIB     LIB(&WLIBR)
  44.              CRTSRCPF   FILE(&WLIBR/QRPGLESRC) RCDLEN(112)
  45.              ADDPFM     FILE(&WLIBR/QRPGLESRC) MBR(cvpgm) +
  46.                           TEXT(‘Convert program’) SRCTYPE(RPGLE)
  47.              OVRDBF     FILE(cvpgm) TOFILE(&WLIBR/QRPGLESRC) +
  48.                           MBR(cvpgm)
  49.              OVRDBF     FILE(CVFLAT) TOFILE(QTEMP/CVFLAT)
  50.              CALL       PGM(CV2) PARM(&FILE &LENGTH &DEM)
  51.              DLTOVR     FILE(*ALL)
  52.              OVRDBF     FILE(&FILE) TOFILE(&LIBR/&FILE)
  53.              CRTBNDRPG  PGM(&WLIBR/CVPGM) SRCFILE(&WLIBR/QRPGLESRC) +
  54.                           OUTPUT(*PRINT)
  55.              OVRDBF     FILE(&FILE) TOFILE(&LIBR/&FILE)
  56.              OVRDBF     FILE(CVFLAT) TOFILE(QTEMP/CVFLAT)
  57.              CALL       PGM(&WLIBR/cvpgm)
  58.              DLTOVR     FILE(*ALL)
  59.              CPYF       FROMFILE(QTEMP/CVFLAT) TOFILE(&TLIBR/&TFILE) +
  60.                           MBROPT(*REPLACE) CRTFILE(*YES)
  61.              ENDDO
  62.              GOTO       CMDLBL(ENDPGM)
  63.              /*                                                      */
  64.              /*—————————————*/
  65.              /* NORMAL PROGRAM EXIT                      */
  66.              /*—————————————*/
  67.              /*                                                      */
  68.  
  69.  EXIT:       GOTO       CMDLBL(ENDPGM)
  70.              /*                                                      */
  71.              /*—————————————*/
  72.              /*  ERROR HANDLING ROUTINE                 */
  73.              /*—————————————*/
  74.              /*                                                      */
  75.  
  76.  ERROR:      RCVMSG     MSGDTA(&MSG) MSGID(&MSGID) MSGF(&MSGF)
  77.              MONMSG     MSGID(CPF0000)
  78.              SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGF) MSGDTA(&MSG) +
  79.                           MSGTYPE(*ESCAPE)
  80.              MONMSG     MSGID(CPF0000)
  81.              GOTO       CMDLBL(ENDPGM)
  82.              /*                                                      */
  83.              /*                                                      */
  84.  
  85.  ENDPGM:     ENDPGM

  1. H OPTION(*Srcstmt : *Nodebugio)
  2.      A********************************************
  3.      A* program name IS cv1                                                *
  4.      A* figure the record length of the file being converted        * 
  5.      A********************************************
  6.      A*
  7.      fCvfile    IF   e             Disk    Usropn
  8.      fCvfileo   o    e             Disk
  9.      A*
  10.      d @Total          s              5  0
  11.      d @FIELDS         s              5  0
  12.      d @Start          s              5  0
  13.      d @Length         s              5
  14.      A*   
  15.      c     *Entry        Plist
  16.      c                   Parm                    @Length
  17.      A* Open AND READ the file AND figure the new length
  18.      A* after ALL the packed FIELDS are unpacked
  19.      c                   Open      Cvfile
  20.      c                   DoU       %Eof(Cvfile)
  21.      c                   READ      Cvfile
  22.      c                   IF        NOT %Eof(Cvfile)
  23.      c
  24.      A*   
  25.      c                   Eval      @FIELDS = Whnfld
  26.      A* IF packed then USE the unpacked length
  27.      c                   IF        Whfldt = ‘P’
  28.      c                   Eval      Whfldb = Whfldd
  29.      c                   EndIf
  30.      c                   IF        Whfldt = ‘A’
  31.      c                   Eval      @Total = @Total + 2
  32.      c                   EndIf
  33.      c                   IF        Whfldp <> *Zeros
  34.      c                   Eval      @Total = @Total + 2
  35.      c                   EndIf
  36.      A* ADD TO get the new total record length
  37.      c                   Eval      @Total = @Total + Whfldb
  38.      A*   
  39.      A*   
  40.      c                   EndIf
  41.      c                   EndDo
  42.      A*
  43.      c                   Close     Cvfile
  44.      c                   Eval      @Total = @Total + @FIELDS
  45.      c                   Move      @Total        @Length
  46.      c                   IF        @Total <> *Zeros
  47.      A* CREATE the flat file
  48.      c                   Call      ‘CV1CL’
  49.      C                   Parm                    @Total
  50.      A*   
  51.      c                   EndIf
  52.      A*   
  53.      c                   Eval      @Start = 0
  54.      A* Open AND READ the file AND output info TO work file
  55.      c                   Open      Cvfile
  56.      c                   DoU       %Eof(Cvfile)
  57.      c                   READ      Cvfile
  58.      c                   IF        NOT %Eof(Cvfile)
  59.      A*   
  60.      A* IF packed then USE the unpacked length
  61.      c                   IF        Whfldt = ‘P’
  62.      c                   Eval      Whfldb = Whfldd
  63.      c                   Eval      Whfldt = ‘S’
  64.      c                   EndIf
  65.      A*   
  66.      c                   IF        @Start = *Zeros
  67.      c                   Eval      @Start  = 1
  68.      c                   Eval      Cvstart = 1
  69.      c                   Eval      Cvend   = Whfldb
  70.      c                   Else
  71.      c                   Eval      Cvstart = Cvend + 1
  72.      c                   Eval      Cvend   = Cvend + Whfldb
  73.      c                   EndIf
  74.      A*   
  75.      c                   Eval      Cvfname  = Whfile
  76.      c                   Eval      Cvfield  = Whfldi
  77.      c                   Eval      Cvtype   = Whfldt
  78.      c                   Eval      Cvlength = Whfldb
  79.      c                   Eval      Cvdec    = Whfldp
  80.      c                   Eval      Cvformat = Whname
  81.      c                   WRITE     Cvrec
  82.      A*   
  83.      A*
  84.      c                   EndIf
  85.      c                   EndDo
  86.      c                   Close     Cvfile
  87.      A*   
  88.      A*   
  89.      c                   Eval      *Inlr = *ON

  1. /*****************************************************/
  2. /* cl name is cv1cl                                  */
  3. /* cl to build a temp flat file based on parms sent  */
  4. /* into the program                                  */
  5. /*****************************************************/
  6.  
  7.              PGM        PARM(&LENGTH)
  8.              DCL        VAR(&LENGTH) TYPE(*DEC) LEN(5 0)
  9.              DLTF       FILE(QTEMP/CVFLAT)
  10.              MONMSG     MSGID(CPF0000)
  11.              CRTPF      FILE(QTEMP/CVFLAT) RCDLEN(&LENGTH)
  12.  END:        ENDPGM

  1. H OPTION(*Srcstmt : *Nodebugio)
  2.      A**********************************************************************
  3.      A* program name IS cv2                                                *
  4.      A* this program will WRITE the program needed TO convert the file     *
  5.      A* TO CSV format                                                      *
  6.      A**********************************************************************
  7.      A*
  8.      fCvfileo   IF   e             Disk      Prefix(x_) Usropn
  9.      fCvpgm     uf a f  114        Disk
  10.      A*
  11.      d Rspec           Ds
  12.      d  Rrec                        112
  13.      A*
  14.      d @File           s             10
  15.      d @Length         s              5
  16.      d @Dem            s              1
  17.      d @Char5          s              5
  18.      d @Char2          s              2
  19.      d @Cvfield        s                   LIKE(x_Cvfield)
  20.      A*   
  21.      A* output the first d spec record
  22.      c                   Eval      %Subst(Rrec:18:1)   = ‘d’
  23.      c                   Eval      %Subst(Rrec:20:18)  = ‘Key             S ‘
  24.      c                   Eval      %Subst(Rrec:50:2)   = ‘10′
  25.      c                   Except    Drecadd
  26.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  27.      A* output the first d spec record
  28.      c                   Eval      %Subst(Rrec:20:18)  = ‘FlatDs          Ds’
  29.      c                   Except    Drecadd
  30.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  31.      A*   
  32.      A* open the file AND output the rest of the d spec
  33.      c                   Open      Cvfileo
  34.      c                   DoU       %Eof(Cvfileo)
  35.      c                   READ      Cvfileo
  36.      c                   IF        NOT %Eof(Cvfileo)
  37.      A*   
  38.      c                   IF        x_Cvtype = ‘A’
  39.      c                   Eval      %Subst(Rrec:51:13) = ‘1a   Inz(’‘"’‘)’
  40.      c                   Except    Drecadd
  41.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  42.      c                   EndIf
  43.      A* IF there IS a decimal then increase the length BY 2
  44.      A* this IS TO allow FOR the decimal IN the flat file
  45.      A* AND FOR the sign
  46.      c                   IF        x_Cvdec > *Zeros
  47.      c                   Eval      x_Cvlength = x_Cvlength + 2
  48.      c**                 Eval      %Subst(Rrec:56:9) = ‘Inz      ‘
  49.      c                   EndIf
  50.      A* the FIELD name IN the program can NOT be the same
  51.      A* AS the file name.
  52.      c                   IF        x_Cvfield = x_Cvformat
  53.      c                   Eval      x_Cvfield = ‘xx        ‘
  54.      c                   EndIf
  55.      A*   
  56.      c                   Move      x_Cvlength    @Char5
  57.      c                   Eval      %Subst(Rrec:19:18)  = x_Cvfield
  58.      c                   Eval      %Subst(Rrec:47:5)  = @Char5
  59.      c*                  Eval      %Subst(Rrec:52:1)  = x_Cvtype
  60.      c                   Eval      %Subst(Rrec:52:1)  = ‘a’
  61.       *   
  62.      c*                  IF        x_Cvtype = ‘S’
  63.      c*                  Move      x_Cvdec       @Char2
  64.      c*                  Eval      %Subst(Rrec:53:2)  = @Char2
  65.      c*                  Else
  66.      c                   Eval      %Subst(Rrec:53:2)  = ‘  ‘
  67.      c*                  EndIf
  68.      A*   
  69.      c                   Except    Drecadd
  70.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  71.      A*   
  72.      c                   IF        x_Cvtype = ‘A’
  73.      c                   Eval      %Subst(Rrec:51:13) = ‘1a   Inz(’‘"’‘)’
  74.      c                   Except    Drecadd
  75.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  76.      c                   EndIf
  77.      A* SET the delimiter
  78.      c                   Eval      %Subst(Rrec:51:13) = ‘1a   Inz(’‘ ‘‘)’
  79.      c                   Eval      %Subst(Rrec:61:1) = @Dem
  80.      c                   Except    Drecadd
  81.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  82.      A*   
  83.      c                   EndIf
  84.      c                   EndDo
  85.      A* close the file FOR the c spce
  86.      c                   Close     Cvfileo
  87.      A****************************************************************************
  88.      A*   
  89.      A* output the first c spec record
  90.      c                   Eval      %Subst(Rrec:18:1)   = ‘c’
  91.      c                   Eval      %Subst(Rrec:38:3)  = ‘DoU’
  92.      c                   Eval      %Subst(Rrec:48:16)  = ‘%Eof(          )’
  93.      c                   Eval      %Subst(Rrec:53:10)  = @File
  94.      A*   
  95.      c                   Except    Crecadd
  96.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  97.      A*   
  98.      c                   Eval      %Subst(Rrec:38:18)  = ‘                  ‘
  99.      c                   Eval      %Subst(Rrec:38:4)  = ‘Read’
  100.      c                   Eval      %Subst(Rrec:48:10)  = @File
  101.      A*   
  102.      c                   Except    Crecadd
  103.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  104.      A*   
  105.      c                   Eval      %Subst(Rrec:38:18)  = ‘                  ‘
  106.      c                   Eval      %Subst(Rrec:38:3)  = ‘If ‘
  107.      c                   Eval      %Subst(Rrec:48:20)  = ‘Not %Eof(          )’
  108.      c                   Eval      %Subst(Rrec:57:10)  = @File
  109.      A*   
  110.      c                   Except    Crecadd
  111.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  112.      A*   
  113.      A* open the file AND output the rest of the c specs
  114.      c                   Open      Cvfileo
  115.      c                   DoU       %Eof(Cvfileo)
  116.      c                   READ      Cvfileo
  117.      c                   IF        NOT %Eof(Cvfileo)
  118.      A* save FIELD name
  119.      c                   Eval      @Cvfield = x_Cvfield
  120.      A* the FIELD name IN the program can NOT be the same
  121.      A* AS the file name.
  122.      c                   IF        x_Cvfield = x_Cvfname
  123.      c                   Eval      x_Cvfield = ‘xx        ‘
  124.      c                   EndIf
  125.      A*   
  126.      A* SET up the KEY AND the chain TO CHECK FOR decimals
  127.      c                   IF        x_Cvdec > *Zeros
  128.      A*
  129.      c                   Eval      %Subst(Rrec:38:6)   = ‘Clear ‘
  130.      c                   Eval      %Subst(Rrec:62:10)  = ‘Key       ’
  131.      c                   Except    Crecadd
  132.      c                   Eval      %Subst(Rrec:38:6)   = ‘MoveL ‘
  133.      c                   Eval      %Subst(Rrec:48:1)   =
  134.      c                   Eval      %Subst(Rrec:49:10)  = %subst(x_Cvfield:1:10)
  135.      c                   Eval      %Subst(Rrec:59:1)   =
  136.      c                   Eval      %Subst(Rrec:62:10)  = ‘Key       ’
  137.      c                   Except    Crecadd
  138.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  139.      A*   
  140.      A* do the chain
  141.      c                   Eval      %Subst(Rrec:24:10)  = ‘Key       ’
  142.      c                   Eval      %Subst(Rrec:38:6)   = ‘Chain ‘
  143.      c                   Eval      %Subst(Rrec:48:7)   = ‘Cvfileo’
  144.      c                   Except    Crecadd
  145.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  146.      c                   Eval      %Subst(Rrec:38:6)   = ‘If    ‘
  147.      c                   Eval      %Subst(Rrec:48:17)  = ‘Z_Cvdec <> *Zeros’
  148.      c                   Except    Crecadd
  149.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  150.      c                   Eval      %Subst(Rrec:38:6)   = ‘Eval  ‘
  151.      c***************    Eval      %Subst(Rrec:48:2)   = ‘x_’
  152.      c                   Eval      %Subst(Rrec:48:10)  = x_Cvfield
  153.      c                   Eval      %Subst(Rrec:60:9)   = ‘= %Editc(’
  154.      c                   Eval      %Subst(Rrec:69:2)   = ‘x_’
  155.      c                   Eval      %Subst(Rrec:71:10)  = x_Cvfield
  156.      c                   Eval      %Subst(Rrec:81:5)   = ‘:’‘P’‘)’
  157.      c                   Except    Crecadd
  158.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  159.      c                   Eval      %Subst(Rrec:38:6)   = ‘Else  ‘
  160.      c                   Except    Crecadd
  161.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  162.      A*   
  163.      c                   EndIf
  164.      A*   
  165.      c                   Eval      %Subst(Rrec:38:6)   = ‘Move  ‘
  166.      c                   Eval      %Subst(Rrec:48:2)   = ‘x_’
  167.      c                   Eval      %Subst(Rrec:50:10)  = @Cvfield
  168.      c                   Eval      %Subst(Rrec:62:10)  = x_Cvfield
  169.      c                   Except    Crecadd
  170.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  171.      A*
  172.      c                   IF        x_Cvdec > *Zeros
  173.      A*
  174.      c                   Eval      %Subst(Rrec:38:6)   = ‘EndIf ‘
  175.      c                   Except    Crecadd
  176.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  177.      c                   EndIf
  178.      A*   
  179.      c                   EndIf
  180.      c                   EndDo
  181.      A* close the file
  182.      c                   Close     Cvfileo
  183.      A*   
  184.      c                   Eval      %Subst(Rrec:38:6)   = ‘Except’
  185.      c                   Eval      %Subst(Rrec:48:7)   = ‘Flatout’
  186.      c                   Except    Crecadd
  187.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  188.      A*   
  189.      c                   Eval      %Subst(Rrec:38:5)   = ‘EndIf’
  190.      c                   Except    Crecadd
  191.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  192.      A*   
  193.      c                   Eval      %Subst(Rrec:38:5)   = ‘EndDo’
  194.      c                   Except    Crecadd
  195.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  196.      A*   
  197.      c                   Eval      %Subst(Rrec:38:4)   = ‘Eval’
  198.      c                   Eval      %Subst(Rrec:48:11)  = ‘*Inlr = *On’
  199.      c                   Except    Crecadd
  200.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  201.      A****************************************************************************
  202.      A*   
  203.      A* output the o specs
  204.      c                   Eval      %Subst(Rrec:18:1)   = ‘o’
  205.      c                   Eval      %Subst(Rrec:19:10)  = ‘Cvflat    ‘
  206.      c                   Eval      %Subst(Rrec:29:4)  = ‘eadd’
  207.      c                   Eval      %Subst(Rrec:42:7)  = ‘Flatout’
  208.      c                   Except    Orecadd
  209.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  210.      A*   
  211.      c                   Eval      %Subst(Rrec:19:10)  = ‘          ‘
  212.      c                   Eval      %Subst(Rrec:29:4)  = ‘    ‘
  213.      c                   Eval      %Subst(Rrec:42:7)  = ‘Flatds ‘
  214.      c                   Except    Orecadd
  215.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  216.      A*   
  217.      c                   Eval      *Inlr = *ON
  218.      A*******************************************************
  219.      A* first time processing                               *
  220.      A*******************************************************
  221.      c     *Inzsr        Begsr
  222.  
  223.      c     *Entry        Plist
  224.      c                   Parm                    @File
  225.      c                   Parm                    @Length
  226.      c                   Parm                    @Dem
  227.      A*
  228.      A* output the h spec record
  229.      c                   Eval      %Subst(Rrec:18:1)  = ‘h’
  230.      c*                  Eval      %Subst(Rrec:20:29) =
  231.      c*                            ‘Option(*Srcstmt : *Nodebugio)’
  232.      c                   Except    Hrecadd
  233.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  234.      A*
  235.      A* open the file AND CHECK FOR formant name
  236.      c                   Open      Cvfileo
  237.      c                   READ      Cvfileo
  238.      c                   Close     Cvfileo
  239.      A* output the f spec record
  240.      c                   Eval      %Subst(Rrec:18:1)  = ‘f’
  241.      c                   Eval      %Subst(Rrec:19:10) = @File
  242.      c                   Eval      %Subst(Rrec:29:6) = ‘if   e’
  243.      c                   Eval      %Subst(Rrec:48:4) = ‘Disk’
  244.      c                   Eval      %Subst(Rrec:56:10) = ‘Prefix(x_)’
  245.      c                   Except    Frecadd
  246.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  247.      A*
  248.      c                   IF        x_Cvfname = x_Cvformat
  249.      c                   Eval      %Subst(Rrec:56:7)  = ‘Rename(’
  250.      c                   Eval      %Subst(Rrec:63:10) = x_Cvformat
  251.      c                   Eval      %Subst(Rrec:73:3)  = ‘:x)’
  252.      c                   Except    Frecadd
  253.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  254.      c                   EndIf
  255.      A*
  256.      A* output the f spec record
  257.      c                   Eval      %Subst(Rrec:18:1)  = ‘f’
  258.      c                   Eval      %Subst(Rrec:19:10) = ‘Cvflat    ‘
  259.      c                   Eval      %Subst(Rrec:29:6) = ‘uf a f’
  260.      c                   Eval      %Subst(Rrec:35:5) = @Length
  261.      c                   Eval      %Subst(Rrec:48:4) = ‘Disk’
  262.      c                   Except    Frecadd
  263.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  264.      A* output the last  f spec record
  265.      c                   Eval      %Subst(Rrec:18:1)  = ‘f’
  266.      c                   Eval      %Subst(Rrec:19:10) = ‘Cvfileo   ’
  267.      c                   Eval      %Subst(Rrec:29:6) = ‘if   e’
  268.      c                   Eval      %Subst(Rrec:46:6) = ‘k Disk’
  269.      c                   Eval      %Subst(Rrec:56:10) = ‘Prefix(z_)’
  270.      c                   Except    Frecadd
  271.      c                   Eval      %Subst(Rrec:19:93) = *Blanks
  272.      A*
  273.      A*
  274.      c     #Inzsr        Endsr
  275.      A*
  276.      oCvpgm     eadd         Hrecadd
  277.      o                       Rrec
  278.      A*
  279.      o          eadd         Frecadd
  280.      o                       Rrec
  281.      A*
  282.      o          eadd         Drecadd
  283.      o                       Rrec
  284.      A*
  285.      o          eadd         Crecadd
  286.      o                       Rrec
  287.      A*
  288.      o          eadd         Orecadd
  289.      o                       Rrec

  1. A* FILE NAME CVFILEO
  2.      A* CONVERSION WORK FILE
  3.      A*
  4.      A          R CVREC
  5.      A*
  6.      A            CVFNAME       10A         TEXT(‘FILE  NAME’)
  7.      A            CVFIELD       10A         TEXT(‘FIELD NAME’)
  8.      A            CVTYPE         1A         TEXT(‘FIELD TYPE’)
  9.      A            CVSTART        5S 0       TEXT(‘FIELD START’)
  10.      A            CVEND          5S 0       TEXT(‘FIELD END  ‘)
  11.      A            CVLENGTH       5S 0       TEXT(‘FIELD LENGTH’)
  12.      A            CVDEC          2S 0       TEXT(‘FIELD DEC   ’)
  13.      A            CVFORMAT      10A         TEXT(‘FIELD FORMAT’)
  14.      A*
  15.      A          K CVFIELD

Comments»

1. Harish Keshwani - July 2, 2006

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /homepages/26/d120742039/htdocs/Norm/iseries/wordpress/wp-content/plugins/technotag.php on line 30

Thank-you Kevin for a very useful utility! I will be loading Kevin’s utility in a downloadable form soon.