07-15-2008 4:01 PM
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!
07-15-2008 4:04 PM
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.
07-15-2008 4:06 PM
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.
07-15-2008 4:07 PM
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
07-15-2008 4:23 PM
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.