Sponsors
Search
Link to our site
Learning Resources
H DftActGrp(*NO) Option(*SRCSTMT) H BNDDIR('QC2LE') // Convert string of hex characters representing ASCII data to // EBCDIC values. Vendor is supplying a file that contains data // like '414243303132' which needs to be interpreted as ABC012. // The entire string received from the vendor is hex representation // of ASCII characters. D ASCII S 16383 D hexIn S 32767 D Hex2Chr Pr ExtProc('cvtch') D Tgt 16383A Options(*VarSize) D Src 32767A Options(*VarSize) D SrcLen 10i 0 Value D Chr2Hex Pr ExtProc('cvthc') D Tgt 32767A Options(*VarSize) D Src 16383A Options(*VarSize) D TgtLen 10i 0 Value D Translate PR ExtPgm('QDCXLATE') D Length 5P 0 const D Data 32766A options(*varsize) D Table 10A const D up c 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' D lo c 'abcdefghijklmnopqrstuvwxyz' D valueToConvert... D C '436f6d7042656e656669747320+ D 6f6620496c6c696e6f69732020+ D 2020202032303020572E204A61+ D 636B736F6E2020202020202020+ D 20202020202039746820466C6F+ D 6F722020202020202020436869+ D 6361676F202020202020202049+ D 4C363036303620202020203830+ D 302D3833372D3233343115AAC2+ D E1333035303031737979797966+ D 00460050005A00057920202020+ D 20202020202020202020202020+ D 20202020202020202020203230+ D 6E79206E332E3330206E6E6E62+ D 6130306E6E6E6E6E6E6E202020+ D 20202020202020202020202020+ D 20202020202020202020202030+ D 3030306E6E6F30316E6E6E6E6E20' D /Free hexIn = valueToConvert ; // Convert entire string to UPPER case. hexIn = %xlate(lo:up:hexIn); // Convert Hex to ASCII. Hex2Chr(ASCII:HexIn:%len(%trimr(HexIn))); // Convert ASCII to EBCDIC Translate(%len(ASCII): ASCII: 'QTCPEBC'); *inlr = *On ; /End-free
[report a broken link by clicking here]