When we're done reading the directory, we need to close it. To do that, we will call the Close Directory API, closedir().
Here's the C and RPG prototypes for closedir():
int closedir(DIR *dirp)
D closedir PR 10I 0 EXTPROC('closedir')
D dirhandle * VALUE
Calling this API is quite simple, just pass it the variable that you received when you called opendir().
For example:
c if closedir(d) < 0
c callp EscErrno(errno)
c endif