75 pts.
 text data to packed
i have comp-3 data in a text field. i need to extract the info and convert it back to numerics to download to a pc. i want to use sql ...

Software/Hardware used:
as/400- client
ASKED: August 14, 2009  3:52 PM
UPDATED: October 12, 2009  1:22 AM

Answer Wiki:
You could alter your cobol program to write the field as packed or as text in a text field. You could write a cobol program to read the data and write to a new file with a packed field You could copy this file to another file with a packed field - cpyf with *NOFMT Phil =========================================================== Assume column MIXED is CHAR(10) with positions 1-3 simple characters and positions 4-10 as PACKED(13,0). That is, the first three bytes can be separated with SUBSTR(MIXED,1,3) and the last seven bytes as SUBSTR(MIXED,4,7). The packed bytes can be exposed with HEX(SUBSTR(MIXED,4,7)). If the hex characters are x'0000000000001F', the decimal value is +1. The first 13 characters are all numeric, so the DEC() function can be used: <pre> dec(substr(hex(substr(MIXED,4,7)),1,13),13,0) </pre> If there are decimal positions, the 13 hex characters can be separated with two SUBSTR() functions and CONCATed around a decimal point before processing with the outer DEC(). If the 14th character indicates a negative value, the expression can be multiplied by -1. Create a VIEW to parse the compound field and to expose the sub-values. Use the view for sending values to a PC. Tom
Last Wiki Answer Submitted:  October 12, 2009  1:22 am  by  philpl1jb   44,150 pts.
All Answer Wiki Contributors:  philpl1jb   44,150 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _