Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.24 KB | None | 0 0
  1.         CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  2.           EXPORTING
  3.             filename                = lv_file
  4.             i_begin_col             = lv_start_col
  5.             i_begin_row             = lv_start_row
  6.             i_end_col               = lv_end_col
  7.             i_end_row               = lv_end_row
  8.           TABLES
  9.             intern                  = lt_table
  10.           EXCEPTIONS
  11.             inconsistent_parameters = 1
  12.             upload_ole              = 2
  13.             OTHERS                  = 3.
  14.  
  15.         IF sy-subrc <> 0.
  16.           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  17.             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  18.         ENDIF.
  19. *&--format data
  20.         CREATE DATA ls_xls LIKE LINE OF gt_excel.
  21.         ASSIGN ls_xls->* TO <fs_line>.
  22.  
  23.         ASSIGN COMPONENT 'MANDT' OF STRUCTURE <fs_line> TO <fs_any>.
  24.         IF sy-subrc = 0.
  25.           lv_offset = 1.
  26.         ENDIF.
  27. *&--check where data is to be splitted
  28.         IF NOT lv_conv_exits IS INITIAL.
  29.           SPLIT lv_conv_exits AT ',' INTO TABLE lt_convs.
  30.         ENDIF.
  31. *&--convert the data into proper format
  32.         lv_conc_lines = lines( lt_convs ).
  33.  
  34.         LOOP AT lt_table ASSIGNING <fs_table>.
  35.           lv_col = <fs_table>-col + lv_offset.
  36.           ASSIGN COMPONENT lv_col OF STRUCTURE <fs_line> TO <fs_any>.
  37.  
  38.           IF sy-subrc = 0.
  39.             IF lv_conc_lines >= <fs_table>-col.
  40.               CLEAR lv_conv_name.
  41.  
  42.               READ TABLE lt_convs INDEX <fs_table>-col INTO lv_conv_name.
  43.  
  44.               IF NOT lv_conv_name IS INITIAL.
  45.                 CONCATENATE  'CONVERSION_EXIT_' lv_conv_name '_INPUT' INTO lv_conv_name.
  46.                 CALL FUNCTION lv_conv_name
  47.                   EXPORTING
  48.                     input  = <fs_table>-value
  49.                   IMPORTING
  50.                     output = <fs_any>.
  51.               ELSE.
  52.                 <fs_any> = <fs_table>-value.
  53.               ENDIF.
  54.  
  55.             ELSE.
  56.               <fs_any> = <fs_table>-value.
  57.             ENDIF.
  58.           ENDIF.
  59.  
  60.           AT END OF row.
  61.             INSERT <fs_line> INTO TABLE gt_excel.
  62.             CLEAR <fs_line>.
  63.           ENDAT.
  64.         ENDLOOP.
  65.  
  66.       CATCH cx_root INTO lo_err.
  67.         MESSAGE lo_err TYPE 'E'.
  68.     ENDTRY.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement