CPYTOIMPF FROMFILE(*LIBL/MY_SRC_FILE *FIRST) TOSTMF('MY_TGT_STREAM')
STMFCODPAG(*PCASCII) RCDDLM(*CRLF) DTAFMT(*FIXED) STRDLM(*NONE)
FLDDLM('')
CPYTOIMPF FROMFILE(*LIBL/MY_SRC_FILE *FIRST) TOFILE(*LIBL/MY_TGT_FILE)
DTAFMT(*FIXED) STRDLM(*NONE) FLDDLM('')
The layout of the /fixed format/ must account for that growth which
enables room for whichever data type. For decimal numeric that will be
room for the sign and decimal separator.
Regards, Chuck
--
All comments provided "as is" with no warranties of any kind
whatsoever and may not represent positions, strategies, nor views of my
employer
Okay, fair enough. But if the field is declared with 0 decimal places
(as they are), wouldn't that make reserving a decimal point place
redundant? Regardless, is there any way to supress this "padding". I
can't see that there is an easy way to remove it after the file has
been created... Thanks again.
can you make an all character intermediate, or a copy to a 2048 no dds
file *nochk and then to your impf?
So for example, DECIMAL(7, 0) is nine bytes CHAR.
select length(char(decimal(int(1), 7, 0)))
, char(decimal(int(1), 7, 0))
from sysibm.sysdummy1
....+....1....+....2....+
LENGTH CHAR
9 1
******** End of data ****
FWiW a database export feature is not intended to be a report writer,
so a few extra blanks or other nuances are not usually an issue. The
requirement is effectively, that given an FDF so the layout of the data
is properly described, to enable an import. Because the eventual text
transport is typically going to compress the data, the extra storage is
also typically not an issue. And where storage is an issue, a more
appropriate export format would be chosen; i.e. delimited versus fixed.
In V5R4 for delimited, as I recall, there is an option to strip
trailing blanks.
Regards, Chuck
--
All comments provided "as is" with no warranties of any kind
whatsoever and may not represent positions, strategies, nor views of my
employer
I suppose if the transport were limited only to CPYTOSTMF because
that interface does not support the externally described database file
directly. If something like that, then if an intermediate copy is
acceptable [as can be inferred] and the data is all character, then the
following:
DSPFD *LIBL/MYDATAFILE /* Get MaxRcdLen */
CRTSRCPF QTEMP/zMaxRcdLen RCDLEN(12+MaxRcdLen)
CPYF FROMFILE(*LIBL/MYDATAFILE) TOFILE(QTEMP/zMaxRcdLen)
FMTOPT(*CVTSRC) TOMBR(TheMbr) MBROPT(*REPLACE)
CPYTOSTMF
FROMMBR('/qsys.lib/qtemp.lib/zMaxRcdLn.FILE/TheMbr.MBR')
TOSTMF('MY_TGT_STREAM') STMFOPT(*REPLACE) DBFCCSID(*FILE)
STMFCODPAG(*PCASCII) ENDLINFMT(*CRLF)
Regards, Chuck
--
All comments provided "as is" with no warranties of any kind
whatsoever and may not represent positions, strategies, nor views of my
employer
> I have a fixed format database file I want copied to a stream file or
> another database file with a single VARLEN field. I need the data in a
> fixed length format that correlates exactly with the DDS described
> length of each field in the source file.
Consider using the Qshell db2 utility to SELECT the columns and CONCAT
their values (or substrings of character representations) into whatever
widths you need. Redirect Qshell output to a streamfile.
--
Tom Liotta
http://zap.to/tl400
SQL example: CHAR(CHAR(MY_DEC_FIELD),10) as MY_CHAR_FIELD
Using CPYF with *NOCHK was giving me the error "buffer length is
greater than record length", since the records I am appending are of
different sizes. Would be great if it allowed you to ignore this error
and just pad with blanks. I mean, its a character field! Anyway,
thanks for all the suggestions people. This turned out to be more of a
problem than I anticipated.
It is very unclear to me what is really being attempted; for lack of
an example. But what I can infer from what has been stated so far,
there is a lot of unnecessary work being done. For example, if the SQL
was used to generated the fixed data, it could have just as well been
used to effect the VARCHAR() result in the same request.? There should
be no reason to even make a temporary copy, as that SQL statement could
be used directly, either in a program or in a VIEW.
Regards, Chuck
--
All comments provided "as is" with no warranties of any kind
whatsoever and may not represent positions, strategies, nor views of my
employer