Note that there are some explanatory texts on larger screens.

plurals
  1. POUnpacking AS400 packed decimal (BCD) - possibly borked by EBCDIC conversion?
    text
    copied!<p>I'm getting files transferred from an AS/400 to our Windows (SBS 2003) via FTP. The files are fixed-width data. The text appears fine, but some of the fields are packed decimals, which when unpacked give bad values. My assumption is that there's an implicit EBCDIC->ASCII conversion happening, which is converting the packed bytes too. However, doing the reverse conversion and unpacking them <em>still</em> gives bad values...sometimes.</p> <p>My guess is the codepage they're using is slightly different (so when I convert back to EBCDIC it's not quite the same), but I've no idea how to find out what codepage they <em>are</em> using (their IT people are being...mildly recalcitrant...otherwise they could just do the FTP in binary mode and skip all these issues).</p> <p>Here is some sample data - these are supposed to unpack to 8-digit numbers which are actually dates in YYYYMMDD format.</p> <pre><code>Received: 2,0,216,202,164 2,0,144,22,177 2,0,16,176,172 2,0,16,176,172 2,0,16,176,172 2,0,16,176,172 1,114,176,160,124 2,0,248,32,63 2,0,144,226,164 2,0,144,226,164 2,0,144,226,164 2,0,144,202,124 2,0,144,202,124 2,0,144,176,172 2,0,144,176,172 2,0,32,22,63 2,0,38,248,172 2,0,38,248,172 2,0,38,98,164 2,0,233,1,15 2,0,45,107,172 1,114,176,226,26 1,114,176,38,177 1,114,176,97,164 2,0,0,17,124 2,0,128,129,31 2,0,128,129,31 2,0,128,129,31 2,0,128,129,31 2,0,128,129,31 2,0,128,129,31 2,0,216,17,63 2,0,160,17,31 2,0,160,128,34 2,0,160,129,26 2,0,38,128,31 2,0,38,144,26 1,114,97,16,124 1,114,97,16,124 2,0,38,234,26 2,0,38,201,172 2,0,45,38,124 2,0,45,216,164 2,0,45,107,177 2,0,248,234,124 2,0,248,202,34 2,0,248,18,172 2,0,97,128,172 2,0,248,18,7 2,0,248,233,15 2,0,201,2,15 2,0,176,16,7 2,0,106,0,31 2,0,216,22,34 2,0,216,160,63 2,0,38,107,7 2,0,233,0,63 2,0,38,107,164 2,0,233,0,26 2,0,38,107,34 2,0,233,0,164 2,0,233,17,15 2,0,45,202,177 2,0,45,106,7 2,0,45,97,177 2,0,47,16,31 2,0,248,216,177 2,0,201,0,172 2,0,176,201,63 2,0,248,97,34 2,0,176,202,26 2,0,248,97,34 2,0,201,2,172 2,0,201,17,164 2,0,176,129,164 2,0,201,17,172 2,0,176,144,7 2,0,145,2,164 2,0,32,145,15 2,0,38,45,26 2,0,38,38,63 2,0,38,233,26 2,0,38,248,34 2,0,45,202,164 2,0,45,107,124 2,0,47,17,15 2,0,47,16,31 2,0,47,130,34 2,0,248,45,177 2,0,106,0,31 2,0,248,22,31 2,0,248,202,172 2,0,248,97,172 2,0,47,128,177 2,0,201,2,164 2,0,216,201,164 2,0,176,16,34 2,0,216,201,34 </code></pre> <p>Here's the codepage to convert back to ebcdic that isn't <em>quite</em> working:</p> <pre><code>ascii = Array( _ &amp;H0, &amp;H1, &amp;H2, &amp;H3, &amp;H37, &amp;H2D, &amp;H2E, &amp;H2F, &amp;H16, &amp;H5, &amp;H25, &amp;HB, &amp;HC, &amp;HD, &amp;HE, &amp;HF, _ &amp;H10, &amp;H11, &amp;H12, &amp;H13, &amp;H3C, &amp;H3D, &amp;H32, &amp;H26, &amp;H18, &amp;H19, &amp;H3F, &amp;H27, &amp;H1C, &amp;H1D, &amp;H1E, &amp;H1F, _ &amp;H40, &amp;H4F, &amp;H7F, &amp;H7B, &amp;H5B, &amp;H6C, &amp;H50, &amp;H7D, &amp;H4D, &amp;H5D, &amp;H5C, &amp;H4E, &amp;H6B, &amp;H60, &amp;H4B, &amp;H61, _ &amp;HF0, &amp;HF1, &amp;HF2, &amp;HF3, &amp;HF4, &amp;HF5, &amp;HF6, &amp;HF7, &amp;HF8, &amp;HF9, &amp;H7A, &amp;H5E, &amp;H4C, &amp;H7E, &amp;H6E, &amp;H6F, _ &amp;H7C, &amp;HC1, &amp;HC2, &amp;HC3, &amp;HC4, &amp;HC5, &amp;HC6, &amp;HC7, &amp;HC8, &amp;HC9, &amp;HD1, &amp;HD2, &amp;HD3, &amp;HD4, &amp;HD5, &amp;HD6, _ &amp;HD7, &amp;HD8, &amp;HD9, &amp;HE2, &amp;HE3, &amp;HE4, &amp;HE5, &amp;HE6, &amp;HE7, &amp;HE8, &amp;HE9, &amp;H4A, &amp;HE0, &amp;H5A, &amp;H5F, &amp;H6D, _ &amp;H79, &amp;H81, &amp;H82, &amp;H83, &amp;H84, &amp;H85, &amp;H86, &amp;H87, &amp;H88, &amp;H89, &amp;H91, &amp;H92, &amp;H93, &amp;H94, &amp;H95, &amp;H96, _ &amp;H97, &amp;H98, &amp;H99, &amp;HA2, &amp;HA3, &amp;HA4, &amp;HA5, &amp;HA6, &amp;HA7, &amp;HA8, &amp;HA9, &amp;HC0, &amp;H6A, &amp;HD0, &amp;HA1, &amp;H7, _ &amp;H20, &amp;H21, &amp;H22, &amp;H23, &amp;H24, &amp;H15, &amp;H6, &amp;H17, &amp;H28, &amp;H29, &amp;H2A, &amp;H2B, &amp;H2C, &amp;H9, &amp;HA, &amp;H1B, _ &amp;H30, &amp;H31, &amp;H1A, &amp;H33, &amp;H34, &amp;H35, &amp;H36, &amp;H8, &amp;H38, &amp;H39, &amp;H3A, &amp;H3B, &amp;H4, &amp;H14, &amp;H3E, &amp;HE1, _ &amp;H41, &amp;H42, &amp;H43, &amp;H44, &amp;H45, &amp;H46, &amp;H47, &amp;H48, &amp;H49, &amp;H51, &amp;H52, &amp;H53, &amp;H54, &amp;H55, &amp;H56, &amp;H57, _ &amp;H58, &amp;H59, &amp;H62, &amp;H63, &amp;H64, &amp;H65, &amp;H66, &amp;H67, &amp;H68, &amp;H69, &amp;H70, &amp;H71, &amp;H72, &amp;H73, &amp;H74, &amp;H75, _ &amp;H76, &amp;H77, &amp;H78, &amp;H80, &amp;H8A, &amp;H8B, &amp;H8C, &amp;H8D, &amp;H8E, &amp;H8F, &amp;H90, &amp;H9A, &amp;H9B, &amp;H9C, &amp;H9D, &amp;H9E, _ &amp;H9F, &amp;HA0, &amp;HAA, &amp;HAB, &amp;HAC, &amp;HAD, &amp;HAE, &amp;HAF, &amp;HB0, &amp;HB1, &amp;HB2, &amp;HB3, &amp;HB4, &amp;HB5, &amp;HB6, &amp;HB7, _ &amp;HB8, &amp;HB9, &amp;HBA, &amp;HBB, &amp;HBC, &amp;HBD, &amp;HBE, &amp;HBF, &amp;HCA, &amp;HCB, &amp;HCC, &amp;HCD, &amp;HCE, &amp;HCF, &amp;HDA, &amp;HDB, _ &amp;HDC, &amp;HDD, &amp;HDE, &amp;HDF, &amp;HEA, &amp;HEB, &amp;HEC, &amp;HED, &amp;HEE, &amp;HEF, &amp;HFA, &amp;HFB, &amp;HFC, &amp;HFD, &amp;HFE, &amp;HFF) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload