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: 

uploading Excel file into SAP Database table?

Former Member
0 Kudos

I built a table in the SAP Data Dictionary, and i need to write a program that uploads the Excel table, into the SAP Database table. Does anybody have a sample program that may help me? Thanks!

4 REPLIES 4

Former Member
0 Kudos

HI,

First upload data into internal table of type database table you want ot populate.

For this Use:

Fn. moduleGUI_UPLOAD.

Then use UPDATE statement to update database table from internal table.

Hope it helps.

former_member181995
Active Contributor
0 Kudos

Danial,

TYPE-POOLS: truxs.
*PARAMETERS: dataset(132) LOWER CASE DEFAULT
*                              'c:\temp\etchingload.txt'.
PARAMETER: pfile LIKE rlgrap-filename." OBLIGATORY.
 CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR          =
      i_line_header              = 'X'
      i_tab_raw_data             = it_raw
      i_filename                 = pfile
    TABLES
      i_tab_converted_data       = it_final
*   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.

INSERT zpayroll FROM  it_final."zpayroll is DB
*  modify zpayroll FROM  it_final.
      IF sy-subrc = 0.
        COMMIT WORK.
      ELSE.
        UPDATE zpayroll FROM it_final.
        IF sy-subrc = 0.
          COMMIT WORK.
        ENDIF.

Amit.

Former Member
0 Kudos

Check this thread.

https://forums.sdn.sap.com/click.jspa?searchID=14081921&messageID=5590107

do a search in forum with the Kep word 'Upload Excel', you will get a number of programs.

Amandeep

Former Member
0 Kudos

TYPES:

BEGIN OF ty_upload,

matnr like mara-matnr,

meins like mara-meins,

mtart like mara-mtart,

mbrsh like mara-mbrsh,

END OF ty_upload.

DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH header line.

DATA wa_upload TYPE ty_upload.

DATA: itab TYPE STANDARD TABLE OF alsmex_tabline WITH header line.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = 'C:\Documents and Settings\venkatapp\Desktop\venkat.xls'

i_begin_col = 1

i_begin_row = 1

i_end_col = 4

i_end_row = 65535

TABLES

intern = itab.

if not itab[] is initial.

loop at itab .

case itab-col.

when '0001'.

it_upload-matnr = itab-value.

when '0002'.

it_upload-meins = itab-value.

when '0003'.

it_upload-mtart = itab-value.

when '0004'.

it_upload-mbrsh = itab-value.

append it_upload.

clear it_upload.

clear itab.

endcase.

endloop.

endif.

loop at it_upload into wa_upload.

ztable-matnr = wa_upload-matnr.

ztable-meins = wa_upload-meins.

ztable-mtart = wa_upload-mtart.

ztable-mbrsh = wa_upload-mbrsh.

insert ztable.

endloop.