F How to show Excel data to Internal Table in SAP ABAP | CodeTheta

How to show Excel data to Internal Table in SAP ABAP


EXCEL DATA

Code :
REPORT ZVP_EXCEL_TO_INTERNAL_TABLE.

TYPE-POOLSTRUXS.

TYPESBEGIN OF STRC,
         ID   TYPE CHAR10,
         NAME TYPE CHAR10,
         AGE  TYPE CHAR10,
       END OF STRC.

DATAIT_STRC TYPE TABLE OF STRC,
      WA_STRC TYPE STRC.

DATAIT_RAW TYPE TRUXS_T_TEXT_DATA.

PARAMETERSP_FILE TYPE RLGRAP-FILENAME.

**************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
*     PROGRAM_NAME        = SYST-CPROG
*     DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME 'P_FILE'
    IMPORTING
      FILE_NAME  P_FILE.
**************************************************************

**************************************************************
START-OF-SELECTION.
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR    =
      I_LINE_HEADER        'X'
      I_TAB_RAW_DATA       IT_RAW
      I_FILENAME           P_FILE
    TABLES
      I_TAB_CONVERTED_DATA IT_STRC
    EXCEPTIONS
      CONVERSION_FAILED    1
      OTHERS               2.

  IF IT_STRC IS INITIAL.
    MESSAGE'EMPTY' TYPE 'I'.
  ENDIF.

END-OF-SELECTION.
*************************************************************

  LOOP AT IT_STRC INTO WA_STRC.
      WRITE:/ WA_STRC-ID,
              WA_STRC-NAME,
              WA_STRC-AGE.
  ENDLOOP.
  .


Output :


IDE Used To Test This Code : ABAP Editor

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment