zoukankan      html  css  js  c++  java
  • SAP 文件操作类 CL_GUI_FRONTEND_SERVICES

    1 、文件下载。

    DATA: l_filename   TYPE string,        "file name
            l_path       TYPE string,        "file path
            l_fullpath   TYPE string,        "full path
            l_useraction TYPE i,             "user action
            l_encoding   TYPE abap_encoding. "endocding
    
    
      " get file to save as
      cl_gui_frontend_services=>file_save_dialog(
         EXPORTING
           default_extension    = gco_dot_txt
           default_file_name    = gco_def_namt
           with_encoding        = abap_true
           file_filter          = cl_gui_frontend_services=>filetype_text
        CHANGING
          filename             = l_filename
          path                 = l_path
          fullpath             = l_fullpath
          user_action          = l_useraction
          file_encoding        = l_encoding
         EXCEPTIONS
           cntl_error           = 1
           error_no_gui         = 2
           not_supported_by_gui = 3
           OTHERS               = 4
             ).
      IF sy-subrc IS INITIAL.
        CASE l_useraction.
          WHEN cl_gui_frontend_services=>action_cancel.
            CLEAR l_fullpath.
            MESSAGE i001(00) WITH text-010.
          WHEN cl_gui_frontend_services=>action_ok OR
               cl_gui_frontend_services=>action_replace.
            cl_gui_frontend_services=>gui_download(
              EXPORTING
                filename                  = l_fullpath
                append                    = space
                write_field_separator     = space
                trunc_trailing_blanks     = gco_true
                confirm_overwrite         = space
                no_auth_check             = gco_true
                codepage                  = l_encoding
              CHANGING
                data_tab                  = git_etab
              EXCEPTIONS
                file_write_error          = 1
                no_batch                  = 2
                gui_refuse_filetransfer   = 3
                invalid_type              = 4
                no_authority              = 5
                unknown_error             = 6
                header_not_allowed        = 7
                separator_not_allowed     = 8
                filesize_not_allowed      = 9
                header_too_long           = 10
                dp_error_create           = 11
                dp_error_send             = 12
                dp_error_write            = 13
                unknown_dp_error          = 14
                access_denied             = 15
                dp_out_of_memory          = 16
                disk_full                 = 17
                dp_timeout                = 18
                file_not_found            = 19
                dataprovider_exception    = 20
                control_flush_error       = 21
                not_supported_by_gui      = 22
                error_no_gui              = 23
                OTHERS                    = 24
                   ).
            IF NOT sy-subrc IS INITIAL.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
              CLEAR l_fullpath.
            ENDIF.
          WHEN cl_gui_frontend_services=>action_append.
            " no header required
          WHEN OTHERS.
            CLEAR l_fullpath.
        ENDCASE.
      ENDIF.
    
      CONCATENATE p_path g_seqno gco_bpt INTO g_path.
      cl_gui_frontend_services=>gui_download(
      EXPORTING
        filename     = g_path
    *    bin_filesize = lv_binary_leng
        filetype     = gco_bin
      CHANGING
        data_tab     = git_etab
      EXCEPTIONS
        OTHERS   = 1
    ).
      IF sy-subrc <> 0..
    
      ENDIF.
  • 相关阅读:
    树莓派配置
    《C#微信开发系列(Top)-微信开发完整学习路线》
    Git基础使用教程(仓库初始化,源码clone,源码push)
    《Cron表达式详解》
    《CSS实现单行、多行文本溢出显示省略号》
    《C#多线程编程实现方式》
    《SQLServer删除重复数据的方法》
    《java提高数据导入效率优化思路》
    《如何使用Javascript判断浏览器终端设备》
    《动手实现一个网页加载进度loading》
  • 原文地址:https://www.cnblogs.com/JackeyLove/p/13070692.html
Copyright © 2011-2022 走看看