CL pgm required to copy data

35 pts.
Tags:
CL
CL Program
I need to create a CL pgm to copy data from 2 files into one. The first file's name to be copied is constant but the second file's name changes on a daily basis. Could anyone help with the syntax required to do this? Thx

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you have a “pattern” to the name change ie date etc. you can “calculate” the name and use a file override for your copy.

If there is no pattern you could have the name of the file entered from a screen making it a variable in your CL program and use an override file over that variable name into your destination file.

If you are running it yourself you can do an override on a command line then call the program.

Need a few more details to help more specifically.

K

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Gilly400
    Hi, You could do something like the following :- PGM PARM(&FILE &LIB) DCL &FILE *CHAR 10 DCL &LIB *CHAR 10 CPYF FROMFIL(LIB1/FILE1) TOFILE(LIB1/NEWFILE) MBROPT(*REPLACE) CPYF FROMFILE(&LIB/&FILE) TOFILE(LIB1/NEWFILE) MBROPT(*ADD) ENDPGM Where LIB1/FILE1 is the (from)file which is always the same name and LIB1/NEWFILE is the file you have to copy to. &FILE is the variable file name and &LIB is the library that contains the variable file name. You could then call the program :- CALL PROGRAM PARM(Myfile Mylib) To process file Myfile in library Mylib. If your variable file is always in the same library then you could remove the &LIB coding and replace the library name in the CPYF command - you also wouldn't need to pass the library on the CALL command. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • KF
    Many thx. The 2 files contain details of reports that are produced on a daily basis, which are to be downloaded into a report archive system for people to view. The first file name is constant but the second changes daily in the format of the date e.g. CYYMMDD File name examples as follows: DOWNLOAD C090512 I need a cl pgm to copy the report data on a daily basis from these 2 files into a new file, that will then be used to download the reports to the archive software. I don't know how to include the data from the file name that changes, and whether I need to declare any variables or message monitoring etc. I would appreciate any help you can give. Thx
    35 pointsBadges:
    report
  • Gilly400
    Hi, You could try the following - this gets the date from the system values and uses that to build the file name - it assumes that all the files are in library YOURLIB. It creates a file called ARCHIVE with a record length of 132 which you can then download - maybe you'll need to increase the record length, depending on your input files. You may need some extra MONMSG's for the CPYF statements. :- PGM DCL &FILENAME *CHAR 10 DCL &DD *CHAR 2 DCL &MM *CHAR 2 DCL &YY *CHAR 2 RTVSYSVAL QDAY &DD RTVSYSVAL QMONTH &MM RTVSYSVAL QYEAR &YY CHGVAR &FILENAME ('C' || &YY || &MM || &DD) CRTPF FILE(YOURLIB/ARCHIVE) RCDLEN(132) MONMSG CPF7302 CPYF FROMFILE(YOURLIB/DOWNLOAD) TOFILE(YOURLIB/ARCHIVE) MBROPT(*REPLACE) CPYF FROMFILE(YOURLIB/&FILENAME) TOFILE(YOURLIB/ARCHIVE) MBROPT(*ADD) ENDPGM Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • KF
    Gilly400, Thx for input. I know only the basics when it comes to cl. The 2 files are already created and it is these files that are required to be copied. How do you get the data from the correct file? The format of the file is YYMMDD preceded always by the letter 'C'. E.G C090512. So, after our end of day processing today the system will create the next days file which will be C090513, and populate it with the data needed. How do you get the correct data from the current file as the previous ones are still held in the library until save/deleted? Thx
    35 pointsBadges:
    report
  • Gilly400
    Hi, You can use RTVSYSVAL to retrieve the system date. Then you can use the date as (part of) the file name. This is what the CHGVAR command does in my example - it "concatenates" the letter C and the year, month and day to give C090512 for the 12th of May 2009. Of course you would need to do this on the same day as your file is created. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • KF
    Hi, Many thanks for your help. I'll set this up in our test system. Regards Keith
    35 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following