Scan application server directory to read a file by pattern

Hi Experts,er
I am trying to search for a file which is on application server
File Name: payroll_1000_date_timestamp
Since i will not know the timestamp on the file i will have to search the file in the folder like this: payroll_1000_date_*
I have tried almost all below techniques but none of them work in background mode:
1.F.M EPS2_GET_DIRECTORY_LISTING
2.EPS_GET_DIRECTORY_LISTING
3.Perform  DIRECTORY_CONTENTS_GET from F.M /SAPDMC/LSM_F4_SERVER_FILE
Would appreciate if someone can highlight on a way i can do this search.
Is there any function module or any utility which can run in background and give me all files present on app. server ? I can than filter it down
later.
Would appreciate your help.
Thanks
Bhanu

Hi Bhanu,
did you try the following??
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
  EXPORTING
dir_name = gv_folder "'\usr\sap\ECD\SYS\global\chase\inbound'
file_mask = 'payroll_1000_date_*'
  TABLES
dir_list = lt_dir_list
  EXCEPTIONS
invalid_eps_subdir     = 1
sapgparam_failed       = 2
    build_directory_failed = 3
no_authorization       = 4
    read_directory_failed  = 5
    too_many_read_errors   = 6
    empty_directory_list   = 7
OTHERS = 8.
IF sy-subrc = 0.

Similar Messages

  • Read application server directory and file

    Hi,
      I'm using the FM "RZL_READ_DIR_LOCAL" to retrieve the application server directory and filename.  The returned result contain all the directory name and filename.  Is there any other FM can separate the result into directory and file??
    Regards,
    Kit

    hi
    Ya One more FM is there - Call Function Gui Upload.
    It will read the file from the app server.
    See this Example:-
    Refer this:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
    *& Report  ZUPLOADTAB                                                  *                     &----
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    DATA: ld_file LIKE rlgrap-filename.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 like pa0002-VORNA,
        name2 like pa0002-name2,
        age   type i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Text version of data table
    TYPES: begin of t_uploadtxt,
      name1(10) type c,
      name2(15) type c,
      age(5)  type c,
    end of t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) type c.
    constants: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *START-OF-SELECTION
    START-OF-SELECTION.
    ld_file = p_infile.
    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    ELSE.
      DO.
        CLEAR: wa_string, wa_uploadtxt.
        READ DATASET ld_file INTO wa_string.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
                                          wa_uploadtxt-name2
                                          wa_uploadtxt-age.
          MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
          APPEND wa_upload TO it_record.
        ENDIF.
      ENDDO.
      CLOSE DATASET ld_file.
    ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    Display report data for illustration purposes
      loop at it_record into wa_record.
        write:/     sy-vline,
               (10) wa_record-name1, sy-vline,
               (10) wa_record-name2, sy-vline,
               (10) wa_record-age, sy-vline.
      endloop.
    reward if help.

  • Download all files from a specific application server directory to Local pc

    Hi Experts,
    I have a requirement of downloading all the files from an application server directory to a local pc.
    I know how to download a single file from an application server at a time provided the file name is known.
    But my requirement is to download all the files in that particulary directory, because I dont know how many files were created in that directory and what are their names.
    Please kindly provide the solution.
    Thanks,
    Kalikonda.

    Nelson,
    Here is the function module that I have used to get all the application server files.
    appl_dir_name is the path of the directory  i.e. '/outbound/PD1/Applnserverfiles/'
    it_appl_srv_fls is the internal table where all the files gets stored in.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
       EXPORTING
         dir_name                     = appl_dir_name
      FILE_MASK                    = ' '
    IMPORTING
      DIR_NAME                     =
      FILE_COUNTER                 =
      ERROR_COUNTER                =
       TABLES
         dir_list                     = it_appl_srv_fls
    EXCEPTIONS
      invalid_eps_subdir           = 1
      sapgparam_failed             = 2
      build_directory_failed       = 3
      no_authorization             = 4
      read_directory_failed        = 5
      too_many_read_errors         = 6
      empty_directory_list         = 7
      OTHERS                       = 8
      IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    hope this solves your problem.
    Thanks,
    kalikonda.

  • File exist in application server directory

    Hi there,
    On my SAP server, i have a directory created specifically to store input files generated from other external systems.
    From my ABAP program, i need to check if any file exist on that application server directory. If yes, then i will proceed to read the input file and process it.
    If it's empty, then output message that file is not available.
    Are there any FM to do this?

    you can use this code to do this...
    Upload data from file
      DATA: lv_filename  TYPE string, "File name
            lv_line      TYPE string. "One line entry in a file
      lv_filename = iv_file_name.
      IF iv_location = gc_application.
        IF iv_record_count IS SUPPLIED.
      Open file
          IF gv_file IS INITIAL.
            OPEN DATASET lv_filename FOR INPUT IN TEXT MODE
                                     ENCODING DEFAULT
                                     IGNORING CONVERSION ERRORS.
            IF sy-subrc <> 0.
              RAISE file_open_error.
            ENDIF.
            gv_file = gc_check.
          ENDIF.
      Read data
          DO iv_record_count TIMES.
            READ DATASET lv_filename INTO lv_line.
            IF sy-subrc <> 0.
      Close file
              CLOSE DATASET lv_filename.
              IF sy-subrc NE 0.
                RAISE file_close_error.
              ENDIF.
              CLEAR gv_file.
    Exit from the loop
              EXIT.
            ENDIF.
            IF iv_separator IS NOT INITIAL.
              CALL FUNCTION 'Z_WM_SPLIT_DATA'
                EXPORTING
                  iv_data      = lv_line
                  iv_separator = iv_separator
                CHANGING
                  ct_tab_data  = ct_tab_data.
            ELSE.
              CHECK NOT lv_line IS INITIAL.
              APPEND lv_line TO ct_tab_data .
            ENDIF.
          ENDDO.
        ELSE.
      Open file
          OPEN DATASET lv_filename FOR INPUT IN TEXT MODE
                                   ENCODING DEFAULT
                                   IGNORING CONVERSION ERRORS.
          IF sy-subrc <> 0.
            RAISE file_open_error.
          ENDIF.
      Read data
          DO.
            READ DATASET lv_filename INTO lv_line.
            IF sy-subrc <> 0.
              EXIT.
            ENDIF.
            IF iv_separator IS NOT INITIAL.
              CALL FUNCTION 'Z_WM_SPLIT_DATA'
                EXPORTING
                  iv_data      = lv_line
                  iv_separator = iv_separator
                CHANGING
                  ct_tab_data  = ct_tab_data.
            ELSE.
              CHECK NOT lv_line IS INITIAL.
              APPEND lv_line TO ct_tab_data .
            ENDIF.
          ENDDO.
      Close file
          CLOSE DATASET lv_filename.
          IF sy-subrc NE 0.
            RAISE file_close_error.
          ENDIF.
        ENDIF.

  • Application Server Directory file attributes lists

    Hi,
    I'm searching for Funtion Module or Method to get Application Server Directory file lists with all attributes.
    1) FM 'SUBST_GET_FILE_LIST' is not getting midifued date and time.
    2) Method CL_GUI_FRONTEND_SERVICES-DIRECTORY_LIST_FILES is getting local directory files.
    I'm looking for standard way to get all attributes whatever we are seeing in AL11 transaction like Name, Length, Creator and last changed date and time stamp-
    ...Nandha

    Hi
    The fm SUBST_GET_FILE_LIST is right but you need to convert the date and time by your self, u can use this routine:
    PERFORM P6_TO_DATE_TIME_TZ(RSTR0400) USING FILE_LIST-MTIME
                                                     FILE_LIST-MOD_TIME
                                                     FILE_LIST-MOD_DATE.
    Max

  • How to know the first placed file in Application server directory

    Hi All ,
    i want to Know the First plased file in a application server directory . i have tried with
    FM EPS_GET_FILE_ATTRIBUTES but it is giving the file size. Can anybody  give some idea to get the file lastmodify property.
    Thanks & Regards
    Prithvi.

    Hi Prithvi!
    Use the methods of class CL_GUI_FRONTEND_SERVICES (if your release is at least 620, sorry otherwise).
    Method DIRECTORY_LIST_FILES will give you all files of a directory, then you can check with method FILE_GET_ATTRIBUTES for some date info.
    But maybe you can agree about a timestamp in the filename - this has to be set by the sender, but is much easier and reliable, too.
    Regards,
    Christian

  • When I open iPhoto 9.2.1 it says that my library needs to be upgraded but when I upgrade the library I am trying to open (33 GB worth of pictures from 2006) the new application says it cannot read the files and how to find them on the system to reimport?!

    When I open iPhoto 9.2.1 it says that my library needs to be upgraded but when I upgrade the library I am trying to open (33 GB worth of pictures from 2006) the new application says it cannot read the files and how to find them on the system to reimport?! and then I'd like to erase the original files since the space requirement is huge!!!! Why is upgrading software iPhoto such a pain. I've gotta get a presentation done and all I get for my money is roadblock!!!

    hello, it sounds like the library is damaged.
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. 

  • Help!! - "The HP Scan Application was unable to save the file to the specified location."

    New OJ6830, latest HP software installed on Win7 64 bit.
    HP Scan scans and displays the scanned pages.  But, when I try to save the file as a pdf or tiff, I get the following error message:
    "The HP Scan Application was unable to save the file to the specified location."
    BTW, I have tried running the app as Administrator and have disabled my antivirus software.
    Why won't the HP scan app save the file?  Has anyone else seen this error message?
    Is there anything else I can do, or this this just a major bug in HP scan software?

    Mike,
    One Idea:
    Make sure you have "San Preview" checked else the software will not accept "specified location".
    Reference:
    Save Scan to Specified Location
    Click the Kudos Thumbs-Up to say Thank You!
    And...Click Accept as Solution when my Answer provides a Fix or Workaround!
    I am pleased to provide assistance on behalf of HP. I do not work for HP. 
    Kind Regards,
    Dragon-Fur

  • How to check if the file already exists in the application server directory

    Hi all. I'm on devsuite 10g.
    I transfer file from local machine to application server using webutil function webutil_file_transfer.client_to_as and I want to check if the file I'm transfering already exists on the server directory.
    How can I make this?
    Thanks all,
    Fabrizio

    use the text_io package and open the file in read-mode.
    like this
    declare
    xFileType text_io.file_type;
    begin
    xFileType := text_io.fopen('c:\temp\test.txt','R'); --file on the middle tier
    -- file exists;
    text_io.fclose(xFileType);
    exception
    when others then
    --file doesn't exist
    end;
    regards
    Christian

  • How to check whether the Application Server directory exits or not

    Hi,
    I have a selection screen in which I give the Application server file name(UNIX file) as input. Here, I would like to check whether the Server directory exists or not.
    Let us say, the path I gave in the selection screen is /usr/sap/tmp/testfile.txt . Here, the file name is testfile.txt and the server directory is /usr/sap/tmp . I would like to check whether this directory /usr/sap/tmp exists in the server or not. I am not bothered about the file name as I am going to write data into the file. I am mainly concerned about whether the directory exists in the server or not. and one more thing... this is the Application Server path not the Local path.
    Can anyone help me on the same how to check whether the server directory exists or not.
    Thanks in advance.
    Best Regards,
    Pradeep.

    Also you can use the FM EPS_GET_DIRECTORY_LISTING for this purpose.
      Store the directory name
        l_dpath = p_file+0(l_no).
      Validate the directory of the application server
        CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
          EXPORTING
            dir_name               = l_dpath
          TABLES
            dir_list               = l_i_dlist
          EXCEPTIONS
            invalid_eps_subdir     = 1
            sapgparam_failed       = 2
            build_directory_failed = 3
            no_authorization       = 4
            read_directory_failed  = 5
            too_many_read_errors   = 6
            empty_directory_list   = 7
            OTHERS                 = 8.
      If any problem occurs with the directory then display proper
      error message
        IF sy-subrc <> 0.
        Display error message
          MESSAGE e018 WITH 'Problem with directory entered'(008).
        ENDIF. " sy-subrc <> 0
    Regards,
    Joy.

  • Application Server Download - Tab Delimited Text File

    Hi,
    I am trying to create a tab delimited text file in application server. Is there any option should i use with the Open Dataset / Transfer statements? My requirement is to download the file (Text - Tab Delimited) into Excel for further analysis. Can you please suggest me a suitable solution for this?
    Thanks,
    Kannan.

    Hi,
    You can use transactions CG3Y and CG3Z. Its very simple.
    Refer sample code:
    constants: c_split TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
    c_path TYPE VALUE char100 '/local/data/interface/A28/DM/OUT'.
    *& Form f1001_browse_appl_file
    Pick up the file path for the file in the application server
    FORM f1001_browse_appl_file .
    DATA: lcl_directory TYPE char128.
    lcl_directory = p_direct.
    CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
    EXPORTING
    directory = lcl_directory
    filemask = c_mask
    IMPORTING
    serverfile = p_f2
    EXCEPTIONS
    canceled_by_user = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE s000 WITH text-039.
    EXIT.
    ENDIF.
    ENDFORM. " f1001_browse_appl_file
    *& Form f1004_app_file
    upload the file from the application server
    FORM f1004_app_file .
    REFRESH: i_input.
    OPEN DATASET p_f2 IN TEXT MODE ENCODING DEFAULT FOR INPUT.
    IF sy-subrc EQ 0.
    DO.
    READ DATASET p_f2 INTO wa_input_rec.
    IF sy-subrc 0.
    MESSAGE s000 WITH text-030.
    EXIT.
    ENDIF.
    o
    + Split The CSV record into Work Area
    PERFORM f0025_record_split.
    o
    + Populate internal table.
    APPEND wa_input TO i_input.
    CLEAR wa_input.
    ENDDO.
    ENDIF.
    ENDFORM. " f1004_app_file
    *& Form f0025_record_split
    Move the assembly layer file into the work area
    FORM f0025_record_split .
    CLEAR wa_input.
    SPLIT wa_input_rec AT c_split INTO
    wa_input-legacykey
    wa_input-profile_role
    wa_input-read_date.
    ENDFORM. " f0025_record_split
    DO your manipulation with the data records here.
    Popualte data into final internal table and write it back to application server at the desired path.
    *& Form f0020_write_application
    Write error log to application Server
    FORM f0020_write_application .
    IF p_f1 IS NOT INITIAL.
    CONCATENATE p_direct p_obj sy-datum text-037 INTO p_f2.
    ELSEIF p_f2 IS NOT INITIAL.
    REPLACE text-036 IN p_f2 WITH text-037.
    ENDIF.
    OPEN DATASET p_f2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc 0.
    EXIT.
    ENDIF.
    LOOP AT i_error INTO wa_error.
    TRANSFER wa_error TO p_f2.
    IF sy-subrc 0.
    EXIT.
    ENDIF.
    CLEAR wa_error.
    ENDLOOP.
    CLOSE DATASET p_f2.
    ENDFORM. " f0020_write_application
    HTH,
    Regards,
    Dhruv Shah

  • Application server directory space

    Hi All,
    Request to confirm the function module / class / coding required to determine the currently available space
    in a directory on the application server.
    Regards
    Kunal

    Hi Arindam,
    Thanks for your response.
    I believe you have understood our req. correctly.
    For an SAP directory , used space = ?, total space = ?
    The External command 'ls' only returns the file names in a directory.
    I am not sure on implementing the df-k suggested by you.
    Is it a separate command or do i have to use it like this
    'df -k' in a new command ? Did try this formation but could not get it to work.
    Returns  an error
    'Can't exec external program (No such file or directory)                                                                                                                                                                                                        External program terminated with exit code 1
    Appreciate your help on this issue.
    Regards
    Kunal

  • OPEN DATA SET to write files in application server folder - some of the files are missing

    Hi,
    I'm using OPEN DATASET statement in batch job to write the files in application server. what i'm experiencing is when i schedule the batch job all the files are not writing into the folder.
    If i run the report again to write the missed files, the files are writing into the application server folder.
    after opening the dataset, i'm closing it. do we need to give any delay between creation of the files? or until the first write operation is done, 2nd one can't start ..how can we achieve this.
    Thanks for your help in advance.
    Thanks,
    Adi.

    Hello Bathineni,
    Are you using the sy-subrc check after the OPEN DATASET statement.
    If not use a sy-subrc check and transfer the contents to file only when the OPEN DATASET returns value sy-subrc = 0.
    if sy-subrc is 8 repeat the same loop say for 3 attempts until the OPEN DATASET becomes 0.
    DO 3 TIMES. <---- put any number of attempts as you need
    OPEN DATASET.
    IF sy-subrc = 0.
       TRANSFER contents to file.
       EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET.
    Regards,
    Thanga

  • SUN application server does not read from Derby database

    Hello,
    I have developed a simple web application in SUN Java Studio Creator 2, and deployed it to the SUN App server 8. It uses a database (PointBase) for some table lookups. It all works OK on my development system. When I try and run the same web application on Production (Sun Java System Application Server Platform Edition 9.0 (build b48)) , with the Derby database, I cannot get it to work. The application looks OK, all web pages get displayed correctly, but none of the fields and tables show any data from the database tables.
    The "ping" command from the admin screen in the app server to the Derby connection pool is successful, and there are no error messages in any logs, it is just that the data from the tables does not get displayed on the web pages. Very strange.
    At first I thought it was a database issue, so I ported the database to mySQL, but the problem was not fixed. In development the web application works OK, but on production the data in the tables do not get displayed.
    Anyone has any ideas?
    Thanks!!

    Are you able to access the data in the tables using standalone java client. ( java program through JDBC api )
    Can you post the code snippet of getting connection ( URL, other db parameters)

  • Twonkey media server unable to read mp4 files created by new version of Leawo Blu Ray Ripper

    For the past week I have been ripping DVDs with a new version (v7.3.0.3) of Leawo Blu Ray Ripper.  The Twonkey media server (v7.2.9-1) on my WD4100DL will not read the newer files compared to movies ripped with the old version (v7.2.1.4).  My Roku media server does just fine.  Is there an upgrade of the Twonkey media server available?
    Thanks for any advice.

    I think that Leawo has helped me to solve the problem.  The MP4 files that I made using the old version of Blu-Ray Ripper apparently defaulted to H.264 video codec for MP4 files.  Twonky is able to read those files. The new version (7.3.0.3) of Leawo Blu-Ray Ripper defaulted to MPEG4 video codec.  Twonkey cannot read those MP4 files.  I have changed the video codec to H.264 in Blu-Ray Ripper and I am in the process of ripping a DVD now.  I will post the result.

Maybe you are looking for