text data to packed
25 pts.
0
Q:
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: Aug 14 2009  3:52 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
7590 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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:


dec(substr(hex(substr(MIXED,4,7)),1,13),13,0)


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 Answered: Oct 12 2009  1:22 AM GMT by TomLiotta   7590 pts.
Latest Contributors: Philpl1jb   24540 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0