How to retrieve file names from AS400 directory

Posted on 2005-04-29
Last Modified: 2012-08-14

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

Question by:premavani
    LVL 16

    Expert Comment

    by:theo kouwenhoven
    Hello premavani,

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

    Just run the dspobjd command:


    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:

         FMTOPT(*MAP *DROP)      

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

    About the jobnumber:

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



    Author Comment

    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.


    LVL 26

    Accepted Solution


    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.

    LVL 26

    Expert Comment

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now