Skip to Content
author's profile photo Former Member
Former Member

Download file from local drive.

Hi all,

I need to write a program to check on C:\ directory for a specific file.

Let's say C:\Test\Abc.txt, if Abc.txt exist in C:\Test directory, it will performs GRAB function to get the content of the file.

The abap program needs to trigger and trigger until it grabs something from the Abc.txt file.

If it is empty, perform the GRAB function again and again.

Is this possible?

Would be greatly appreciated if someone provide some sample codes.

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2008 at 07:38 AM

    Dear Abap experts,

    Any inputs for above question?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi all,

      I have a solution here for the above matter.

      I need someone to help to improve the code to make it better.

      Or any limitations here?

      In the program I can set the max interval time for detecting the file exist in the

      specific directory. Once it is detected, it will exit. If not it will continue detecting up to max 60 seconds.

      *&---------------------------------------------------------------------*
      *& Report  ZTESTWONG_FILE_EXIST
      *&
      *&---------------------------------------------------------------------*
      *&
      *&
      *&---------------------------------------------------------------------*
      
      REPORT  ZTESTWONG_FILE_EXIST.
      type-pools: ABAP.
      
      DO 60 times.
        WAIT up to '1' seconds.
      
        data: fname type string value 'C:\TEST\ABC.TXT',
              result type ABAP_BOOL,
              flag.
      
        CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
          EXPORTING
            FILE                 = fname
          RECEIVING
            RESULT               = result
          EXCEPTIONS
            CNTL_ERROR           = 1
            ERROR_NO_GUI         = 2
            WRONG_PARAMETER      = 3
            NOT_SUPPORTED_BY_GUI = 4
            others               = 5.
      
        IF SY-SUBRC eq 0 and result = 'X'.
      *   File Exists
          WRITE: / 'File Exist.'.
          EXIT.
        ELSE.
      *   File does not exist
          IF flag = ''.
            WRITE: / 'File Not Exist.'.
            flag = 'X'.
          ENDIF.
        ENDIF.
      ENDDO.
      

      Thanks in advance.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.