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.
A..........T.Name++++++RLen++TDpB. A R PACKEDR A PCKFLD 5P 2
2. Create an LF that makes the packed field look like a zoned field.
A..........T.Name++++++.Len++TDpB......Functions++++++ A R PACKEDR PFILE(PACKEDPF) A PCKFLD S
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 ASCII 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.
8. Executing "get charview charview.txt" gives almost a useful result.
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.