Return to the Systems Tips
Create a Tilde-delimited File
Dear MC Wizard:
My company is contractually committed to
supply a customer with a data file extracted from our
iSeries (AS/400) system and translated into a ASCII text
file. This is not a problem, except the customer requires
that the fields in the extracted ASCII file be tilde-
delimited, and the software my company owns does not
support a tilde-delimited file transfer.
The customer's suggestion was to concatenate all of the fields (and there are lots of them) into one field and programmatically concatenate a tilde character (~) between each field. That just doesn't seem to be a very magical or practical way of doing this, so I am hoping that you can pull a rabbit out of your hat for me by recommending some other approach, or by recommending a vendor that has an affordable way of specifying a tilde as the field delimiter for a file transfer. --Tormented by Tildes
Dear Tormented: Tilde-delimited files, huh? What will they think of next? The Copy to Import File will do the job for you. Put a tilde in the Field Delimiter (FLDDLM) parameter. Here's an example. It assumes you'll need to end with records with the standard carriage-return-line- feed combination and that character fields won't need to be in quotation marks:
CPYTOIMPF FROMFILE(WIZARD/PRODUCTS) TOSTMF('/home/wizard/products.txt') STMFCODPAG(*PCASCII) RCDDLM(*CRLF) STRDLM(*NONE) FLDDLM('~')This example will work on V5R1 systems; on prior releases, you cannot use the STMFCODPAG parameter to set the output file's CCSID. The workaround on those systems is to create the output file with the proper CCSID before running the CPYTOIMPF command. The commands to do this are:
CRTPF FILE(QTEMP/DUMMY) RCDLEN(1) CPYTOSTMF FROMMBR('/qsys.lib/qtemp.lib/dummy.file/dummy.mbr') TOSTMF('/home/wizard/products.txt') STMFCODPAG(*PCASCII) DLTF FILE(QTEMP/DUMMY)Get to know CPYTOIMPF and its companion, Copy from Import File (CPYFRMIMPF). IBM has put a lot of ability into them, and they can save you the trouble of writing programs to build or read files designed for transfer of data from one system to another. Be tormented no longer.
[report a broken link by clicking here]