Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
- EXPORTING
- filename = lv_file
- i_begin_col = lv_start_col
- i_begin_row = lv_start_row
- i_end_col = lv_end_col
- i_end_row = lv_end_row
- TABLES
- intern = lt_table
- EXCEPTIONS
- inconsistent_parameters = 1
- upload_ole = 2
- OTHERS = 3.
- IF sy-subrc <> 0.
- MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
- WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- ENDIF.
- *&--format data
- CREATE DATA ls_xls LIKE LINE OF gt_excel.
- ASSIGN ls_xls->* TO <fs_line>.
- ASSIGN COMPONENT 'MANDT' OF STRUCTURE <fs_line> TO <fs_any>.
- IF sy-subrc = 0.
- lv_offset = 1.
- ENDIF.
- *&--check where data is to be splitted
- IF NOT lv_conv_exits IS INITIAL.
- SPLIT lv_conv_exits AT ',' INTO TABLE lt_convs.
- ENDIF.
- *&--convert the data into proper format
- lv_conc_lines = lines( lt_convs ).
- LOOP AT lt_table ASSIGNING <fs_table>.
- lv_col = <fs_table>-col + lv_offset.
- ASSIGN COMPONENT lv_col OF STRUCTURE <fs_line> TO <fs_any>.
- IF sy-subrc = 0.
- IF lv_conc_lines >= <fs_table>-col.
- CLEAR lv_conv_name.
- READ TABLE lt_convs INDEX <fs_table>-col INTO lv_conv_name.
- IF NOT lv_conv_name IS INITIAL.
- CONCATENATE 'CONVERSION_EXIT_' lv_conv_name '_INPUT' INTO lv_conv_name.
- CALL FUNCTION lv_conv_name
- EXPORTING
- input = <fs_table>-value
- IMPORTING
- output = <fs_any>.
- ELSE.
- <fs_any> = <fs_table>-value.
- ENDIF.
- ELSE.
- <fs_any> = <fs_table>-value.
- ENDIF.
- ENDIF.
- AT END OF row.
- INSERT <fs_line> INTO TABLE gt_excel.
- CLEAR <fs_line>.
- ENDAT.
- ENDLOOP.
- CATCH cx_root INTO lo_err.
- MESSAGE lo_err TYPE 'E'.
- ENDTRY.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement