Issue WS_FILENAME_GET 上载文件

Issue WS_FILENAME_GET

Issue:  WS_FILENAME_GET is obsolete in the ECC 6.0 Version

WS_FILENAME_GET function module is obsolete, and results in errors on Unicode systems.
Suggest to use FILE_OPEN_DIALOG und FILE_SAVE_DIALOG Unicode-enabled methods of the cl_gui_frontend_services class.
Note:
New applications should restart on these methods instead of the function module. The function module is extended
by a Support Package so that it diverts calls to the methods without the application having to be changed. 
                         

We use CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

  Issue1:

 CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
*     DEF_FILENAME           = ' '
*     DEF_PATH               = ' '
      MASK                   = TEXT-T01         
*     MODE                   = ' '
      TITLE                  = TEXT-T02         
    IMPORTING
      FILENAME               = PR_FPATH         
*     RC                     =
    EXCEPTIONS
      INV_WINSYS             = 1
      NO_BATCH               = 2
      SELECTION_CANCEL       = 3
      SELECTION_ERROR        = 4
      OTHERS                 = 5. 

Solution 1 :
 DATA: WK_TITLE TYPE STRING,
       WK_FILTER TYPE STRING,
       WK_FILE TYPE FILETABLE,
       WK_RC TYPE I.
       WK_TITLE = TEXT-T02.
       WK_FILTER = TEXT-T01.
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    EXPORTING
      WINDOW_TITLE            = WK_TITLE
      FILE_FILTER             = WK_FILTER
    CHANGING
      FILE_TABLE              = WK_FILE
      RC                      = WK_RC
    EXCEPTIONS
      FILE_OPEN_DIALOG_FAILED = 1
      CNTL_ERROR              = 2
      ERROR_NO_GUI            = 3
      NOT_SUPPORTED_BY_GUI    = 4
      OTHERS                  = 5.
   IF NOT WK_FILE[] IS INITIAL.
    READ TABLE WK_FILE INTO PR_FPATH INDEX 1.
  ENDIF.

Issue no:2
*  CALL FUNCTION 'WS_FILENAME_GET'
*    EXPORTING
*      def_filename = 'pancard.txt'
*      def_path = 'd:\'
*      mask = ',*.txt.'
*      mode = 'O'
*      title =
*      'Please specify a file name and path for download/upload.'
*    IMPORTING
*      filename = f_input
**     TITLE = ' '
*    EXCEPTIONS
*         no_batch         = 1
*         selection_cancel = 2
*         OTHERS           = 3.
*
** Display Success/Error Message
*  IF sy-subrc = 0.
*    MESSAGE s000 WITH 'File located Successfully'(001).
*  ELSEIF sy-subrc = 2.
*    MESSAGE s000 WITH 'Get File Cancelled'(002).
*    STOP.
*  ELSE.
*    MESSAGE e000 WITH 'Unable to Select File'(003).
*    STOP.
*  ENDIF.

   LV_TITLE = 'Please specify file name and path for download/upload.'.
   LV_FILE_FILTER = '.TXT|.TXT'.
   LV_FILENAME = 'pancard.txt'.

   CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
      EXPORTING
        WINDOW_TITLE            = LV_TITLE
*       DEFAULT_EXTENSION       =
        DEFAULT_FILENAME        = LV_FILENAME
        FILE_FILTER             = LV_FILE_FILTER
*       WITH_ENCODING           =
        INITIAL_DIRECTORY       = 'd:\'
*       MULTISELECTION          =
      CHANGING
        FILE_TABLE              = LI_FILETABLE
        RC                      = LV_RC
        USER_ACTION             = LV_USERAction
*       FILE_ENCODING           =
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        NOT_SUPPORTED_BY_GUI    = 4
        others                  = 5.

  IF LI_FILETABLE IS NOT INITIAL.
    READ TABLE LI_FILETABLE INTO f_input INDEX 1.
  ENDIF.

* Display Success/Error Message
  IF sy-subrc = 0.
    MESSAGE s000 WITH 'File located Successfully'(001).
   ELSE.
    MESSAGE e000 WITH 'Unable to Select File'(003).
    STOP.
  ENDIF.
  IF LV_USERACTION = 9.
    MESSAGE s000 WITH 'Get File Cancelled'(002).
    STOP.
  ENDIF.

 
posted @ 2012-06-28 17:25  VerySky  阅读(1796)  评论(0)    收藏  举报