IBM i Gurus,
I'm on V5R1 and am trying to use a variable in a CLP for the File and
Member of the FROMFILE parameter on the CPYTOIMPF cmd, but keep getting
CPD0078 (not a valid name) errors.
I've tried 3 different ways and each way comes up with CPD0078. If I
type the cmd from the cmd line it works just fine. My test CLP is as
follows:
PGM
DCL VAR(&DATAFILE) TYPE(*CHAR) LEN(10)
DCL VAR(&CSVFILE) TYPE(*CHAR) LEN(12)
DCL VAR(&FROMFILE) TYPE(*CHAR) LEN(30)
DCL VAR(&STREAMFILE) TYPE(*CHAR) LEN(50)
/* Prepare Variables */
CHGVAR VAR(&DATAFILE) VALUE('CSTU02F2')
CHGVAR VAR(&CSVFILE) VALUE('CSTU02F2.CSV')
CHGVAR VAR(&STREAMFILE) VALUE('QDLS/BPCS/' || +
&CSVFILE)
/***** Test #1 */
/***** Hardcode File, use variable for Mbr */
CPYTOIMPF FROMFILE(('EXCELHDGS ' || &DATAFILE)) +
TOSTMF(&STREAMFILE) MBROPT(*REPLACE) +
STMFCODPAG(*PCASCII) RCDDLM(*CRLF)
/***** Test #2 */
/***** Use variable that includes File and Mbr */
CHGVAR VAR(&FROMFILE) VALUE('EXCELHDGS ' || +
&DATAFILE)
CPYTOIMPF FROMFILE(&FROMFILE) TOSTMF(&STREAMFILE) +
MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
RCDDLM(*CRLF)
/***** Test #3 */
/***** Use variable for Lib, File, and Mbr */
CHGVAR VAR(&FROMFILE) VALUE('SHIOMODTF/EXCELHDGS ' +
|| &DATAFILE)
CPYTOIMPF FROMFILE(&FROMFILE) TOSTMF(&STREAMFILE) +
MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
RCDDLM(*CRLF)
ENDPGM
From the errors I'm getting (see below) it seems as if FROMFILE is being
truncated at 10 characters.
Tests #1 and #2 error message:
"Value 'EXCELHDGS ' for parameter FROMFILE not a valid name."
Message ID . . . . . . : CPD0078
Date sent . . . . . . : 07/19/12 Time
sent . . . . . . : 09:30:05
Message . . . . : Value 'EXCELHDGS ' for parameter FROMFILE not a
valid
name.
Cause . . . . . : Value 'EXCELHDGS ' contains characters that are not
valid
in a name or is a single value that was specified as part of a
qualifier. A
name must begin with an alphabetic character followed by alphanumeric
characters, or if the value is a string of characters, it must be
enclosed
in quotation marks.
Recovery . . . : Correct the name or specify the single value alone,
then
try the command again. More information on names can be found in the
CL
Reference manual.
Test #3 error message:
"Value 'SHIOMODTF/' for parameter FROMFILE not a valid name."
Message ID . . . . . . : CPD0078
Date sent . . . . . . : 07/19/12 Time
sent . . . . . . : 09:34:06
Message . . . . : Value 'SHIOMODTF/' for parameter FROMFILE not a
valid
name.
Cause . . . . . : Value 'SHIOMODTF/' contains characters that are not
valid
in a name or is a single value that was specified as part of a
qualifier. A
name must begin with an alphabetic character followed by alphanumeric
characters, or if the value is a string of characters, it must be
enclosed
in quotation marks.
Recovery . . . : Correct the name or specify the single value alone,
then
try the command again. More information on names can be found in the
CL
Reference manual.
I'm sure this is something simple that I am missing.
Thanks for your help,
Jay Adams
As an Amazon Associate we earn from qualifying purchases.