Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CPYTOIMPF in a CL using a variable

Status
Not open for further replies.

Muskalane

Programmer
Nov 18, 2011
1
US
Hello, I'm trying to rename a file using a variable in the CPYTOIMPF command. I want to append the current date.

CPYTOIMPF FROMFILE(QTEMP/B1183) +
TOSTMF('tmp/B1183_&DATE.csv') +
MBROPT(*REPLACE) STMFCODPAG(*STDASCII) +
RCDDLM(*CRLF) STRDLM(*NONE) FLDDLM(',')


It's not working and my file name ends up B1183_&DATE.csv. I'm not very familiar with this command.

Does anyone know a workaround?

Thank you so much.
Muskalane
 
First you have to compose the CSV-filename something like this
Code:
/* Create CSV file name from date */
CHGVAR     &CSVNAME VALUE('B1183_' *CAT &DATE *CAT '.csv')
and then use it in the command
Code:
CPYTOIMPF  FROMFILE(QTEMP/B1183) +                   
           TOSTMF(&CSVNAME) +         
           ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top