Home > AS/400 Tips > iSeries administrator tips > How to save time using the CPYTOPCD and CPYFRMPCD commands
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

How to save time using the CPYTOPCD and CPYFRMPCD commands


Ron Turull
10.27.2004
Rating: -3.64- (out of 5)


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



Ron Turull

The Copy To PC Document (CPYTOPCD) and the Copy From PC Document (CPYFRMPCD) commands are real time-savers for copying iSeries physical file members to and from PC text files (i.e., PC documents). These commands provide a two-way data conversion utility between the iSeries and PC via the shared folders system on the iSeries (also called the DLO and DLS systems).

The prompted CPYTOPCD command is shown below. (The CPYFRMPCD command is very similar.)

The translate table parameter

Of particular interest is the Translate Table parameter (TRNTBL keyword). The Translate Table parameter specifies the name of the translation table object (object type *TBL) to use for converting the data. As you are aware, the PC uses ASCII data encoding while the iSeries uses EBCDIC. When you specify the default value of *DFT for the translate table parameter, the CPYTOPCD command will use the system default EBCDIC-to-ASCII table and the CPYFRMPCD will use the system default ASCII-to-EBCDIC table.

The special value *NONE can be used if no data translation is required. This is useful when you need to copy a physical file from one iSeries to another with dissimilar media types (via e-mail or PC media). For example, use the CPYTOPCD command with TRNTBL(*NONE) to copy the data from an iSeries file to a shared folders document. Then attach the document (i.e., file) to an e-mail. Alternatively, copy the document from the "I:" drive to a PC diskette. Load the diskette in a PC connected to another iSeries and reverse the process (e.g., copy the file from the diskette to the I: drive, then use the CPYFRMPCD command with TRNTBL(*NONE) to copy it to a physical file). Note: The to-file on the CPYFRMPCD must already exist.

More Information

You can also specify one of the other many standard translation tables loaded on the iSeries. You can even specify your own table to accomplish specialized data conversion.

Format of PC data parameter

Another parameter that plays a part in data conversion is the format of PC data parameter (TRNFMT keyword). This parameter accepts one of two special values, *TEXT or *NOTEXT, and is ignored if *NONE is specified for the translation table parameter.

Use *TEXT to have the data converted to an ASCII text file. ASCII text files on a PC are stored in variable-length records. Trailing blanks are removed from each record and the records are delimited at the end by a sequence of special characters -- a carriage-return character followed by a line-feed character. PC programs know they have reached the end of a record when this sequence of characters is encountered. You can use just about any popular word processor to edit an ASCII text file.

Using the *NOTEXT special value will result in fixed length records being created in the PC file. Trailing blanks are not removed and no special end-of-record characters are added to the end of the records. The length of the records is equal to the record length of the physical file being copied. Use *NOTEXT when copying data into a PC database.

Three other handy uses of the CPYTOPCD and CPYFRMPCD commands

Once you become familiar with these commands you will find other uses for them. Here are three of my favorites.

  1. Edit iSeries source code in your favorite PC editor. Editing programs written in free-format languages in a Windows-based editor is a real treat after using the text-based SEU. The CPYTOPCD and CPYFRMPCD command can be used to copy to and from iSeries source files. When a source file is copied to a PC file, the sequence numbers and source dates are removed; when a PC text file is copied to an iSeries source file, sequence numbers are added and source dates are set to zeros, which is the major drawback. (If that is a problem, you can always use WebSphere.) Specify TRNFMT(*TEXT) when copying to or from source files for editing purposes.
  2. Find corrupted data faster. Sometimes corrupted data can hide like the proverbial needle in a haystack. The search facilities in SEU are very limited, and sometimes you just can't get the job done with the available query products. That's when we like to use the power of the search facilities found in many of today's most popular PC word processors. Simply copy the data to a PC file and load it into your favorite word processor.
  3. Transfer PC files via the iSeries. SNA Distribution Services (SNADS) is a convenient way to transfer files between two iSeries servers linked by modem. SNADS can also be used to transfer PC files, any type of PC files, even executable files (.EXE's). Use the CPYFRMPCD to copy the PC file to a physical file. Make sure to specify TRNTBL(*NONE) so the data is not translated. The iSeries file can be of any record length. Of course, if FTP is available on both the originating system and the destination system (one as a server and the other as a client), you can just do a binary transfer. It is easier and quicker.

-----------------------------------
About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.


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




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


RELATED CONTENT
iSeries administrator tips
DB2 on AS/400: What has it done for me lately?
Linux for IBM i: Introducing Linux to IBM i people
Application modernization for the iSeries: Why bother?
Application modernization in the i world
Checking on System i disk space requires creating a new command: XRTVSYSSTS
High availability planning and testing for iSeries: Notes, gloats, and moats
Viewing netstat information
Step-by-step PTF download determination
Preventing adopted special privileges on i5/OS
Display documents on your iSeries -- quick and easy

Systems Management
Can you trust all those trigger programs?
Are your backups complete?
Controlling remote command processing
Time for your annual checkup
Watch your profiles
Avoid locking issues
Send message to users at a remote site
Security journal receiver management
Top 10 backup commands
Tracking critical file access in real time

OS/400
Top 10 backup commands
Take control of your iSeries
Top Q&A's on the OS/400
Top 10 security tips
Use caution when providing access to file shares
How to set up an autostart job
How does Sarbanes-Oxley affect you?
Automated disaster recovery revisited
Top 10 Administrator Tips
User profile exit points make administrators' lives easier

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

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 enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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