Application Development and Automation 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: 
Read only

FILE format problem

Former Member
0 Likes
490

Hi All,

I want to use excel file as source file in my BDC. I am using GUI_UPLOAD for this, but if I select .XLS file it is picking junk values. Here I am using fuletype as ASC. After saving this file as .CSV the values of column 01 is replaced as 1 that is not required. Same is happening when TAB DELIMITTED is selected.

Can any one suggest solution for this?

Regards,

Dilip Gupchup

3 REPLIES 3
Read only

Former Member
0 Likes
453

Do that way.

Save your excel as tab delimited text file (or Text (Unicode).

Then upload to sap. All will be ok then.

BR, Jacek

Message was edited by: Jacek Slowikowski

Read only

Former Member
0 Likes
453

Hi Dilip,

Check this sample code.Use your Excel file for the Uploading purpose

report ztest.

types: begin of ttab ,

fld1(30) type c,

fld2(30) type c,

fld3(30) type c,

fld4(30) type c,

fld5(30) type c,

end of ttab.

data: itab type table of ttab with header line.

selection-screen skip 1.

parameters: p_file type localfile default

'C:\test.txt'.

selection-screen skip 1.

at selection-screen on value-request for p_file.

call function 'KD_GET_FILENAME_ON_F4'

exporting

static = 'X'

changing

file_name = p_file.

start-of-selection.

clear itab. refresh itab.

perform upload_data.

loop at itab.

write:/ itab-fld1, itab-fld2, itab-fld3, itab-fld4, itab-fld5.

endloop.

************************************************************************

  • Upload_Data

************************************************************************

form upload_data.

data: file type rlgrap-filename.

data: xcel type table of alsmex_tabline with header line.

file = p_file.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = file

i_begin_col = '1'

i_begin_row = '1'

i_end_col = '200'

i_end_row = '5000'

tables

intern = xcel

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

loop at xcel.

case xcel-col.

when '0001'.

itab-fld1 = xcel-value.

when '0002'.

itab-fld2 = xcel-value.

when '0003'.

itab-fld3 = xcel-value.

when '0004'.

itab-fld4 = xcel-value.

when '0005'.

itab-fld5 = xcel-value.

endcase.

at end of row.

append itab.

clear itab.

endat.

endloop.

endform.

Read only

Former Member
0 Likes
453

Hi,

U can use this way here split wont work so try s follows-

DATA: TEMP_TAB LIKE ALSMEX_TABLINE OCCURS 5 WITH HEADER LINE.

CASE TEMP_TAB-COL.

WHEN 1.

record-LIFNR_001 = TEMP_TAB-VALUE.

WHEN 2.

record-BSART_002 = TEMP_TAB-VALUE.

WHEN 3.

record-BEDAT_003 = TEMP_TAB-VALUE.

WHEN 4.

record-EKORG_004 = TEMP_TAB-VALUE.

WHEN 5.

record-EKGRP_005 = TEMP_TAB-VALUE.

WHEN 6.

record-LPEIN_006 = TEMP_TAB-VALUE.

WHEN 7.

record-WERKS_007 = TEMP_TAB-VALUE.

WHEN 8.

record-EMATN_01_008 = TEMP_TAB-VALUE.

WHEN 9.

record-MENGE_01_009 = TEMP_TAB-VALUE.

WHEN 10.

record-EBELP_010 = TEMP_TAB-VALUE.

ENDCASE.

Hope this helps u.

Regards,

Seema.