Sponsors
Search
Link to our site
Learning Resources
I had a string of hex data coming over from SQL Server. The data was a mix of alphabetic characters, y, n, etc... and numeric values, both integer and decimal. To convert the numeric values I used the following. d cvthexval PR extproc('cvtch') d shortReceiver * value d longSource * value d sourceBytes 10i 0 value D loHex C 'abcdef' D hiHex C 'ABCDEF' d charval4 S 4a d charval S 8a d intResult S 10i 0 D work8 s 8A D work4 s 4A D ClmPdYt s 9 2 D ClmDedS s 4 0 /free // convert to decimal - 9,2 work8 = %subst(ccdata:3:8); // Convert Hex characters to upper case charVal = %xlate(loHex:hiHex:Work8); // convert ASCII hex values to EBCDIC cvthexval(%addr(intResult) : %addr(charVal) : %size(intResult) * 2); ClmPdYt = intResult / 100; // Convert to integer - 4,0 work4 = %subst(ccdata:11:4); // Convert Hex characters to upper case charVal = '0000' + %xlate(loHex:hiHex:Work4); // convert ASCII hex values to EBCDIC cvthexval(%addr(intResult) : %addr(charVal) : %size(intResult) * 2); ClmDeds = intResult; /end-free
[report a broken link by clicking here]