We recently got this suggestion from a reader:
“You could try explicitly specifying: RCDDLM(*CRLF)
in your CpyToImpF command. It works for me we’re running OS/400 V5R2.”
If the field being transferred is a CHAR field, then trailing spaces is correct and they should not be truncated. If the field is VARCHAR, then the trailing spaces shouldn’t exist to be truncated.
If the field is CHAR and you want to <i>convert</i> it to VARCHAR, then you need to tell the system that that’s what you want to do. One good way of doing that is with SQL DDL, since that’s the language designed to communicate data formatting info to the database.
Create a VIEW that does the conversion and use the VIEW for input to CPYTOIMPF:
CREATE VIEW mylib/myview
SELECT varchar(trim(CharCol1)) as VCol1
That view converts column CharCol1 from the base table into VCol1 in the view. You can use iSeries Navigator or RUNSQLSTM to execute SQL if you don’t have interactive SQL available.