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: 

function module WS_upload

Former Member
0 Kudos
66

Hi experts

I wanted to upload one excel file in CSV format to database table which i vh created how to to the same my code is like this but it takes only dat file not CSV

REPORT ZSDCCDTGTUPD .

TABLES: ZCCD_TGT.

DATA: BEGIN OF itab OCCURS 0,

kunnr TYPE zccd_tgt-kunnr,

FSCAL_YEAR TYPE zccd_tgt-FSCAL_YEAR,

VALUE(14) type c, "TYPE zccd_tgt-VALUE,

date1 TYPE zccd_tgt-date1,

END OF itab.

data : l_flnm type rlgrap-filename.

selection-screen begin of block bk1 with frame title text-001.

selection-screen skip 1.

parameters: p_flnm like rlgrap-filename obligatory.

selection-screen skip 1.

selection-screen end of block bk1.

at selection-screen on value-request for p_flnm.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

importing

file_name = p_flnm.

.

start-of-selection.

clear l_flnm.

l_flnm = p_flnm.

call function 'WS_UPLOAD'

exporting

filename = l_flnm

filetype = 'dat'

tables

data_tab = ITAB

exceptions

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7

gui_refuse_filetransfer = 8

others = 9.

LOOP AT ITAB.

zccd_tgt-kunnr = ITAB-kunnr.

zccd_tgt-FSCAL_YEAR = ITAB-FSCAL_YEAR.

zccd_tgt-VALUE = ITAB-VALUE.

zccd_tgt-date1 = ITAB-DATE1.

MODIFY ZCCD_TGT.

commit work.

ENDLOOP.

REPORT ZSDCCDTGTUPD .

TABLES: ZCCD_TGT.

DATA: BEGIN OF itab OCCURS 0,

kunnr TYPE zccd_tgt-kunnr,

FSCAL_YEAR TYPE zccd_tgt-FSCAL_YEAR,

VALUE(14) type c, "TYPE zccd_tgt-VALUE,

date1 TYPE zccd_tgt-date1,

END OF itab.

data : l_flnm type rlgrap-filename.

selection-screen begin of block bk1 with frame title text-001.

selection-screen skip 1.

parameters: p_flnm like rlgrap-filename obligatory.

selection-screen skip 1.

selection-screen end of block bk1.

at selection-screen on value-request for p_flnm.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

importing

file_name = p_flnm.

.

start-of-selection.

clear l_flnm.

l_flnm = p_flnm.

call function 'WS_UPLOAD'

exporting

filename = l_flnm

filetype = 'dat'

tables

data_tab = ITAB

exceptions

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7

gui_refuse_filetransfer = 8

others = 9.

LOOP AT ITAB.

zccd_tgt-kunnr = ITAB-kunnr.

zccd_tgt-FSCAL_YEAR = ITAB-FSCAL_YEAR.

zccd_tgt-VALUE = ITAB-VALUE.

zccd_tgt-date1 = ITAB-DATE1.

MODIFY ZCCD_TGT.

commit work.

ENDLOOP.

1 REPLY 1

Kanagaraja_L
Active Contributor
0 Kudos
33

Use FM " ALSM_EXCEL_TO_INTERNAL_TABLE ".

Kanagaraja L