How to read a text file to use for variables in CL

5 pts.
Tags:
CL programming
CL variables
I have a CL that saves libraries as savf files to later FTP to a storage device. For each library I have a set of commands that specifiy the specific library and the specific savf file for that library. The commands are repeated three times, once for each library/savf file. I would like to have the CL read from a text file containing the list of save libraries, perhaps with the associated savf file for each library. This would then loop through the library list in the text file, bringing back the library and file names to be used in a variable. Can someone help me with the call to the external library and the loop configuration? I've done this in other batch languages but am reall new to the IBM CLP (It took me 8 hours to do my basic CL and FTP. Thanks in advance for any help available. Patrick Frank

Answer Wiki

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

– 1. create a db2 file for your data

— 2. cl

PGM
DCLF yourFile

LOOP: RCVF /* reads next record from yourFile */
MONMSG CPF0864 EXEC(GOTO EOF)

/* here you can use the fields from the file, the field names are the db2 field name preceeded with & */
/* so a field named savflib would be used here as &savflib */

GOTO LOOP

eof: endpgm

//////////////////////////////////////////////////////

I’m not sure if this will help but you can use a file on the 400 that has all the files listed with properties. Just copy out what you need. It has the libraries,files,type..etc..
QSYS/QADBXREF

Thanks
Ron

Discuss This Question: 2  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
  • TomLiotta
    Please supply OS version/release. Prior to V5R4, CL had almost no chance of reading a "text file" without some help. A text file in the /QDLS file system could be read with the HFS APIs, and a user space could contain a copy of a text file and be read with the user space APIs. (Copying between the /root file system and a user space can require *AUDIT special authority.) I think V5R4 CL can read text files, but I'm not sure why anyone would do it unless no other compiler was available. Also, Qshell scripts can process text files easily. A CL program can invoke Qshell with the STRQSH command. Tom
    125,585 pointsBadges:
    report
  • Caddy4Tiger
    I found some freeware from Ariadne software with examples that enable files to be read and updated in a CL program much as above. I'm using those commands in my CL back-up routines See CLDBIOV2R1 - Best regards Allun
    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