`
icfsx
  • 浏览: 21515 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

function to Brows the file and upload

阅读更多

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.

DATA: I_FILE TYPE STRING.

PERFORM FRM_FILE_PATH USING '*.txt,*.*' CHANGING  P_FILE.     "browse the file

PERFORM UPLOAD.     " upload file

 

FORM FRM_FILE_PATH  USING PR_MASK

                CHANGING PR_FILE.

  DATA:L_FILE(128).

  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

    EXPORTING

      FIELD_NAME = 'C:\'

      MASK       = PR_MASK  """'C:\*.xls,*.xls'

    CHANGING

      FILE_NAME  = PR_FILE.

  IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

ENDFORM.                    " FRM_FILE_PATH

form upload .

  I_FILE = P_FILE.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD

    EXPORTING

      FILENAME                = I_FILE

      "FILETYPE                = 'BIN'

      CODEPAGE                = CODEPAGE

    CHANGING

      DATA_TAB                = ITAB3[]

    EXCEPTIONS

      FILE_OPEN_ERROR         = 1

      FILE_READ_ERROR         = 2

      NO_BATCH                = 3

      GUI_REFUSE_FILETRANSFER = 4

      INVALID_TYPE            = 5

      NO_AUTHORITY            = 6

      UNKNOWN_ERROR           = 7

      BAD_DATA_FORMAT         = 8

      HEADER_NOT_ALLOWED      = 9

      SEPARATOR_NOT_ALLOWED   = 10

      HEADER_TOO_LONG         = 11

      UNKNOWN_DP_ERROR        = 12

      ACCESS_DENIED           = 13

      DP_OUT_OF_MEMORY        = 14

      DISK_FULL               = 15

      DP_TIMEOUT              = 16

      NOT_SUPPORTED_BY_GUI    = 17

      ERROR_NO_GUI            = 18

      OTHERS                  = 19.

  IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WRITE :/ '文件导入失败' .

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

ENDFORM.

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics