Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How upload .xlsx file dependig on table

0 Kudos

I have a few .xlsx files. Each of one has the same strucure like table to uploading. For example sflisgt.xlsx -> SFLIGHT, carriers.xlsx -> CARRIERS. First I have form get_file and then upload_data like below. But it looks terrible. Now I have two radiobuttons (rb_x1, rb_x2), but if I will need 10?. How I can declareting standard table dependind which radiobuttons is checked and then one time CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'


FORM upload_data.

DATA: lt_raw TYPE truxs_t_text_data.

CASE abap_true.
WHEN rb_x1.
DATA lt_output_1 TYPE STANDARD TABLE OF sflight.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = abap_true
i_tab_raw_data = lt_raw
i_filename = p_file
TABLES
i_tab_converted_data = lt_output_1
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.

MODIFY sflight FROM TABLE lt_output_1.

WHEN rb_x2.
DATA lt_output_2 TYPE STANDARD TABLE OF carriers.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* i_field_seperator = ";"
i_line_header = abap_true
i_tab_raw_data = lt_raw
i_filename = p_file
* I_STEP = 1
TABLES
i_tab_converted_data = lt_output_2
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.
MODIFY carriers FROM TABLE lt_output_2.

ENDCASE.
ENDFORM.

0 REPLIES 0