Home > AS/400 Tips > iSeries programmer tips > Use SQL views to transfer packed data using FTP
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Use SQL views to transfer packed data using FTP


Vernon Hamberg
01.13.2005
Rating: -4.14- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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



Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
iSeries programmer tips
Groovy programming on IBM i
EGL Rich UI on IBM i: Do you Dojo?
Running PHP open source applications: NOBODY needs authority
Programming for the Web on the IBM i, what is possible
Using geocoding on AS/400 to enhance your Web presence
The best technologies and tools for System i programmers in 2009
Seven IBM i project lessons learned in 2008
Documenting nested program structures on the AS/400
What is an integrated database?
An automated CL method of moving a query from AS/400 to Excel

FTP
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
Generically send a text file from the IFS via FTP
Automate Client Access to find files on Windows scheduler
SAVF by FTP on AS/400 -- error "source file not found"
Use a virtual directory to move a .bmp file from the IFS to a remote server to run a software package
Transferring binary files to IFS from a PC via FTP
FTP from AS/400 to PC folder
How to FTP without knowing the file name
IFS folder error
Creating the correct member type in a source physical file via FTP

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


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.

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.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts