Function module to list files

Hii
Can anyone help me in finding a function module that lists all the files form the application server directory along with the craetion date and time??
I was using the function module SUBST_GET_FILE_NAME which lists all the files, but the date and time is not maintained here..I mean, the file creation date and time fields are available, but blank..I want the date and time as can be seen in AL11 when we browse for a file in a directory..
Tx

Hi,
use this program or put the code in a function module if you want
i have not provided any output, so put a breakpoint at the write:/ 'end'. statement and see the contents of the file_list internal table
*& Report  ZKRIS_GET_DIRECTORY_FILES_ATTR
REPORT  zkris_get_directory_files_attr.
PARAMETERS: p_dir(128) DEFAULT 'write your dir name here'.
TYPES: name_of_dir(1024)        TYPE c,
       name_of_file(260)        TYPE c,
       name_of_path(1285)       TYPE c.
DATA: BEGIN OF file,
        dirname     TYPE name_of_dir,  " name of directory. (possibly
                                       " truncated.)
        name        TYPE name_of_file, " name of entry. (possibly
                                       " truncated.)
        type(10)    TYPE c,            " type of entry.
        len(8)      TYPE p,            " length in bytes.
        owner(8)    TYPE c,            " owner of the entry.
        mtime(6)    TYPE p, " last modification date, seconds since 1970
        mode(9)     TYPE c, " like "rwx-r-x--x": protection mode.
        useable(1)  TYPE c,
        subrc(4)    TYPE c,
        errno(3)    TYPE c,
        errmsg(40)  TYPE c,
        mod_date    TYPE d,
        mod_time(8) TYPE c,            " hh:mm:ss
        seen(1)     TYPE c,
        changed(1)  TYPE c,
      END OF file.
DATA: sap_yes(1)  VALUE 'X'
    , sap_no(1)   VALUE ' '
    , srt(1)      VALUE 'T'
    , no_cs       VALUE ' '            " no MUST_ContainString
    , all_gen     VALUE '*'    " generic filename shall select all
    , strlen      LIKE sy-fdpos
DATA: BEGIN OF file_list OCCURS 100,
        dirname     TYPE name_of_dir,  " name of directory. (possibly
                                       " truncated.)
        name        TYPE name_of_file, " name of entry. (possibly
                                       " truncated.)
        type(10)    TYPE c,            " type of entry.
        len(8)      TYPE p,            " length in bytes.
        owner(8)    TYPE c,            " owner of the entry.
        mtime(6)    TYPE p, " last modification date, seconds since 1970
        mode(9)     TYPE c, " like "rwx-r-x--x": protection mode.
        useable(1)  TYPE c,
        subrc(4)    TYPE c,
        errno(3)    TYPE c,
        errmsg(40)  TYPE c,
        mod_date    TYPE d,
        mod_time(8) TYPE c,            " hh:mm:ss
        seen(1)     TYPE c,
        changed(1)  TYPE c,
      END OF file_list.
DATA: BEGIN OF searchpoints OCCURS 10,
        dirname     TYPE name_of_dir,  " name of directory.
        sp_name     TYPE name_of_file, " name of entry. (may end with *)
        sp_cs(10)   TYPE c, " ContainsString pattern for name.
      END OF searchpoints.
searchpoints-dirname = p_dir.
searchpoints-sp_name = '*'.
searchpoints-sp_cs = ''.
PERFORM fill_file_list USING searchpoints-dirname
                             searchpoints-sp_name
                             searchpoints-sp_cs
WRITE:/ 'end'.
*&      Form  fill_file_list
*       text
*      -->A_DIR_NAME      text
*      -->A_GENERIC_NAME  text
*      -->A_MUST_CS       text
FORM fill_file_list USING a_dir_name a_generic_name a_must_cs.
  " Routine von M. Mittelstein
******************************************************************CAS***
* Es wird eine Liste von Dateinamen in die Tabelle FILE_LIST gelesen.
* A_DIR_NAME ....... directory name
* A_GENERIC_NAME ... generic filename (may end with *)
* A_MUST_CS ........ a contains pattern for legal filenames  OR NO_CS
  DATA: errcnt(2) TYPE p VALUE 0.
*  call 'C_DIR_READ_FINISH'             " just to be sure
*      id 'ERRNO'  field file_list-errno
*      id 'ERRMSG' field file_list-errmsg.
*  call 'C_DIR_READ_START' id 'DIR'    field a_dir_name
*                          id 'FILE'   field a_generic_name
*                          id 'ERRNO'  field file-errno
*                          id 'ERRMSG' field file-errmsg.
  IF sy-subrc <> 0.
    sy-subrc = 4.
    EXIT.
  ENDIF.
  DO.
    CLEAR file.
    CALL 'C_DIR_READ_NEXT'
      ID 'TYPE'   FIELD file-type
      ID 'NAME'   FIELD file-name
      ID 'LEN'    FIELD file-len
      ID 'OWNER'  FIELD file-owner
      ID 'MTIME'  FIELD file-mtime
      ID 'MODE'   FIELD file-mode
      ID 'ERRNO'  FIELD file-errno
      ID 'ERRMSG' FIELD file-errmsg.
    file-dirname = a_dir_name.
    MOVE sy-subrc TO file-subrc.
    CASE sy-subrc.
      WHEN 0.
        CLEAR: file-errno, file-errmsg.
        CASE file-type(1).
          WHEN 'F'.                 " normal file.
            PERFORM filename_useable USING file-name file-useable.
          WHEN 'f'.                 " normal file.
            PERFORM filename_useable USING file-name file-useable.
          WHEN OTHERS.              " directory, device, fifo, socket,...
            MOVE sap_no  TO file-useable.
        ENDCASE.
        IF file-len = 0.
          MOVE sap_no TO file-useable.
        ENDIF.
      WHEN 1.                     " end of directory
        EXIT.
      WHEN 4.                     " filename too long
        MOVE sap_no TO file-useable.
      WHEN OTHERS.
        ADD 1 TO errcnt.
        IF errcnt > 90.
          EXIT.
        ENDIF.
        IF sy-subrc = 5.
          MOVE: '???' TO file-type,
                '???' TO file-owner,
                '???' TO file-mode.
        ELSE.
*         ULINE.
*         WRITE: / 'C_DIR_READ_NEXT', 'SUBRC', SY-SUBRC.
        ENDIF.
        MOVE sap_no TO file-useable.
    ENDCASE.
    PERFORM p6_to_date_time_tz(rstr0400) USING file-mtime
                                               file-mod_time
                                               file-mod_date.
*   * Does the filename contains the requested pattern?
*   * Then store it, else forget it.
    IF a_must_cs = no_cs.
      MOVE-CORRESPONDING file TO file_list.
      APPEND file_list.
    ELSE.
      IF file-name CS a_must_cs.
        MOVE-CORRESPONDING file TO file_list.
        APPEND file_list.
      ENDIF.
    ENDIF.
  ENDDO.
  CALL 'C_DIR_READ_FINISH'
      ID 'ERRNO'  FIELD file_list-errno
      ID 'ERRMSG' FIELD file_list-errmsg.
  IF sy-subrc <> 0.
    WRITE: / 'C_DIR_READ_FINISH', 'SUBRC', sy-subrc.
  ENDIF.
  IF srt = 'T'.
    SORT file_list BY mtime DESCENDING name ASCENDING.
  ELSE.
    SORT file_list BY name ASCENDING mtime DESCENDING.
  ENDIF.
  sy-subrc = 0.
ENDFORM.                    "FILL_FILE_LIST
*&      Form  filename_useable
*       text
*      -->A_NAME     text
*      -->A_USEABLE  text
FORM filename_useable USING a_name a_useable.
*----================------------------------
  DATA l_name(75).
  l_name = a_name.
  IF l_name(4) = 'core'.
    a_useable = sap_no.
  ELSE.
    a_useable = sap_yes.
  ENDIF.
ENDFORM.                    "FILENAME_USEABLE

Similar Messages

  • Function module for logical file path and name

    Hello all,
    I am wondering is there any function module available to translate a logical file path to a physical file path and a logical file name to a physical file name? Thanks a lot!
    Regards,
    Anyi

    Please check the FM FILE_NAME_GET.
          CALL FUNCTION <b>'FILE_GET_NAME'</b>
             EXPORTING
               logical_filename = 'ZDELCHKREP'
               parameter_1 = it_cntry-cntry
             IMPORTING
               file_name        = l_file
             EXCEPTIONS
               file_not_found   = 08.
        CALL FUNCTION <b>'FILE_GET_NAME_USING_PATH'</b>       EXPORTING
             logical_path = 'ZDELCHKREP'
             file_name = l_file
           IMPORTING
             file_name_with_path = l_file.
    Message was edited by: Anurag Bankley
    Message was edited by: Anurag Bankley

  • Function Module for listing Equipments based on Material Number

    Hi,
       I need to display list of Equipments based on the given Material Number.
       This can be done by simple query statement as given below,
              SELECT equnr matnr sernr FROM equi
              INTO CORRESPONDING FIELDS OF TABLE <Int Table>
              WHERE matnr IN im_matnr.
        But, I need Function module to acheive this. Can anyone suggest me the Standard Function module which works as mentioned above?

    Hi Shirlatha,
    If you need to  only above code  value  then you can create own FM  and pass the MATNR only.
    In SAP BAPI_EQMT_DETAIL  one FM is there to get complete Equipment details but need to pass matnr and Equipment  number.
    Please try to use this FM or you can create Own FM.
    Regards,
    Prasenjit

  • Function Modules, for listing Cost centers Under a manager

    Hi All,
    1. Can any one please suggest me any Function Module available for listing the cost center under a manager, given only the Manager's username or pernr.
    2. And also the Function Group which has the collection of Function Modules which deals with operations and reporting on Cost centers from a Manager's Role (basically on budjet Monitoring aspects).
    Thanks and Regards,
    Girimurugan

    If this is the followup of the previous post (responsible person) and you wanted to get a list of cost centers based on that using a FM , i doubt that there is a FM available for that. You have to read the table to get the info.
    When you say manager, he could be a manager for a HR organisation but the cost organization may be different. in a typical set up it would be a cost center group (which will have set of cost centers under it) and this will be linked to a hr organization.
    All this is purely based on how cost center hierarchy (standard hierarchy) and hr organization maintained and how they are linked.
    Regards
    Raja

  • Function module to list out a report's input/output parameters

    Hi experts,
    I'd like to know if there is a function module which can list out all the input and output parameters (variables, tables, etc.) by giving the report name as input.
    If not, please suggest a way to find out the input/output parameters.
    Regards,
    Ancy

    Well, they're not input/output parameters, and really you shouldn't refer to them as such.  A variable is simple what it says - a variable.  You could, I suppose, refer to data sources.  But then, the report could be getting data from a set of function modules.
    So my assumption is correct, you are talking about a where-used list.
    >Check out tables like CROSS. To find other useful tables, put an SQL trace on, do the where used, and see what tables are hit.
    matt

  • ABAP Function Module for Output File Compression of HTML file

    We would to compress a HTML file that is created during a daily batch run so that it can be sent to the concerned users by email.
    THerefore we are looking for a Function Module and code that can do this for us.
    Please help.
    You can contact me at [email protected]
    Thanks.
    Suresh Rao

    We would to compress a HTML file that is created during a daily batch run so that it can be sent to the concerned users by email.
    THerefore we are looking for a Function Module and code that can do this for us.
    Please help.
    You can contact me at [email protected]
    Thanks.
    Suresh Rao

  • Function module to know file data.

    Hello Experts,
    Is there any function module available which can give me details of a file like no of rows and cols in a file?
    My input file is EXCEL file and I want to know no of lines (i.e rows) present in file before reading it.
    If there is no such FM then plz let me know any function module which will read an excel file line by line in internal table as follow :
    types : begin of ty_itab,
               Line type string,
         End of ty_itab.
    Data : gt_itab type standard table of ty_itab.
    i want ot read excel file in above internal table which stores excel file dta line by line in it.
    -Shweta

    Hi,
    You can use FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' to read excel to internal table. But you need to know begin row, begin column, end row, and end column. The internal table is SAP standard format, so you need to process it to your custom internal table.
    Anyway, reading data from excel is a lot more time consuming compared to reading data from tab delimited file and using FM 'GUI_UPLOAD'. Changing the source data from excel to a tab delimited file is also an easy task for user (copy paste from excel to notepad). So I recommend to change the requirement and make tab delimited file as your input.
    Regards,
    Teddy Kurniawan

  • Function module for uploading file in background

    hi friends
    i am working on Inbound IDOC interface where in which i am creating a function module for that,
    in which based on the idoc received , the interface has to choose the file from the shared folder and it has to move its contents to an internal table
    can anybody suggest me what function module can i use.
    we cant use GUI_upload,or cl_gui_frontend_services=>gui_upload
    because this requires an user to interact in mines it is not the case
    thanks in advance
    with regards
    s.janagar

    hi,
    check this thread,you will get idea how to transfer data from file to internal table.
    [https://forums.sdn.sap.com/click.jspa?searchID=17706879&messageID=6281020]

  • Any function module to transfer File(Excel)  from Appli Serveto Unix Server

    Hi all,
    Do you have any function module to transfer excel file from application server to Unix server.
    Can anyone have some sample code for the same.
    Thanks in Advance.
    Sreedhar Marri

    Hi,
            There is no function module ,instead use open dataset command.
    Syntax example,
    data: e_file like rlgrap-filename.
    data : txtstr type string.
    concatenate  searchpoints-dirname '/scm/' werks '/' filnam into e_file.
      open dataset e_file for output in text mode encoding default.
    loop at itab.
        concatenate itab ',' into txtstr.
         transfer txtstr to e_file.
      endloop.
    where itab is the contents u want to transfer.
    Pls check for required authorisations with ur BASIS for open dataset command.
    Regards,
    Balakumar.G.

  • Function Module for creating file name in Application Server

    Hi Guys,
    Can you suggest me a function module to generate a file name for a flat file to be save on application server using DATASET. 
    Required filename format : <table name >.<times tamp>.TXT
    Thanks in advance.

    Hi,
    Please try this ...
    DATA: BEGIN OF FILE1,
            CONST1(01) TYPE C VALUE '_',
            FIELD1     LIKE SY-DATUM,
            CONST2(01) TYPE C VALUE '_',
            FIELD2     LIKE SY-UZEIT,
          END OF FILE1.
    DATA: FILENAME LIKE EDI_PATH-PTHNAM.
    MOVE SY-DATUM  TO FILE1-FIELD1.
    MOVE SY-UZEIT  TO FILE1-FIELD2.
    CONCATENATE <table name> FILE1 INTO FILENAME.
    Regards,
    Ferry Lianto

  • Function module in flat file load

    Hi,
    I am loading data using flat file. Followed the steps in how to load using web. In one of the function module there is coding
    CONSTANTS:
       c_memory_id_file_upload TYPE memory_id VALUE 'Z_SEM_BPS_FILE_UPLOAD'
    and
    IMPORT content TO l_content FROM MEMORY ID c_memory_id_file_upload.
    What do these mean ?
    for constant which value we have to give.
    thanks in advance.

    You can give any value for this constant or leave it intact. This is tag for export to memory simply.

  • Function module for Excel file upload

    Hi,
    I am new to APO technical. My requirement is upload excel file data. However commonly used FM in R/3 for uploading excel files from presentation server are not avaliable ( KCD_EXCEL_OLE_TO_INT_CONVERT , ALSM_EXCEL_TO_INTERNAL_TABLE , TEXT_CONVERT_XLS_TO_SAP etc) in APO system(SCM 4.0 version).
    Let me know if there are any other FM avaliable and procedure to upload the excel files in APO?
    Please let me know if you require any further details.
    Regards
    Reddy

    Hi
    The data structures in APO differ from R/3 (e.g. data is held in livecache tables) and hence the FM's you mention will not work in APO.
    Try looking at the Wiki pages as there is a lot of useful information there for you, e.g. this example code to download and upload data between Excel and APO:
    Link: [Download SCM data into Excel|http://wiki.sdn.sap.com/wiki/display/SCM/DownloadPlanningdataintoexcel]
    Have a look around the Wiki, hopefully it will help you out
    Regards
    Ian

  • Function module "GM_DOCUMENT_REVERSE" not found.  after Patch Update

    Hi Abapers/Basis
    After patch update i am not able to do FBCJ reversal entry getting below error message.
    Runtime Errors         CALL_FUNCTION_NOT_FOUND
    Exception              CX_SY_DYN_CALL_ILLEGAL_FUNC
    Date and Time          25.05.2011 14:43:26
    Short text
         Function module "GM_DOCUMENT_REVERSE" not found.
    What happened?
         The function module "GM_DOCUMENT_REVERSE" is called,
         but cannot be found in the library.
         Error in the ABAP Application Program
         The current ABAP program "SAPLRWCL" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_FUNC', was
         not caught in
        procedure "CALL_DISPATCHER_STORNO_R" "(FORM)", nor was it propagated by a
         RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        The program "SAPLRWCL" contains the CALL FUNCTION statement.
        The name of the function module to be called is "GM_DOCUMENT_REVERSE".
        No function module exists with the name "GM_DOCUMENT_REVERSE".
        All function modules are listed in the Function Library (SE37).
        Possible reasons:
        a) Wrong name specified. Pay particular attention to
           upper/lower case and underscores ("_").
           or
        b) Transport error
        c) In the case of an enqueue/dequeue module,
           the lock object may not have been activated
           (ABAP/4 Dictionary).
    How to correct the error
        Check the last transports to the SAP System.
        Is the program "SAPLRWCL" currently being changed?
        If an enqueue/dequeue module is involved, is the activation
        of the lock object missing in the ABAP/4 Dictionary?
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "CALL_FUNCTION_NOT_FOUND" "CX_SY_DYN_CALL_ILLEGAL_FUNC"
        "SAPLRWCL" or "LRWCLF10"
        "CALL_DISPATCHER_STORNO_R"
        Function modules with names similar to "GM_DOCUMENT_REVERSE":
        GM_DOCUMENT_CLOSE
        GM_DOCUMENT_RECORD
        GM_DOCUMENT_DELETE
        GM_DOCUMENT_POST
        GM_DOCUMENT_CHECK
        G_DOCUMENT_RECORD
        GJ_DOCUMENT_RECORD
        GM_DOCUMENT_PROJECT
        GET_DOCUMENTS
        GM_DOCUMENT_DISPLAY
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
       To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
       Display the system log by calling transaction SM21.
       Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
       In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    Moderator message: please don't just dump your dumps, search for SAP notes or open a call with SAP instead.
    Edited by: Thomas Zloch on May 25, 2011 2:16 PM

    Hi Karthik,
    Thank you for ur reply.
    I did not implement any user exit/ badi. Dump is saying that my smarform function module does not exist in the se37 library.
    I have excuted my form through se38, that time is working fine. When i tried through output type it is going to dump.
    Regards,
    Kusuma.

  • Command Error in FTP_COPY function module

    I need to transfer file to non-sap server and I am using function modules FTP_CONNECT and FTP_COPY to do the same. FTP_CONNECT establishes connection to server but FTP_COPY fails with raising exception COMMAND_ERROR (CERROR = 2). We are unable to trace why exactly this exception is raised and what is the root cause for it.
    Has anybody used these function modules to transfer file? Any experience or hints on mentioned error? Any kindly is very much appreciated. Thank you.
    -Abhijit

    Hello,
    Did you use SAPFTP as RFC destination ?
    What you also can do is take a look at the following SAP test programs who use the same function modules (FTP_CONNECT, FTP_COPY, ...):
    RSFTP003                               FTP put / get Test
    RSFTP004                               FTP Copy
    RSFTP006                               FTP command list
    RSFTP007                               Test FB:FTP_SERVER_TO_R3 / FTP_R3_TO_SERVER
    RSFTP009                               Test FTP put with Verify
    RSFTP011                               FTP Copy
    I have always used these programs as a reference for FTP programmation with success.
    Good luck.
    Wim

  • THrough dynpro i am not able to debug backend function module

    Hi,
    In my scenario i am uploading one file through dynpro application and store it at backend(sap r/3). In this scenario first i copy file from ep application server to r/3 application server and then send file dms server where i store that file. I make function module which copy file from ep application server and send it r/3 application server and further it store it dms server.
    I checked with function module it was working fine in backend but when i am call fm in my application it would not work,
    I could not able to debugg it also.
    Please provide if i miss any thing .
    Regards,
    Gurprit Bhatia

    Have you fulfilled following list:
    1. Enbable remote debugging(external breakpoint) on function module
    2. Use same UserID that enables debugging and used in JCo Connection.
    3. Keep open the SAP GUI screen
    4. Run your application, it will take you to SAP GUI screen when breakpoint found.
    Thats all, hope this will help.
    Jawed Ali
    Edited by: Jawed Ali on Aug 27, 2008 10:42 AM

Maybe you are looking for

  • I keep getting a "not delivered" message when I try to send a picture through imessage

    Over the last week each time I sent a picture in iMessage it goes out then I get a "Not Delivered" message. The other person gets the picture even though it says not delivered.  I've shut iMessage off then back on, I've done a hard shutdown/restart. 

  • DVD-Audio Pla

    Hi?I have a XtremeMusic card, with the latest drivers installed (and yes I also have the Digiatla i/o problem after rebbot). The problem is I installed the DVD-Audio player. The player plays but there is no sound, if I use the mouse to move along the

  • K8D master ft onboard video problem

    Hi, I have the k8d master ft and when I install a pci vid card the onboard video is disabled. Does anyone know how or even if it is possible to run both? I could not find anything in bios but maybe I missed it. thanks.

  • Group Messages in Spectrum 2

    I am having an issue with group messages.  When someone sends a group message that I'm part of, I receive it as an individual message even though I have the group function enabled.  Furthermore, I can receive replies from someone else in the group to

  • Urgent help - I've deleted entire site

    Hello - I have two sites and wanted to separate them - I have duplicated domain file three times to be save and deleted one site - could see it had gone but existed on the copy so then deleted the other (my main site) but instead of it deleting on ju