Wednesday, September 30, 2020

Upload Excel File Data Update thought internal table in SAP ABAP.

Table update thought excel file upload in SAP ABAP. 


Table update program in SAP ABAP .

REPORT ZTCS_TAX_UPLOAD.

TYPE-POOLSTRUXS.

PARAMETERSP_FILE TYPE  RLGRAP-FILENAME.
PARAMETERSP_HEAD TYPE CHAR01 DEFAULT 'X'.

TYPESBEGIN OF T_DATATAB,
         KUNNR TYPE KUNNR,
         ALAND TYPE ALAND,
         TATYP TYPE TATYP,
         TAXKD TYPE TAKLD,
       END OF T_DATATAB.
DATAIT_DATATAB TYPE STANDARD TABLE OF T_DATATAB,
      WA_DATATAB TYPE T_DATATAB.

DATA:IT_KNVI_U TYPE STANDARD TABLE OF KNVI,
     WA_KNVI_U TYPE KNVI.

DATAIT_RAW TYPE TRUXS_T_TEXT_DATA.

* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      FIELD_NAME 'P_FILE'
    IMPORTING
      FILE_NAME  P_FILE.

START-OF-SELECTION.
  " CONVERT EXCEL DATA TO SAP INTERNAL TABLE DATA
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR    =
      I_LINE_HEADER        P_HEAD
      I_TAB_RAW_DATA       IT_RAW       " WORK TABLE
      I_FILENAME           P_FILE
    TABLES
      I_TAB_CONVERTED_DATA IT_DATATAB[]  "ACTUAL DATA
    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.
***********************************************************************
* END-OF-SELECTION.
END-OF-SELECTION.
  " FOR SAMPLE, EXCEL DATA TRANSFERED TO INTERNAL TABLE IS DISPLAYED WITH WRITE
  LOOP AT IT_DATATAB INTO WA_DATATAB.
        WA_KNVI_U-KUNNR =   WA_DATATAB-KUNNR.
        WA_KNVI_U-ALAND =   WA_DATATAB-ALAND.
        WA_KNVI_U-TATYP =   WA_DATATAB-TATYP.
        WA_KNVI_U-TAXKD =   WA_DATATAB-TAXKD.
        APPEND WA_KNVI_U TO IT_KNVI_U.
        MODIFY KNVI FROM WA_KNVI_U.
        COMMIT WORK AND WAIT.
  ENDLOOP.
  MESSAGE 'DATA UPDATED SUCCESSFULLY' TYPE 'I'.

No comments:

Post a Comment