PageRenderTime 65ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/ebcdic-t.txt

https://bitbucket.org/chriz/z_vedit
Plain Text | 1700 lines | 1278 code | 422 blank | 0 comment | 0 complexity | dca44a05cdc47e2f41e3e69e943ca024 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. Documentation for the EBCDIC Conversion Package (Trial Level 2)
  2. ---------------------------------------------------------------
  3. Written by: Ted Green and Thomas C. Burt
  4. Last change: 10/16/2003
  5. Introduction
  6. ------------
  7. The VEDIT Level-2 EBCDIC package converts EBCDIC files into ASCII with any
  8. number of packed-decimal, binary, zoned, text and "ignore" fields.
  9. The converted ASCII records can optionally have newline characters, e.g.
  10. Carriage-Return and Line-Feed, appended to the end of each converted record.
  11. They can also be output in DBASE format, with the DBASE header record being
  12. automatically generated.
  13. Other output options include quoting-and-comma delimiting each field or
  14. appending a user specified delimiter string after each field; converting an
  15. all-blank or null numeric field to zeros; and emitting an explicit decimal
  16. point.
  17. For EBCDIC to ASCII conversions, the converted file is normally saved as
  18. "filename.ASC"; for DBASE output, the default extension is ".DBF". Or, the
  19. user may explicitly give the output filename. In no case is the source data
  20. file altered.
  21. Any conversion errors can optionally be reported in the file "ebcdic.err".
  22. This file is initially deleted; therefore, a batch file can test for its
  23. existence to determine whether there were any errors.
  24. The conversion is completely controlled by a ".LAY" data layout file which
  25. the user must create once for each type of file to be converted. This layout
  26. file primarily lists the beginning and ending columns for each field and the
  27. data type of the field. It also specifies the record length and specifies
  28. whether newline characters are to be appended to the end of each converted
  29. record.
  30. As described below, a COBOL "copy-book" can often be automatically converted
  31. into a .LAY data layout file. Therefore, we highly recommend that you
  32. procure the "copy-book" for your data file(s).
  33. Once the .LAY data layout file has been created, the conversion macro can
  34. be manually run from within VEDIT, or automatically run from either a
  35. Window's icon or a DOS or NT command line. The macro runs without any user
  36. interaction and, when done, saves the converted file and displays it on the
  37. screen. Optionally, the macro can automatically exit, in which case the
  38. conversion requires no user interaction whatsoever.
  39. To convert many files, EBCDIC-T.VDM can be used with the menu function {MISC,
  40. WILDFILE macro} to automatically convert entire groups of files, e.g. all
  41. files in a directory.
  42. The speed of the conversion depends both on the size of the file and the
  43. number of packed fields per record. The conversion speed is typically 10
  44. megabytes per minute on a 1000mhz Pentium.
  45. NOTES: A custom conversion can also be performed on any desired fields using
  46. a custom written VEDIT macro. This is described in more detail later.
  47. The conversion supports additional technical options which are
  48. not described here. Please examine the description at the beginning
  49. of the EBCDIC-T.VDM file for additional details. The following
  50. capabilities of the Level-2 package are not described here:
  51. * Preprocessing and postprocessing.
  52. * Appending or prefixing padding characters to any specified field.
  53. Greenview Data is available on a contract basis to perform any part
  54. of the conversion for you, including creating the data layout file or
  55. even translating the EBCDIC file(s) that you supply. If you do not
  56. have the packed field locations for your file, we can often examine
  57. the file and determine them for you.
  58. EBCDIC Conversion Files
  59. -----------------------
  60. Assuming you chose to include the "EBCDIC conversion files" during
  61. installation, you will have the following files in the VEDIT Home Directory,
  62. e.g. in "c:\vedit" or "c:\program files\vedit":
  63. EBCDIC-T.VDM The trial version of the EBCDIC Level 2 conversion macro
  64. described here. (Do not modify this file).
  65. EBCDIC-2.VCM EBCDIC conversion submacros; used only by custom macros;
  66. loaded automatically during preprocessing if any custom
  67. field ("c") is encountered. (Do not modify this file).
  68. COBOL2V.VDM The COBOL copy-book preprocessor. This is used by
  69. EBCDIC-T.VDM. It may also be run independently. (Do not
  70. modify this file).
  71. RELAY.VDM Generate output column numbers from a data layout (.lay)
  72. file. Handles quoted-comma-delimited fields and user
  73. specified field separators. This is used by COBOL2V.VDM. It
  74. may also be run independently. (Do not modify this file).
  75. REGPREP.VDM Used by EBCDIC-T.VDM to streamline the macro code, making
  76. it run faster. (Do not modify this file).
  77. EBCDIC.LAY A simple prototype data layout file to help you get started.
  78. It supports EBCDIC files with uniform fixed-length records.
  79. NOTE: You must edit this file, as described below, before
  80. converting any files.
  81. COBOL.COP A sample COBOL "Copy-Book" corresponding to sample data file
  82. COBOL.EBC.
  83. COBMIX.LAY A prototype data layout file produced from COBOL.COP, above.
  84. Includes some initial .LAY specifications.
  85. COBOL.LAY A prototype data layout file produced from COBMIX.LAY,
  86. above. Converted by COBOL2V.VDM and RELAY.VDM into standard
  87. .LAY format.
  88. COBOLD.LAY A prototype layout file to produce DBASE output.
  89. Not supplied. Generated as stated in "Quick DBASE Test", q.v.
  90. COBOL.EBC A small example EBCDIC file with a layout corresponding to
  91. COBOL.COP.
  92. COBOL.ASC The converted ASCII file made from the example COBOL.EBC
  93. file.
  94. COBOL.DBF The converted ASCII file in DBASE format made from COBOL.EBC
  95. via COBOLD.LAY.
  96. EBCDIC-T.BAT A batch file for automating the conversion process.
  97. Win 95/98/NT/2000/XP users can create a shortcut icon to this
  98. batch file for "drag and drop" conversion.
  99. EBCDIC-T.TXT This documentation file.
  100. LEADZERO.CUS An example of a custom macro for processing custom fields.
  101. This macro converts unpacked EBCDIC numbers to ASCII and then
  102. strips any leading zeroes. It optionally inserts a period
  103. before the second-last or third-last digit.
  104. UNPAKDEC.VDM A high-speed EBCDIC conversion macro that supports up to 32
  105. packed-decimal fields.
  106. UNPAKDEC.TXT Documentation file for the UNPAKDEC.VDM macro.
  107. Quick Test
  108. ----------
  109. You can perform a quick test by converting the supplied COBOL.EBC file using
  110. the supplied COBOL.LAY data layout (COBOL copy-book) file. From a DOS/NT
  111. command box, change to the directory containing VEDIT and into which you
  112. placed the EBCDIC conversion file. This is typically "c:\vedit". Then, give
  113. the command:
  114. vpw -x ebcdic-t.vdm cobol.ebc cobol.lay
  115. This will leave you in the VEDIT editor with the converted file displayed.
  116. Alternatively, to automatically save the file and exit, give the command:
  117. vpw -y -x ebcdic-t.vdm cobol.ebc cobol.lay
  118. The following section "Performing the Conversion (Automatically)" describes
  119. this in more detail.
  120. NOTE: The easiest way to perform this quick test is to open a DOS box in
  121. Windows, change to the directory containing the VEDIT file, (e.g.
  122. with the DOS command "cd \vedit") and then enter the commands above.
  123. You could run the quick test by selecting "Run" from the "Start"
  124. button, but then you will have to enter the full pathname to each
  125. file in the command.
  126. Once you have everything set up, you can create an icon on the
  127. Windows Desktop to perform the conversion via drag-and-drop.
  128. 1. Right-click on the desktop and select New -> Shortcut.
  129. 2. For the "Command line" or "Location of item", enter:
  130. c:\vedit\ebcdic-t.bat "%1"
  131. (This assumes VEDIT was installed into "c:\vedit").
  132. 3. For the "Name of shortcut", enter any desired name, such as
  133. "EBCDIC conversion".
  134. 4. You will now have an icon on your desktop.
  135. Creating the .LAY Layout File
  136. -----------------------------
  137. The user must specify via a ".LAY" data layout file, typically EBCDIC.LAY,
  138. the location of the packed, zoned and other special fields. The file's record
  139. length and several options are also specified in the data layout file.
  140. The data layout file is best understood from a simple example. Assume an
  141. EBCDIC file with the following specs:
  142. Record length is 114
  143. Field between columns 10 and 14 is a packed-decimal number (unsigned)
  144. Field between columns 20 and 21 is a packed-decimal number (unsigned)
  145. Field between columns 22 and 23 is a packed-decimal number
  146. Field between columns 30 and 33 is a packed-binary number
  147. Field between columns 42 and 46 is a zoned number
  148. Field between columns 51 and 55 is an unsigned number
  149. Field between columns 56 and 59 is a short (single precision) floating point number
  150. Field between columns 60 and 67 is a long (double precision) floating point number
  151. All other fields are simple EBCDIC text
  152. To convert this file and create a Windows/DOS text file with a Carriage-
  153. Return and Line-Feed at the end of each record, the following layout file is
  154. used: (This is the supplied prototype EBCDIC.LAY file)
  155. r=114,0 //Record length is 114, convert to DOS newlines
  156. o=z,b2z //Output leading zeros (blank '+' sign; sign at end)
  157. //Convert all-blank/null numeric fields to zeros
  158. e=0,ebcdic.err //Only report serious errors in EBCDIC.ERR
  159. d 10-14 u v2 //Packed-decimal (no sign, explicit decimal point)
  160. d 20-21 u //Packed-decimal (no sign)
  161. d 22-23 //Packed-decimal
  162. b 30-33,=9; //Packed-binary (9 digits; default is 8)
  163. z 42-46 //Zoned number (5 digits plus sign)
  164. u 51-55 //Unsigned number; want leading blanks converted to zeros
  165. //(o=b2z); otherwise redundant
  166. l 56-59,=7; v2 //Short (single precision) floating point; upto 7 digits with two past a decimal point
  167. l 60-67,=12; v2 //Long (double precision) floating point; upto 12 digits, 2 fractional
  168. As shown above, comments can be added to the layout file by preceding them
  169. with "//".
  170. The "r=114,0" indicates that this file has fixed-length records of 114 bytes.
  171. Most EBCDIC files have fixed-length records. Note that unpacking fields will
  172. increase the record length. The ",0" indicates that a Carriage-Return and
  173. Line-Feed will be appended after each record in order to create a Windows/DOS
  174. text file. Use ",1" to append just a Line-Feed to create a UNIX text file.
  175. The "o=z,b2z" specifies that leading zeros are to be output, rather than
  176. spaces and that all-blank/null numeric fields are to be converted to text
  177. zeros. The conversion options are described below.
  178. The "d" specifies a packed-decimal field. It must be followed by the
  179. beginning and ending column numbers of the field. The "u" in the parameter
  180. field specifies that this value is unsigned, so no sign is output, not even
  181. a space. Note: a positive or negative sign in the input data will generate
  182. an error. The "v2" specifies that an explicit decimal point is to be
  183. output, followed by the last two digits of the packed decimal value.
  184. The "b" specifies a packed-binary field. The maximum size of a packed-
  185. binary field is eight bytes. Ordinarily, a 4-byte binary field is output in
  186. an eight digit field. This can be changed with the ",=ndigits;" parameter as
  187. described in the later topic "Formatting Numeric Data".
  188. The "z" specifies a zoned number field. In a zoned field, the sign is
  189. packed into the last digit; the other digits are not packed. The output
  190. field is one greater than the input field so that the sign can be
  191. expressed.
  192. The "u" specifies a simple unsigned (non-packed) number. Since this
  193. is no different from other EBCDIC text, it need not be included. Using it
  194. here ensures that any leading spaces will be converted to zeros and allows
  195. all-blank/null numeric fields to be converted to zeros with the "o=b2z"
  196. instruction.
  197. Finally, the "l" specifies a short (single precision) or long (double
  198. precision) floating point number. The short value is four bytes in length;
  199. the long is eight. In the above example, the short value is expressed in a
  200. seven digit field including the two fractional digits. The output field is
  201. 9 bytes long to account for the sign and the explicit decimal point.
  202. Similarly, the long floating point value is output in a twelve digit field.
  203. Any fractional digits contained in the actual data beyond the two that are
  204. expressed are truncated. If the first truncated digit is five or greater the
  205. final expressed digit is rounded up.
  206. The complete list of possible field types is:
  207. b Packed-binary field
  208. d Packed-decimal field
  209. n Packed-No-Zone (PNZ); no sign; additional digit can be packed.
  210. z Zoned number field
  211. s Signed ASCII decimal field; analogous to zoned decimal. '{', 'A'-'R'
  212. and '}' represent signed digits. Used when converting an ASCII file
  213. with compressed fields. Should be used with "u=ignore" to set
  214. the default conversion.
  215. u Unsigned numeric field. Simple EBCDIC. Using it allows explicit
  216. decimal points to be output or leading spaces converted to zeros or
  217. having an all blank/null field converted to zeros.
  218. e EBCDIC field. This is redundant and slows down conversion, but may
  219. help some users better visualize their file. Necessary when
  220. quoted-and-comma-delimited or user-specified delimiter or DBASE
  221. output is specified. Also required for the first or last item of
  222. an "out" bracketed section.
  223. h Hex field. Output each byte as 2 hexadecimal digits.
  224. i Ignore field. The bytes in this field will be passed on "as is".
  225. l Floating point number. See topic "Floating Point Numbers".
  226. f Fill field. The bytes in this field are replaced (filled) with ASCII
  227. spaces, or another specified padding character.
  228. x Delete the field.
  229. c Custom field. A custom macro is used to process this field.
  230. The "b", "d", "l", "u" and "z" specifications can also take several options
  231. which specify exactly how the number is converted. If no options are
  232. specified, numbers are converted as follows:
  233. * Output space instead of '+' for positive values
  234. * Place the sign at the end of the number
  235. * Output numbers as signed values
  236. * Output leading zeros instead of spaces (due to "o=z")
  237. The following options, which are specified after the column numbers, control
  238. the conversion: (These override any "o=..." command settings).
  239. + Use an explicit "+" sign for positive numbers, else a Space is
  240. used. Negative numbers are always converted with "-".
  241. b Place the sign at the beginning of the number, else the sign is at
  242. the end of the number.
  243. u The data is expressed as an unsigned number. This option overrides
  244. the "+" and "b" options.
  245. z Use leading "0" in numbers; else leading zeros are replaced with
  246. Spaces.
  247. b2z Convert all-blank/null numeric fields to zeros.
  248. See also the topics "Formatting Numeric Data" and "Floating Point Numbers".
  249. Since it would be tedious to specify the same conversion options for every
  250. field, you can specify the default options with the "o=..." command. For
  251. example, "o=z" specifies that the converted numbers should have leading "0"
  252. instead of spaces. The command "o=+bz" would place the sign, including '+',
  253. and any leading zeros ahead of all unpacked numeric values by default. A
  254. .LAY file should have at most one "o=..." command.
  255. For some fields, you may want to disable one or more of the default options
  256. set with the "o=..." command. This can be done with the following options:
  257. - To use Space instead of "+" for positive numbers.
  258. e To place the sign at the end of the number.
  259. s The data is expressed as a signed value.
  260. p To use blank padding instead of zeros to right justify small numbers.
  261. NOTE: These field options are only needed to override the default options
  262. set with the "o=..." command.
  263. The numeric field specifications "b", "d", "l", "n", "u" and "z" (binary,
  264. packed decimal, floating point, packed-no-zone, unsigned numeric and zoned
  265. decimal) can also take an optional explicit decimal point position.
  266. v1 Place the decimal point "." one digit from the right.
  267. v2 Place the decimal point "." two digits from the right.
  268. v3 Place the decimal point "." three digits from the right.
  269. For example, the layout file above could be modified with these options:
  270. r=114,0 //Record length is 114, convert to DOS newlines
  271. o=-ep,b2z //Standard output default options
  272. //Also, convert all-blank/null numeric fields to zeros
  273. e=0,ebcdic.err //Only report serious errors in EBCDIC.ERR
  274. d 10-14 b //Packed-decimal; place sign at beginning
  275. d 20-21 zv2 //Packed-decimal; include leading "0"
  276. // place decimal point two digits from right
  277. d 22-23 +b //Packed-decimal; include "+" at beginning
  278. b 30-33 z //Packed-binary; include leading "0"
  279. //Note: output in an eight-digit field
  280. z 42-46 b //Zoned number; place sign at beginning
  281. u 51-55 z //Unsigned number in columns 51 thru 55; want leading blanks
  282. //and all-blank/null fields converted to zeros; else redundant
  283. l 56-59 //Short (single precision) floating point integer; 7 digit
  284. // field with no decimal point
  285. l 60-67 v0 //Long (double precision) floating point integer; 16-digits;
  286. // decimal point but no fractional digits
  287. Sometimes it is more convenient to specify the type and size of each field
  288. instead of its beginning and ending columns. The following variation of the
  289. original example shows this. Note how the "+" is used:
  290. r=114,0 //Record length is 114, convert to DOS newlines
  291. o=z,b2z //Output leading zeros (blank '+' sign; sign at end)
  292. //Convert all-blank/null numeric fields to zeros
  293. e=0,ebcdic.err //Only report serious errors in EBCDIC.ERR
  294. e +9 // 9 columns of EBCDIC text (1 - 9)
  295. d +5 // 5 columns of Packed-decimal (10-14)
  296. e +5 // 5 columns of EBCDIC text (15-19)
  297. d +2 // 2 columns of Packed-decimal (20-21)
  298. d +2 // 2 columns of Packed-decimal (22-23)
  299. e +6 // 6 columns of EBCDIC text (24-29)
  300. b +4 // 4 columns of Packed-binary (30-33)
  301. e +8 // 8 columns of EBCDIC text (34-41)
  302. z +5 // 5 columns of Zoned number (42-46)
  303. e +4 // 4 columns of EBCDIC text (47-50)
  304. u +5 // 5 columns of EBCDIC digits (51-55)
  305. l +4 // 4 columns of short (single precision) floating point (56-59)
  306. l +8 // 8 columns of long (double precision) floating point (60-67)
  307. e +47 //47 columns of EBCDIC text (56-76)
  308. The name of the data layout file can be either EBCDIC.LAY or filename.LAY,
  309. where 'filename' is the name of the file being converted. The name of the
  310. layout file can also be explicitly specified. This is described below under
  311. "Conversion Options".
  312. Floating Point Numbers
  313. ----------------------
  314. The EBCDIC conversion packages support IBM 360-style floating point numbers
  315. in the range 10E-18 through 10E18. Output is fixed format, right justified.
  316. The field is specified like the other numeric fields; e.g.,
  317. l bc,ec[,=ndigits;] [sop] [v[n]] // comment
  318. where the beginning and ending columns must be four or eight bytes long;
  319. "sop" are the standard options "+buz-esp", 'v' specifies that an explicit
  320. decimal point is to be output and 'n' specifies the number of digits to
  321. output past the decimal point. The optional "ndigits" specifies the total
  322. number of digits output, both before and after the decimal point (See
  323. "Formatting Numeric Data"). It must be sufficiently large to express the
  324. whole-number digits as well as the fractional digits "vn". There will
  325. always be at least one digit before the decimal point, even if just zero.
  326. The default "ndigits" is 7 for short floats and 16 for long floats.
  327. Floating point numbers with magnitudes greater than 10E18 are treated as
  328. erroneous; their output fields are filled with BAD_CHARs and error messages
  329. are generated in EBCDIC.ERR. Numbers with magnitudes between zero and 10E-18
  330. are output as zeros.
  331. (Technical)
  332. Floating point numbers have an intrinsic truncation error associated with
  333. them. IBM's standard floating point number has 6 significant hexadecimal
  334. digits and a sign and exponent packed into 4 bytes, with a certain amount of
  335. truncation error associated with the 6th digit. This can be transformed into
  336. a decimal representation of about 7 digits with a significant amount of
  337. error in the eighth digit. Accordingly, the eighth digit is truncated and
  338. the preceding digit(s) is/are rounded up when the truncated digit was
  339. greater than or equal to five. For double precision (eight bytes), seven-
  340. teen significant decimal digits can be output.
  341. NOTE: The EBCDIC conversion packages correctly handle these truncation
  342. issues according to the IBM documentation.
  343. If the conversion instruction specifies fewer significant digits than can
  344. be validly expressed, the last digit output is rounded up when the non
  345. displayed subsequent digit is five or greater. Double rounding (from 4 to
  346. 5 during conversion and then from 5 to 6 for displaying) is prevented.
  347. If the conversion instruction specifies more digits than can be validly
  348. expressed, zeros are used for the excess positions.
  349. Using a COBOL Copy-Book for the .LAY Layout File
  350. ------------------------------------------------
  351. For simple data files containing neither REDEFINES nor OCCURS clauses, it
  352. is possible to "cut and paste" the COBOL copy-book into the .LAY layout
  353. file. The COBOL copy-book must be preceded by a "p=" line and followed by
  354. a "q=" line.
  355. The following example converts the same file in the same way as the
  356. original example (this is the supplied prototype COBMIX.LAY file):
  357. r=114,0 //Record length is 114, convert to DOS newlines
  358. o=z,b2z //Output leading zeros (blank '+' sign; sign at end)
  359. //Convert all-blank/null numeric fields to zeros
  360. e=0,ebcdic.err //Only report serious errors in EBCDIC.ERR
  361. //
  362. p= //Start of COBOL data specifications
  363. //Vedit comments and blank lines are OK after the "p=" line
  364. *************************************************************** 000100
  365. * * 000110
  366. * SAMPLE COPY-BOOK * 000120
  367. * * 000130
  368. * RECSIZE = 114 BYTES * 000140
  369. * * 000150
  370. *************************************************************** 000160
  371. 000170
  372. 01 SAMPLE-REC. 000180
  373. 03 SA-KEY. 000190
  374. 10 SA-KEY-ALPHA PIC X(7). 000200
  375. 10 SA-KEY-NUMERIC PIC 9(2). 000250
  376. 03 SA-PAC-DEC-1 PIC 9(7)V99 COMP-3. 000300
  377. 03 FILLER PIC X(5). 000350
  378. 03 SA-PAC-DEC-2 PIC 999 COMP-3. 000400
  379. 03 SA-PAC-DEC-3 PIC S9(3) COMP-3. 000450
  380. 03 FILLER PIC X(6). 000500
  381. 03 SA-SIGNED-BINARY PIC S9(9) COMP. 000550
  382. 03 FILLER PIC X(8). 000600
  383. 03 SA-ZONED-DECIMAL PIC S9(5). 000650
  384. 03 FILLER PIC X(4). 000700
  385. 03 SA-ANOTHER-NUMERIC PIC 9(5). 000750
  386. 03 SA-FLOAT PIC S9(5)V99 COMP-1. 000800
  387. 03 SA-DOUBLE PIC S9(10)V99 COMP-2. 000850
  388. 03 FILLER PIC X(47). 000900
  389. q= //End of COBOL data specifications
  390. Notes: The COBOL statement lines must be included verbatim, maintaining
  391. the 1-6,7,8-72,73-80 columnar format. For statements covering
  392. more than 1 line, the entire statement must be included, not just
  393. the picture format.
  394. Other than COBOL statement lines, only blank lines, Vedit comment
  395. lines and Column setting "c=col" lines (see below) may appear between
  396. the "p=" and "q=" lines.
  397. Alternatively, each individual packed field's COBOL statement can be cut and
  398. pasted into the layout file. It is necessary to indicate the beginning column
  399. number of each non-contiguous field, as in the following example:
  400. r=114,0 //Record length is 114, convert to DOS newlines
  401. o=z,b2z //Output leading zeros (blank '+' sign; sign at end)
  402. //Convert all-blank/null numeric fields to zeros
  403. e=0,ebcdic.err //Only report serious errors in EBCDIC.ERR
  404. //
  405. p= //Start COBOL section
  406. //Columns 1-9 are simple EBCDIC
  407. c=10 //Starting column # for upcoming packed-decimal field
  408. 03 SA-PAC-DEC-1 PIC 9(7)V99 COMP-3. 000300
  409. //Columns 15-19 are simple EBCDIC
  410. c=20 //Starting column # for upcoming packed-decimal fields
  411. 03 SA-PAC-DEC-2 PIC 999 COMP-3. 000400
  412. 03 SA-PAC-DEC-3 PIC S9(3) COMP-3. 000450
  413. //Columns 24-29 are simple EBCDIC
  414. c=30 //Starting column #
  415. 03 SA-SIGNED-BINARY PIC S9(9) COMP. 000550
  416. //Columns 34-41 are simple EBCDIC
  417. c=42 //Starting column #
  418. 03 SA-ZONED-DECIMAL PIC S9(5). 000650
  419. //Columns 47-50 are simple EBCDIC
  420. c=51 //Starting column #
  421. 03 SA-ANOTHER-NUMERIC PIC 9(5). 000750
  422. 03 SA-FLOAT PIC S9(5)V99 COMP-1. 000800
  423. 03 SA-DOUBLE PIC S9(10)V99 COMP-2. 000850
  424. //Columns 68-114 are simple EBCDIC
  425. q= //End COBOL section
  426. More complicated copy-books with "OCCURS" and "REDEFINES" clauses should
  427. first be converted to a normal .LAY file with the supplied COBOL2V.VDM macro
  428. as described below.
  429. Performing the Conversion (Manually)
  430. -------------------------
  431. NOTE: The conversion is normally performed automatically (see below),
  432. but you can also run it manually.
  433. To convert files manually, it is necessary to have the data layout file named
  434. EBCDIC.LAY in the current or VEDIT Home Directory.
  435. 1. Open the EBCDIC file to be converted.
  436. NOTE: Steps 2. thru 4. are optional; they just let you review the EBCDIC
  437. file before it is converted.
  438. 2. Assuming the file has fixed-length records, set the correct record
  439. length with {CONFIG, File handling, File type}.
  440. 3. Press <Alt-D> (the hot-key for {VIEW, Toggle display mode}) several times
  441. to switch to EBCDIC mode. The non-packed fields should now be readable.
  442. 4. Open the file EBCDIC.LAY and ensure that it is correct. In particular,
  443. the "r=" should be set to the same record length that you set above.
  444. Switch back to the data file's buffer.
  445. 5. Select {MISC, Load/Execute macro}.
  446. Enter the file name "ebcdic-t.vdm" or select this file in the dialog box.
  447. Use the default register number "100".
  448. 6. The macro will start, display its sign-on message and immediately begin
  449. performing the conversion. It displays a progress message of how many
  450. records have been converted.
  451. The conversion creates a new file with the same filename, but an ".ASC"
  452. extension.
  453. 7. When done, the beginning of the converted file will be displayed on the
  454. screen.
  455. 8. Select {FILE, Exit} to exit the editor.
  456. Performing the Conversion (Automatically)
  457. -------------------------
  458. The conversion can be performed automatically from a command line or with a
  459. DOS batch file. Win 95/98/NT/2000/XP users can create a shortcut icon to the
  460. batch file; you can then drag-and-drop the file to be converted onto the
  461. icon.
  462. 1a. From a DOS or NT command line, use the following command to run the
  463. 32-bit Windows VEDIT with the conversion macro:
  464. c:\vedit\vpw -x ebcdic-t.vdm filename
  465. where 'filename' is the name of the file to be converted.
  466. (This assumes VEDIT was installed in c:\vedit.)
  467. 2a. This will immediately start the conversion. When done, the converted file
  468. will be saved and shown on the screen. You must still exit the editor.
  469. To also automatically exit, use the command:
  470. c:\vedit\vpw -y -x ebcdic-t.vdm filename
  471. This will convert and save the file, and exit VEDIT without any user
  472. intervention whatsoever.
  473. -OR-
  474. 1b. Use the supplied EBCDIC-T.BAT batch file which contains the command to
  475. run the 32-bit Windows VEDIT and automatically convert the specified
  476. file:
  477. c:\vedit\vpw -x ebcdic-t.vdm %1 %2
  478. Therefore, to convert the file with name 'filename', give the command:
  479. ebcdic-t filename
  480. 2b. This will convert and save the file, and exit VEDIT without any user
  481. intervention whatsoever.
  482. If desired, you can have VEDIT display the converted file before saving
  483. and exiting. The comments in the EBCDIC-T.BAT file describe how to
  484. do this.
  485. NOTE: These commands assume that the EBCDIC data file, EBCDIC-T.BAT and
  486. EBCDIC.LAY are in the current directory. If not, you may need to
  487. specify the full pathname to the files.
  488. EBCDIC-T.BAT also assumes that VEDIT was installed into the
  489. "C:\VEDIT" directory. If you installed VEDIT into another directory,
  490. e.g. "C:\Program Files\VEDIT", you must edit the EBCDIC-T.BAT file
  491. to specify the correct directory.
  492. Conversion Options
  493. ------------------
  494. By default, the name of the data layout file is EBCDIC.LAY. Optionally, you
  495. can use "filename.LAY", where 'filename' is the name of the file being
  496. converted. You can also explicitly specify the name of the .LAY file.
  497. EBCDIC.LAY is convenient when you have many files of the same type;
  498. filename.LAY is better when each file is of a different format.
  499. The "-n" invocation switch causes filename.LAY to be used as the layout file.
  500. Therefore, use the following command to automatically run the conversion
  501. macro:
  502. c:\vedit\vpw -n -x ebcdic-t.vdm datafile.ebc
  503. where 'datafile.ebc' is the name of the file to be converted.
  504. datafile.lay will be used as the name of the layout file.
  505. Alternatively, you can explicitly specify the name of the layout file. This
  506. is necessary when the .LAY layout file is in a different directory. Use the
  507. command form:
  508. c:\vedit\vpw -x ebcdic-t.vdm datafile.ebc layout.lay
  509. where 'datafile.ebc' is the name of the file to be converted.
  510. 'layout.lay' is the name of the data layout file.
  511. Using Different Directories
  512. ---------------------------
  513. By default, the EBCDIC source file "datafile.ebc", the data layout file
  514. EBCDIC.LAY and the resulting ASCII file "datafile.asc" must all be in
  515. the same directory. However, you can specify separate directories with
  516. the command:
  517. vpw -x ebcdic-t.vdm \dir1\datafile.ebc -a \dir2\datafile.asc \dir3\layout.lay
  518. where '\dir1\datafile.ebc' is the pathname of the file to be converted.
  519. '\dir2\datafile.asc' is the pathname of the converted file.
  520. '\dir3\layout.lay' is the name of the data layout file.
  521. This format lets you specify the full pathname of the converted file and of
  522. the data layout file.
  523. ---------------
  524. ADVANCED TOPICS
  525. ---------------
  526. Quoted-Comma-Delimited ASCII File
  527. ---------------------------------
  528. Consider the following relatively simple .LAY file:
  529. r=76,0 //Record length is 76, convert to DOS newlines
  530. o=z,b2z //Output leading zeros (blank '+' sign; sign at end)
  531. //Convert all-blank/null numeric fields to zeros
  532. e=0,ebcdic.err //Only report serious errors in EBCDIC.ERR
  533. e +9 // 9 columns of EBCDIC text (1 - 9)
  534. d +5 // 5 columns of Packed-decimal (10-14)
  535. e +5 // 5 columns of EBCDIC text (15-19)
  536. d +2 // 2 columns of Packed-decimal (20-21)
  537. d +2 // 2 columns of Packed-decimal (22-23)
  538. e +6 // 6 columns of EBCDIC text (24-29)
  539. b +4 // 4 columns of Packed-binary (30-33)
  540. e +8 // 8 columns of EBCDIC text (34-41)
  541. z +5 // 5 columns of Zoned number (42-46)
  542. e +4 // 4 columns of EBCDIC text (47-50)
  543. u +5 // 5 columns of EBCDIC digits (51-55)
  544. e +21 //21 columns of EBCDIC text (56-76)
  545. One converted ASCII record might look like this:
  546. ABCDEFGHI123456789 ABCDE123 123 ABCDEF1234567890ABCDEFGH12345 ABCD12345ABCDE...
  547. It is difficult to tell where one field ends and the next begins. Therefore,
  548. the conversion can optionally quote each field and separate them with commas.
  549. Therefore, the converted ASCII record would look like this:
  550. "ABCDEFGHI","123456789 ","ABCDE","123 ","123 ","ABCDEF","123456789 ","ABCDEFGH","12345 ","ABCD","12345","ABCDE..."
  551. To select this option, add the "qcd" command to the .LAY file:
  552. r=76,0 //Record length is 76, convert to DOS newlines
  553. o=z,b2z //Output leading zeros (blank '+' sign; sign at end)
  554. //Convert all-blank/null numeric fields to zeros
  555. qcd //Create quoted-comma-delimited ASCII
  556. e +9 //9 columns of EBCDIC text (1 - 9)
  557. ...
  558. Please be aware of these notes when creating a quoted-comma-delimited file:
  559. * The "qcd" command must appear in the .LAY file before any field specs.
  560. * All fields, including simple EBCDIC text fields, must be specified.
  561. * Only use the "qcd" command when necessary - it slows down the conversion
  562. by about 20%. Although it makes the ASCII file more humanly readable,
  563. most database programs, such as Microsoft Access (tm), can import based
  564. on beginning and ending columns and don't need a quoted-comma-delimited
  565. file.
  566. * When quoting and comma delimiting output fields, any quotes that appear
  567. in text fields may confuse programs that later try to process the output.
  568. To automatically convert quotes to apostrophes, use the EBCDIQ.TBL
  569. conversion table as explained in the topic "Alternative EBCDIC to ASCII
  570. Translation Tables", below.
  571. User Specified Field Delimiter String
  572. -------------------------------------
  573. As an alternative to quoting and comma delimiting each field, a custom string
  574. can be used to separate fields. E.g., to separate the fields with " | "
  575. (space, pipe, space), place the following command at the beginning of the
  576. .LAY layout file:
  577. v=Reg_Set(XDREG,/ | /);
  578. This is an example of the "v=" specification which executes Vedit macro
  579. commands. The text register specified by internal value XDREG (currently 17,
  580. when not being run under WILDFILE.VDM) is set to the specified string.
  581. EBCDIC-2.VDM appends T-Reg(XDREG) to the end of each specified output field
  582. and to the end of each set of unspecified (default) fields.
  583. Note: To use the "/" character as part of the string, the string delimiting
  584. "/" may be replaced by any of '"`\.
  585. Alternative EBCDIC to ASCII Translation Tables
  586. ----------------------------------------------
  587. It is sometimes necessary or desirable to translate EBCDIC text characters
  588. to a different ASCII character than normal. Three alternative translation
  589. tables are supplied for this purpose: EBCDIQ.TBL which converts quotes to
  590. apostrophes; EBCDIL.TBL which converts "low values" (0x00 - 0x3f) into
  591. ASCII spaces; and EBCDILQ.TBL which does both. The "Q" table are provided
  592. for use when output is being quoted and comma delimited. The "L" tables
  593. are provided for cases when uninitialized text fields or, perhaps,
  594. undocumented packed fields are present in supposedly simple text fields.
  595. The result of treating them as text is gibberish in the ASCII output.
  596. To use one of these tables, include the following, appropriately edited,
  597. line near the beginning of your .lay file:
  598. v=Translate_Load("EBCDIQ.TBL") // Convert EBCDIC " to ASCII '
  599. This assumes that the table has been copied to your VEDIT home directory
  600. or is in the directory containing the data file being translated.
  601. Formatting Numeric Data
  602. -----------------------
  603. The numeric field specifiers "b", "d", "l", "n", "u" and "z" have an
  604. associated default output width dependent on the individual data type, the
  605. size of the input field, the presence and location of a sign and the
  606. presence of an explicit decimal point.
  607. The location of the sign (plus, minus or blank) has been well explained in
  608. the topic "Creating the .LAY Layout File". The sign may also be suppressed
  609. by the unsigned option 'u'. E.g., "b 1,4 u". The output for this binary
  610. field is eight columns - the standard number of digits stored in a 4-byte
  611. binary. There is no sign to be expressed for the unsigned numeric fields 'u'
  612. (simple numeric) and 'n' (packed, no zone).
  613. To output an explicit decimal point, use the "v[n]" option, where 'n' is
  614. the number of digits following the decimal point. E.g.,"d 1,4 v2". The
  615. output for this packed decimal field is nine columns in the format
  616. "ddddd.ffs" where 's' is the sign. If 'n' is omitted or 0, nothing
  617. is output past the decimal point.
  618. To control the actual number of digits output, use the ",=ndigits;" option,
  619. where "ndigits" is the total number of digits to be output both before and
  620. after any explicit decimal point. E.g., "l 1,4,=6; v2". The output of this
  621. floating point field is eight columns in the format "dddd.ffs". The default
  622. size is nine columns. I.e., "l 1,4 v2" generates "ddddd.ffs".
  623. The number of digits output can be greater or less than the default number
  624. of digits contained in a numeric field. If greater, leading zeros/blanks
  625. are normally output. For the case of floating point fields only, specifying
  626. more digits past the decimal point than are contained in the actual data
  627. results in trailing zeros being output.
  628. Specifying fewer digits than the default must be done with care. If fewer
  629. digits are specified than are actually contained in any field other than a
  630. floating point's fractional digits, a BAD_CHAR will be placed into the
  631. field's first output column and an error message will be output to
  632. EBCDIC.ERR.
  633. The defaults for binary numbers are two, four, eight and eighteen digits for
  634. one-, two-, four- and eight-byte binary numbers. (Note: IBM does not support
  635. one-byte binary numbers).
  636. The default for packed decimals is 2*(ending column - beginning column) + 1.
  637. The default for packed, no zone is 2*input size, where input size = (ending
  638. column - beginning column + 1).
  639. The default for short (single precision) floating point (input size = 4) is
  640. 7.
  641. The default for long (double precision) floating point (input size = 8) is
  642. 16.
  643. Following are examples of binary fields with the total output field size
  644. given in the comment field:
  645. o=+z //Output leading zeros and '+' for nonnegative values
  646. b 1,4,=9; //10 bytes (9 digits + sign) PIC S9(9) COMP.
  647. b 1,4 u // 8 bytes (8 digits, no sign) PIC 9(8) COMP.
  648. b 1,4,=10; //11 bytes (10 digits including any leading zeros + sign)
  649. b 1,1 u //1 byte (1 digit, no sign) PIC X.
  650. b 1,1,=2; u raw //2 byte2 (2 digits, no sign) PIC X.
  651. b 1,1,=2; raw //3 bytes (2 digits + sign)
  652. b 1,1 - //2 bytes (1 digit, trailing sign, space if positive)
  653. b 1,1 -b //2 bytes (1 digit, leading sign, space if positive)
  654. b 1,2 // 5 bytes (4 digits + sign) PIC S9(4) COMP.
  655. b 1,8 //19 bytes (18 digits + sign) PIC S9(18) COMP.
  656. b 1,8,=14; //15 bytes (14 digits + sign) PIC S9(14) COMP.
  657. Reporting Errors
  658. ----------------
  659. Any conversion errors can optionally be reported in a file; the default
  660. filename is "ebcdic.err" in the same directory as the converted output file.
  661. Alternatively, you can specify a different filename or a full pathname with
  662. the "e=" command (see below).
  663. Three kinds of errors can be reported:
  664. * Syntax errors in the ".LAY" file and other serious errors which prevent
  665. any data from being converted. The ebcdic.err file will contain a
  666. description of the error.
  667. * Errors in the data file. When bad data, e.g. an invalid packed-decimal
  668. number is encountered, it is converted to spaces and the conversion
  669. continues. Optionally, up to the first 'n' data errors can be reported.
  670. The ebcdic.err file will contain a description and the position in the
  671. data file of the error.
  672. * Any unexpected conditions which cause the conversion to stop. These are
  673. reported with "***** Unexpected breakout occurred." in the ebcdic.err
  674. file.
  675. Our experience is that many data files contain insignificant errors in some
  676. fields. In some cases the field is defined in the copy-book, but is never
  677. used and contains garbage. Therefore, we suggest ignoring errors in the data
  678. file unless the data is really critical and you are willing to take the time
  679. to track down the errors on the mainframe side. When data error reporting is
  680. enabled, only the first 'n' errors are reported to prevent creating huge
  681. error files.
  682. The "e=" command in the ".LAY" file controls which errors are reported in the
  683. error file and can override the name of the file. Some examples are:
  684. e=1000,ebc-data.err
  685. Up to the first 1000 errors in the data file will be reported.
  686. Specifies that the name of the error file is "ebc-data.err".
  687. This will be written to the main output directory which is the
  688. same as the source data file unless altered by the "-a outpathname"
  689. invocation option.
  690. e=200
  691. Up to the first 200 errors in the data file will be reported. The
  692. default error file "ebcdic.err" will be used.
  693. e=0
  694. Most errors in the data file will not be reported and will not
  695. cause an error file to be created. Severe errors will still be
  696. reported. These are mostly encountered by the preprocessor and
  697. will have been fixed before production runs are made.
  698. e=0,\errdir\ebcdic.err
  699. Exactly the same as "e=0". It explicitly gives the location and
  700. name of the error file.
  701. When the conversion starts, any existing "ebcdic.err" file is deleted. A
  702. batch file can therefore test for the existence of ebcdic.err to determine if
  703. the conversion was successful or not. The supplied EBCDIC-T.BAT file does
  704. this with the batch commands:
  705. IF NOT EXIST ebcdic.err GOTO DONE
  706. ECHO -
  707. ECHO Conversion had errors!
  708. ECHO See the file EBCDIC.ERR for details.
  709. ECHO -
  710. PAUSE
  711. :
  712. :DONE
  713. Advanced Commands
  714. -----------------
  715. The new "out" command allows diverting just part of a record to its own
  716. file. To link extracted data to its parent record, a unique ID # is
  717. automatically generated. Associated with this are 4 new commands, "b=",
  718. "d=", "a=" and "n=" (see below).
  719. Outputting a record section to its own file (out)
  720. -------------------------------------------------
  721. It is possible to output a section of a record to its own file by using the
  722. 'out "fname"' ... 'out' brackets. This can be done even when the parent
  723. record is being output to its own file. The unique ID #, discussed below, is
  724. appended to both the end of the section and the end of the parent record.
  725. out ["fname"] Use the "out" commands as brackets around a section to
  726. divert the output to the file "fname". The first "out"
  727. requires the filename. The first and last fields must
  728. be explicitly defined. For example,
  729. ...
  730. out "special.asc"
  731. e 510,579
  732. out
  733. ...
  734. converts columns 510 through 579 from simple EBCDIC to ASCII
  735. and outputs the results into file "special.asc". The unique
  736. ID will be appended to the end of the line in "special.asc"
  737. and to the end of the parent record's output line.
  738. The first and last fields (here, the same) have been
  739. explicitly specified, even though ordinarily they could have
  740. been omitted.
  741. Unique ID #'s for Extracted Fields
  742. ----------------------------------
  743. When data fields are being output to their own files, it is helpful and
  744. sometimes necessary to generate a unique ID # for associating the extracted
  745. portions of the data record with the main portion. The unique ID is output
  746. at the end of the extracted portion and at the end of the parent record.
  747. For Level-2 this occurs for 'out "fname"' ... 'out' bracketed sections
  748. (see above).
  749. The unique ID # consists of a 5-digit "# days elapsed since base date"
  750. followed by a 1-digit "daily run #" (default value is 0) followed by a
  751. 6-digit "record #". The five-digit elapsed days count allows for 270+
  752. unique years. The 6-digit record count allows for 999,999 records to be
  753. processed in a single day. The "daily_run_#" allows more than one such
  754. run per day. This value must be explicitly set (see below).
  755. The ID's are generated automatically, based on the day of the run and the
  756. input record #. To control the ID generation, 4 commands have been added:
  757. "b=base_date" (default = 1/1/2000); "d=run_date" (default = current date);
  758. "a=additional_offset" (default = 0) and "n=l,m[,n]" to control the number
  759. of digits in the unique ID (default = 5 digits for days elapsed, 6 digits
  760. for the record # and 1 digit for the run #).
  761. To change the run date, add the "d=run_date" command to the .LAY file. Dates
  762. are expressed in mm/dd/yyyy format. The year must be completely expressed.
  763. The separator may be any of "_./\:-".
  764. To change the base date from its default of 1/1/2000, add the "b=base_date"
  765. command; e.g.,
  766. b=1/1/1900 // Include dates from the previous century
  767. To change the number of digits in the unique ID to 4 digits for # days
  768. elapsed since base date and 5 digits for the record # use the "n=d,r"
  769. command; e.g.,
  770. n=4,5 // 4 digits for days elapsed since base date
  771. // 5 digits for record count
  772. // There is still 1 digit reserved for the
  773. // daily run #
  774. In case more than one data set is processed for a given base_date and
  775. run_date, one can include the "a=additional_offset" command in order
  776. to generate unique ID's in the 2nd and later runs. Set the offset greater
  777. than or equal to the last record # processed in the previous run(s); e.g.
  778. a=9999 // Previous run ended with record 9,999
  779. As an alternative, one can employ the digit reserved for the daily run #
  780. by adding the run # to the invocation command line after the "-u"
  781. parameter, which is placed after all specified filenames. For the second
  782. run of the day this might be:
  783. c:\vedit\vpw -x ebcdic-2.vdm datafile.ebc layout.lay -u 2
  784. DBASE output
  785. ------------
  786. To easily produce DBASE-style output, set the second parameter in the
  787. "r=reclen,parm2" specification in the .LAY file to "DBASE-III". During
  788. preprocessing, a DBASE header record - including automatically generated or
  789. explicitly entered field names - is generated for the output file.
  790. The automatically generated names are of the form "Fn", where 'n' is the
  791. field's index, counting from 1.
  792. A second letter 'A', 'B', ... is automatically generated between 'F' and 'n'
  793. for each section being output to its own file via

Large files files are truncated, but you can click here to view the full file