Example 1:

  DATA: w_file  LIKE rlgrap-filename.
  MOVE  p_file TO w_file.
  REFRESH: iexcel, inolist.
  CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
    EXPORTING
      filename                = w_file
      i_begin_col             = 1
      i_begin_row             = 1
      i_end_col               = 2
      i_end_row               = 100
    TABLES
      intern                  = iexcel
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.

  IF sy-subrc <> 0.
    WRITE: / 'EXCEL UPLOAD FAILED ', p_file, sy-subrc.
  ELSE.
    SORT iexcel BY row col.
    LOOP AT iexcel.
      CASE iexcel-col.
        WHEN 1.
          inolist-lgnum       = iexcel-value.
        WHEN 2.
          inolist-lgtyp       = iexcel-value.
      ENDCASE.

      AT END OF row.
        IF inolist-lgnum <> space.
          APPEND inolist.
        ENDIF.
        CLEAR inolist.
      ENDAT.
    ENDLOOP.
  ENDIF.

 

Example 2:

  DATA: iexcel  TYPE kcde_cells OCCURS 0 WITH HEADER LINE.

  CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'    "GOOD
     EXPORTING
       filename                = p_upld
       i_begin_col             = 1
       i_begin_row             = 1
       i_end_col               = 9
       i_end_row               = 30000
     TABLES
       intern                  = iexcel
     EXCEPTIONS
       inconsistent_parameters = 1
       upload_ole              = 2
       OTHERS                  = 3.

  IF sy-subrc <> 0.
    WRITE: / 'EXCEL UPLOAD FAILED ', p_upld, sy-subrc.
  ELSE.
    SORT iexcel BY row col.
    LOOP AT iexcel.
*      IF c_header = 'X' AND iexcel-row = 1. "Excel 有表頭則忽略之
*        CONTINUE.
*      ENDIF.
      CASE iexcel-col.
        WHEN 1.
          i_upld-matnr      = iexcel-value.
        WHEN 2.
          i_upld-werks      = iexcel-value.
        WHEN 3.
          i_upld-vdatu      = iexcel-value.
        WHEN 4.
          i_upld-bdatu      = iexcel-value.
        WHEN 5.
          i_upld-lifnr      = iexcel-value.
        WHEN 6.
          i_upld-ekorg      = iexcel-value.
        WHEN 7.
          i_upld-meins      = iexcel-value.
        WHEN 8.
          i_upld-feskz      = iexcel-value.  "Fix Vendor
        WHEN 9.
          i_upld-autet      = iexcel-value.  "MRP
      ENDCASE.
      AT END OF row.
        APPEND i_upld. CLEAR i_upld.
      ENDAT.
    ENDLOOP.
  ENDIF.

arrow
arrow
    創作者介紹
    創作者 Benson 的頭像
    Benson

    runman1999

    Benson 發表在 痞客邦 留言(0) 人氣()