BEGIN OF ts_data,
value_0001 TYPE tv_data,
value_0002 TYPE tv_data,
value_0003 TYPE tv_data,
value_0004 TYPE tv_data,
value_0005 TYPE tv_data,
value_0006 TYPE tv_data,
value_0007 TYPE tv_data,
value_0008 TYPE tv_data,
value_0009 TYPE tv_data,
value_0010 TYPE tv_data,
value_0011 TYPE tv_data,
value_0012 TYPE tv_data,
value_0013 TYPE tv_data,
value_0014 TYPE tv_data,
value_0015 TYPE tv_data,
value_0016 TYPE tv_data,
value_0017 TYPE tv_data,
value_0018 TYPE tv_data,
value_0019 TYPE tv_data,
value_0020 TYPE tv_data,
END OF ts_data,
tt_data TYPE TABLE OF ts_data,
tv_index(4) TYPE n.
CONSTANTS:
co_max_col TYPE i VALUE 20,
co_max_row TYPE i VALUE 9999.
*&---------------------------------------------------------------------*
*& SELECTION-SCREEN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_fname FOR FIELD pa_fname.
PARAMETERS pa_fname TYPE localfile OBLIGATORY LOWER CASE MEMORY ID fnm.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (83) tx_read0.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_read1 FOR FIELD pa_read1.
PARAMETERS pa_read1 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_read2 FOR FIELD pa_read2.
PARAMETERS pa_read2 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_read3 FOR FIELD pa_read3.
PARAMETERS pa_read3 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_read4 FOR FIELD pa_read4.
PARAMETERS pa_read4 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_read5 FOR FIELD pa_read5.
PARAMETERS pa_read5 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) tx_read6 FOR FIELD pa_read6.
PARAMETERS pa_read6 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF LINE.
AT SELECTION-SCREEN OUTPUT.
tx_fname = 'Path and name of Excel to open'.
tx_read0 = 'Function:'.
tx_read1 = 'ALSM_EXCEL_TO_INTERNAL_TABLE'.
tx_read2 = 'FILE_READ_AND_CONVERT_SAP_DATA'.
tx_read3 = 'IMPORT_FROM_SPREADSHEET'.
tx_read4 = 'KCD_EXCEL_OLE_TO_INT_CONVERT'.
tx_read5 = 'TEXT_CONVERT_XLS_TO_SAP'.
tx_read6 = 'UPLOAD_XLS_FILE_2_ITAB'.
*&---------------------------------------------------------------------*
*& Form excel_read1
*&---------------------------------------------------------------------*
FORM excel_read1 CHANGING pt_data TYPE tt_data.
DATA:
lt_excel TYPE STANDARD TABLE OF alsmex_tabline,
ls_excel TYPE alsmex_tabline,
lv_data TYPE tv_data,
lv_error TYPE string.
IF sy-subrc <> 0.
WRITE: / 'SY-SUBRC = ', sy-subrc.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_error.
WRITE: / lv_error.
STOP.
ENDIF.
LOOP AT lt_excel INTO ls_excel.
lv_data = ls_excel-value.
PERFORM itab_insert_value USING ls_excel-col ls_excel-row lv_data
CHANGING pt_data.
ENDLOOP.
ENDFORM. "excel_read1
*&---------------------------------------------------------------------*
*& Form excel_read2
*&---------------------------------------------------------------------*
FORM excel_read2 CHANGING pt_data TYPE tt_data.
DATA:
lv_fname TYPE filename-fileintern,
lv_error TYPE string.
IF sy-subrc <> 0.
WRITE: / 'SY-SUBRC = ', sy-subrc.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_error.
WRITE: / lv_error.
STOP.
ENDIF.
ENDFORM. "excel_read2
*&---------------------------------------------------------------------*
*& Form excel_read3
*&---------------------------------------------------------------------*
FORM excel_read3 CHANGING pt_data TYPE tt_data.
DATA:
lv_url(256) TYPE c,
ls_range TYPE soi_dimension_item,
lt_range TYPE soi_dimension_table,
lt_excel TYPE soi_generic_table,
ls_excel TYPE soi_generic_item,
lv_data TYPE tv_data,
lv_col TYPE tv_index,
lv_row TYPE tv_index.
LOOP AT lt_excel INTO ls_excel.
lv_data = ls_excel-value.
lv_col = ls_excel-column.
lv_row = ls_excel-row.
PERFORM itab_insert_value USING lv_col lv_row lv_data
CHANGING pt_data.
ENDLOOP.
ENDFORM. "excel_read3
*&---------------------------------------------------------------------*
*& Form excel_read4
*&---------------------------------------------------------------------*
FORM excel_read4 CHANGING pt_data TYPE tt_data.
DATA:
lt_excel TYPE kcde_intern,
ls_excel TYPE kcde_intern_struc,
lv_data TYPE tv_data,
lv_error TYPE string.
IF sy-subrc <> 0.
WRITE: / 'SY-SUBRC = ', sy-subrc.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_error.
WRITE: / lv_error.
STOP.
ENDIF.
LOOP AT lt_excel INTO ls_excel.
lv_data = ls_excel-value.
PERFORM itab_insert_value USING ls_excel-col ls_excel-row lv_data
CHANGING pt_data.
ENDLOOP.
ENDFORM. "excel_read4
*&---------------------------------------------------------------------*
*& Form excel_read5
*&---------------------------------------------------------------------*
FORM excel_read5 CHANGING pt_data TYPE tt_data.
DATA:
lt_raw_data(4096) TYPE c OCCURS 0,
lt_data TYPE STANDARD TABLE OF string,
lv_error TYPE string.
IF sy-subrc <> 0.
WRITE: / 'SY-SUBRC = ', sy-subrc.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_error.
WRITE: / lv_error.
STOP.
ENDIF.
ENDFORM. "excel_read5
*&---------------------------------------------------------------------*
*& Form excel_read6
*&---------------------------------------------------------------------*
FORM excel_read6 CHANGING pt_data TYPE tt_data.
IF sy-subrc <> 0.
WRITE: / 'SY-SUBRC = ', sy-subrc.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_error.
WRITE: / lv_error.
STOP.
ENDIF.
ENDFORM. "excel_read6
*&---------------------------------------------------------------------*
*& Form itab_insert_value
*&---------------------------------------------------------------------*
FORM itab_insert_value USING pi_col TYPE tv_index
pi_row TYPE tv_index
pi_value TYPE tv_data
CHANGING pt_data TYPE tt_data.
DATA:
lv_fieldname TYPE string.
FIELD-SYMBOLS:
<fs_data> TYPE ts_data,
<fs_value> TYPE tv_data.
CHECK pi_value <> ''.
WHILE pi_row > lines( pt_data ).
INSERT INITIAL LINE INTO TABLE pt_data.
ENDWHILE.
READ TABLE pt_data ASSIGNING <fs_data> INDEX pi_row.
ASSERT sy-subrc = 0.
CONCATENATE 'VALUE_' pi_col INTO lv_fieldname.
ASSIGN COMPONENT lv_fieldname OF STRUCTURE <fs_data> TO <fs_value>.
ASSERT sy-subrc = 0.
<fs_value> = pi_value.
ENDFORM. "itab_insert_value
*&---------------------------------------------------------------------*
*& Form itab_display
*&---------------------------------------------------------------------*
FORM itab_display USING pt_data TYPE tt_data.
DATA:
ls_data TYPE ts_data,
lv_value TYPE tv_data.
LOOP AT pt_data INTO ls_data.
WRITE / ''. " sy-tabix.
DO co_max_col TIMES VARYING lv_value FROM ls_data-value_0001
NEXT ls_data-value_0002.
WRITE: lv_value(10).
ENDDO.
ENDLOOP.
ENDFORM. "itab_display
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.