내부 테이블로 EXCEL 데이터 가져오기

2187 단어
방법은 excel의 데이터를 내표로 가져올 수 있지만, excel 필드와 내표 필드가 일치해야 합니다.
  • 방법1
  • DATA: lt_filename TYPE rlgrap-filename,   
            lt_data TYPE truxs_t_text_data.```
    
    DATA:GT_DATA TYPE STANDARD TABLE OF ZSEXCEL WITH HEADER LINE .
    FIELD-SYMBOLS: .
    
     ``` lt_filename = p_path.   " 
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING```
          ```I_LINE_HEADER              = 'X'
          I_TAB_RAW_DATA             = lt_data
          I_FILENAME                 = lt_filename
        TABLES
          I_TAB_CONVERTED_DATA       = GT_VBRK
        EXCEPTIONS
          CONVERSION_FAILED          = 1
          OTHERS                     = 2
                .```
    ```  IF SY-SUBRC <> 0.
    ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    **         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.```
    
    *  
    ``` DATA: lt_filename TYPE rlgrap-filename ,   " 
       lt_excel TYPE TABLE OF  alsmex_tabline ,
       ls_excel TYPE alsmex_tabline.```
    
    ```lt_filename = p_path.   " ```
    
    ```call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        exporting
          filename                = lt_filename
          i_begin_col             = 1
          i_begin_row             = 2
          i_end_col               = 128
          i_end_row               = 9999
        tables
          intern                  = lt_excel
        exceptions
          inconsistent_parameters = 1
          upload_ole              = 2
          others                  = 3.```
    
    ```sort lt_excel by row col.```
    
    loop at lt_excel into ls_excel.
        case ls_excel-col.
          when 1. " 
            gs_tab-vbeln        = ls_excel-value.```
    *        translate gs_vbak-vbeln to upper case.
          when 2. " 
            gs_tab-POSNR        = ls_excel-value.
     endcase .
    
     at end of row. " gt_tab
        APPEND gs_tab to gt_tab .
        CLEAR gs_tab .
        ENDAT.
    endloop.
    LOOP , , :
     IF lt_excel[] IS INITIAL.
        MESSAGE E361(ZFIN01)."  ' '.
      ENDIF.
    
      LOOP AT lt_excel .                    " 
    
        AT NEW ROW.
          CLEAR GS_TAB.
        ENDAT .
    
        ASSIGN COMPONENT lt_excel-COL OF STRUCTURE  GS_TAB TO ." 
         =  lt_excel-VALUE." 
    
        AT END OF ROW.
          APPEND GS_TAB TO GT_TAB.
        ENDAT.
    
      ENDLOOP.

    좋은 웹페이지 즐겨찾기