REPORT ZMFA_EXCEL LINE-SIZE 255.
DATA: IT_RAW TYPE TRUXS_T_TEXT_DATA.
DATA: BEGIN OF GT_ITAB OCCURS 0 ,
MATNR TYPE ETYP-MATNR,
SERNR TYPE RISA0-SERNR,
EQTYP TYPE RM63E-EQTYP,
BAUJJ TYPE EDEVICED-BAUJJ,
BGLJAHR TYPE EDEVICED-BGLJAHR,
HERST TYPE EDEVICED-HERST,
TYPBZ TYPE EDEVICED-TYPBZ,
BESITZ TYPE EDEVICED-BESITZ,
MSGTYP TYPE BDC_MART,
END OF GT_ITAB .
SELECTION-SCREEN BEGIN OF BLOCK 100 WITH FRAME TITLE TEXT-001 .
PARAMETERS : P_FNAME TYPE LOCALFILE.
SELECTION-SCREEN END OF BLOCK 100.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME .
PERFORM GET_FILENAME.
START-OF-SELECTION.
PERFORM GET_EXCEL_DATA.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form GET_FILENAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_FILENAME .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FNAME
EXCEPTIONS
OTHERS = 0.
IF SY-SUBRC NE 0 .
"Hata
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_EXCEL_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_EXCEL_DATA .
TRANSLATE P_FNAME TO UPPER CASE.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FNAME
TABLES
I_TAB_CONVERTED_DATA = GT_ITAB[]
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.
ENDFORM.
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com
Social Plugin