How to retrieve file names from AS400 directory

Hello,

We need to get only file names from AS400 directory. Is there anyway to get job number of a specific job?

EG: We have created a spool file with default name that has a job number that identifies different spool files.
How to retrieve this job number during the file creation time?

Eg for 1st situation: We have created a directory in AS400. The files keep on adding to the directory. How to retrieve all these file names at any time?

Please respond quickly.

Thanks in Advance
 

premavaniAsked:
Who is Participating?
 
tliottaCommented:
Prema:

Do you have QShell available? Easiest way is to use the QSH 'ls' utility to list the names. Something like:

 ==>  ls >/qsys.lib/mylib.lib/myfile.file/mymbr.mbr

Details can be added for specific examples if you need them.

If not, then you may need to write programs using IFS APIs to read the directory entries.

Tom
0
 
MurpheyApplication ConsultantCommented:
Hello premavani,

First:  We need to get only file names from AS400 directory

Just run the dspobjd command:

DSPOBJD OBJ(MYFILELIB/*ALL)          
        OBJTYPE(*FILE)            
        OUTPUT(*OUTFILE)          
        OUTFILE(MYLIB/FILELIST)    

Now you have a file FILELIST in library MYLIB. and you can browse the contents.
if you just want to have the file names run a query or copy the file with *MAP *DROP option
to a new file by:
creating file ODOBNM with  CRTPF FILE(MYLIB/ODOBNM) RCDLEN(10)

And copy the contents of the FILELIST with:

CPYF FROMFILE(MYLIB/FILELIST)
     TOFILE(MYLIB/ODOBNM)  
     MBROPT(*REPLACE)        
     CRTFILE(*NO)            
     OUTFMT(*CHAR)          
     FMTOPT(*MAP *DROP)      


> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

About the jobnumber:

type WRKACTJOB
and press 2 times the F11 there you see all the jobnumbers.

Regards,
Murph



0
 
premavaniAuthor Commented:
Hi Murph,

DSPOBJD will retreive file names that are there in the library.
I want to retrieve file names from an AS400 directory.

EG: we have created a directory called tmp in AS400. In that directory we have kept few xml files.
To process these files, we need the xml file name. Is there any CL command to retrieve these file names?

Please respond ASAP.

Thanks
Prema

0
 
tliottaCommented:
Note that Raj was specific in requesting a list of "directory" file names and not "library" file names.

Tom
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.