135 pts.
 Deleting IFS records after so many days
Can anyone provide CL code that would delete records within a date range? I would like to delete entries, say-that are 35 days old from the IFS.

Software/Hardware used:
as400 v6r1
ASKED: January 13, 2013  7:32 PM
UPDATED: January 14, 2013  1:01 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question. Michael Tidmarsh   11,390 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Delete records .. or delete files?

 44,150 pts.

 

Yeah, clarification on deleting “records” would be useful. It’d also be helpful to know why CL was requested. CL wouldn’t usually be the first language choice for processing IFS files by date (nor most other ways).

It can certainly be done. I’ve done similar things in three different ways with CL.

The most common and simplest way is by using Qshell utilities. The ‘find’ utility can form the basis of a function that returns IFS files within a chosen path that are older than your set age.

If you wanted more detailed control, the Integrated File System APIs [ http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Funix2.htm ] include opendir(), readdir() and closedir(). You could code a CL procedure to retrieve entries and check dates.

Or Qp0lProcessSubtree() is another Integrated File System API that could be more efficient than the other two possiilities.

Either way with APIs can require fairly detailed knowledge of how to interpret attributes of directory entries. Coding can be fairly complex depending on the directory structure, the CCSID of names, the conversion of date values and other elements.

The Qshell alternative would likely be much simpler to code. It probably would also run much slower. If the volume of entries is high, it might be too slow. It’s pretty easy to practice with the utilities, though. You can work out the command you need interactively.

You can use [ qshell delete age ] as a Google search to find a number of articles. Some of the problems with creating and running such a function are mentioned in different articles. You’ll have to determine what issues you’ll run into, if any.

Tom

 108,055 pts.