The question of how to transfer packed data from an iSeries to an ASCII system has been asked many times. It has been suggested that one can use a logical file that redefines the packed field as zoned. This works as long as the value is non-negative and the number of decimals is 0 - the decimal point does not get transferred.
CPYTOIMPF and CPYFRMIMPF can also be used but require extra steps in the process.
A standard logical file cannot convert numeric data to character, either. But a view can use the CHAR function to convert any numeric data to left-justified values that have the sign and the decimal point.
To test this idea, take the following steps:
1. Create a PF with a single packed 5,0 field.
2. Create an LF that makes the packed field look like a zoned field.
3. Create a view over the PF that converts the packed field to character.
create view somelib/charview (pckfld) as select char(pckfld) from packedpf
4. Add some data, both positive and negative - I used 5 and -4.
5. Start an FTP session from Windows, using ASC...
To continue reading for free, register below or login
To read more you must become a member of Search400.com
');
// -->

II mode.
6. Executing "get packedpf packedpf.txt" results in the usual garbage.
7. Executing "get zonedpf zonedpf.txt" gets closer but no decimal point, and the sign is obscured.
00500
0040}
8. Executing "get charview charview.txt" gives almost a useful result.
5.00
-4.00
There is still a problem with varying field lengths. However, you could use quotes and commas in the SELECT statement to generate a CSV-formatted output.
==================================
MORE INFORMATION ON THIS TOPIC
==================================
The Best Web Links: tips, tutorials and more.
Visit the ITKnowledge Exchange and get answers to your developing questions fast.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.