I am receiving a file daily in an IFS directory, I manually copy the file to a library using the CPYFRMSTMF command. I want to automate the process so that it will be done every day at a specific time. The challenge is that the file name in the IFS directory is different every day, for example it is ABC121206 today and ABC121306 tomorrow and the CPYFRMSTMF cannot take a generic value such as ABC*. Is there a process or API that would rename the file to a generic name in the IFS so that the CPYFRMSTMF command would use that name every days?
Thanks

Answer Wiki

If the file name contains a date. Create a variable with the constant (i.e. ABCxxxxxx). You can do it one of two ways (chgvar &filename (‘ABC’ || &date)) or (chgvar substr(&filename,4,6) &date). Use the variable (&filename) in you copy statement.

=============================================

If you have Qshell installed, try experimenting with something like this:<pre>
crtdtaara MYLS *char 32
qsh cmd(‘ls | datarea -w -l MYLS’)
dspdtaara MYLS</pre>Note that the “pipe” character between the ls and datarea utilities will need to be the appropriate pipe character for your system. Right now, my emulator sessions require using “!”.

There are far better ways of doing this, but you need something simple for now. What I coded is simply to give you an example to see if it can be adapted. You ought to be able to copy/paste those commands onto a command line (watching the “pipe”.)

The code creates a basic *char(32) data area in the current library — pick a library you prefer, set the size you need. The STRQSH commands then list (ls) the current directory to standard out, which is piped into the datarea utility, which writes (-w) lines to the MYLS data area found in the library list (-l). You can then display the data area to see what’s there. In a CL program, you’d use RTVDTAARA rather than DSPDTAARA of course.

If you try variations of ls, you can choose the path that you want to list and set a pattern to select which files to list. If there’s only and always just a single file, then you probably won’t have to worry much.

It’s not very sophisticated. I didn’t think you needed anything but the basics. It should be easy enough to adapt for various purposes.

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

Processing your response...

Discuss This Question: 1 &nbspReply

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

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

If you need the process to be more forgiving you can create a list of the file names in the IFS folder and populate a physical file with the results. Then run a program to use CPYFRMSTMF for each filename in your physical file. Here is some sample CL code to create the physical file with the list of filenames in the IFS the reason for filelist2 is this PF has the field name in it.
CLRPFM FILE(mylib/FILELIST) QSH CMD('(LS /IFSfoldername>/QSYS.LIB/mylib.LIB/FILELIST.FILE/FILELIST.MBR)')
CPYF FROMFILE(mylib/FILELIST) TOFILE(mylib/FILELIST2) MBROPT(*REPLACE) FMTOPT(*NOCHK)

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

Processing your reply...

Ask a Question

Free Guide: Managing storage for virtual environments

Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!

To follow this tag...

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