Saturday, March 15, 2014
CL_GUI_FRONTEND_SERVICES=>FILE_EXIST Method to check whether a file exists or not. This method receives as a parameter an address and name of a particular file, and  returns RESULT = 'X' if there is a file else SPACE if there is no file.



REPORT ZTEST_FRONT_END_SERVICES.

data gv_result type abap_bool.
*&----------------------------------------------------*
* Selection-screen
*&----------------------------------------------------*
PARAMETERS: p_file TYPE string.

*&----------------------------------------------------*
* Selection-screen Validation
*&----------------------------------------------------*
AT SELECTION-SCREEN.
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
    EXPORTING
      FILE                 = p_file
    RECEIVING
      RESULT               = gv_result
    EXCEPTIONS
      CNTL_ERROR           = 1
      ERROR_NO_GUI         = 2
      WRONG_PARAMETER      = 3
      NOT_SUPPORTED_BY_GUI = 4
      others               = 5.
  IF SY-SUBRC <> 0.
*   Implement suitable error handling here
  else.
    IF gv_result is INITIAL .
      MESSAGE 'File is not available' TYPE 'E'.
    ENDIF.
  ENDIF.


0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.