首页 > 代码库 > SAP 导入

SAP 导入

SAP的两个比较常用的导入方法 导入后内表结构字段都差不多的

 

REPORT ZJ_TE2.* DATA: 2015/01/05 BY:CHARLES* 描述: 很多事情 不要只了解 还需要去做* 深入 了解 上传 和 下载的设置DATA: BEGIN OF GT_DATA OCCURS 0,  V1(10) TYPE C,  V2(10) TYPE C,  V3(10) TYPE C,  END OF GT_DATA.DATA: LT_ITAB_CONTENT TYPE TABLE OF ALSMEX_TABLINE,      LS_ITAB_CONTENT LIKE LINE OF  LT_ITAB_CONTENT.DATA : L_INTERN TYPE KCDE_CELLS OCCURS 0 WITH HEADER LINE.SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.PARAMETERS: P_FILE LIKE RLGRAP-FILENAME  OBLIGATORY.SELECTION-SCREEN END OF BLOCK B1.AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.  PERFORM GET_FILE1.  "PERFORM GET_FILE2.  "效果一样START-OF-SELECTION.  "PERFORM GET_DATA1.  PERFORM GET_DATA2.    "和上面的效果一样*&---------------------------------------------------------------------**&      Form  get_data*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM GET_DATA1.  CALL FUNCTION ALSM_EXCEL_TO_INTERNAL_TABLE    EXPORTING      FILENAME                = P_FILE      I_BEGIN_COL             = 1        "upload的Excel的起始列      I_BEGIN_ROW             = 1        "upload的Excel的起始行      I_END_COL               = 100      "upload的Excel的终止列      I_END_ROW               = 9999     "最多四位    TABLES      INTERN                  = LT_ITAB_CONTENT    EXCEPTIONS      INCONSISTENT_PARAMETERS = 1      UPLOAD_OLE              = 2      OTHERS                  = 3.ENDFORM.                    "get_data*&---------------------------------------------------------------------**&      Form  get_data2*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM GET_DATA2.  CALL FUNCTION KCD_EXCEL_OLE_TO_INT_CONVERT    EXPORTING      FILENAME    = P_FILE      I_BEGIN_COL = 1      I_BEGIN_ROW = 1      I_END_COL   = 256      I_END_ROW   = 65536    TABLES      INTERN      = L_INTERN.  BREAK-POINT.ENDFORM .                   "get_data2*&---------------------------------------------------------------------**&      Form  file*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM GET_FILE1.  CALL FUNCTION WS_FILENAME_GET    EXPORTING      DEF_FILENAME = *.*      MASK         = ,*.*,*.*.      MODE         = 0      TITLE        = 本地计算机文件    IMPORTING      FILENAME     = P_FILE    EXCEPTIONS      OTHERS       = 8.  IF SY-SUBRC <> 0.    WRITE: / Err : WS_FILENAME_GET.    CLEAR P_FILE.  ENDIF.ENDFORM.                    "file‘*&---------------------------------------------------------------------**&      Form  GET_FILE2*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM GET_FILE2.        data:l_file type String ,        lf_rc type c.    call function F4_FILENAME  "文件选择框    exporting      program_name  = syst-cprog      dynpro_number = syst-dynnr      field_name    = ‘‘    importing      file_name     = P_FILE.   l_file = P_FILE.   call method cl_gui_frontend_services=>file_exist   "判断物理文件是否存在    exporting      file                 = l_file    receiving      result               = lf_rc    exceptions      cntl_error           = 1      error_no_gui         = 2      wrong_parameter      = 3      not_supported_by_gui = 4      others               = 5.  if lf_rc <> X.    " message e000(oo) with ‘The file is not exist‘.    message e000(oo) with 该文件不存在.  endif.      ENDFORM.                    "GET_FILE2

 

SAP 导入