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

Application server Excel file to Internal table

Former Member
0 Likes
2,873

Hi experts,

I have an excel file on the App server.

I need to upload it to internal tables.

Pls let me knw how this can be done....

Thanks in advance

Note : Valid answers will be rewarded!!

8 REPLIES 8
Read only

Former Member
0 Likes
1,269

Hi

Use Opendataset, followed by Transfer and then Closedataset to populate internal table from file in appl server.

Thanks

Vijay

Read only

Former Member
0 Likes
1,269

Check out in this way ..


report ztest
no standard page heading.

parameters: d1 type localfile default '/usr/sap/TEST/Data1.csv'.

data: begin of itab occurs 0,
fld1(20) type c,
fld2(20) type c,
fld3(20) type c,
end of itab.
data: wa(2000) type c.

start-of-selection.

open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc 0.
exit.
endif.
split wa at ',' into itab-fld1 itab-fld2 itab-fld3.
append itab.
enddo.
endif.
close dataset d1. 

REgards,

Santosh

Read only

Former Member
0 Likes
1,269

Hi ,

Refer these link.

[;

[;

[;

Hope this helps.

Award if helpful.

Regards

Sourabh

Read only

Former Member
0 Likes
1,269

Hi Gayathri,

U can use read it using Datasets.

See the concept of Datasets in ABAP.

U can Understand it easily.

Regards,

GP

Read only

ThomasZloch
Active Contributor
0 Likes
1,269

<REMOVED>

Edited by: Thomas Zloch on Mar 20, 2008 9:43 AM

Read only

Former Member
0 Likes
1,269

Hi All,

U have all given solutions for a tab delimited text file...pls understand that its for an EXCEL file...

Note : Excel file content is in Russian language....!

Read only

Former Member
0 Likes
1,269

Gayathri,

Try with below 2 methods.

1.

DATA : l_t_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.

DATA : l_f_index TYPE i.

DATA : l_f_start_col TYPE i VALUE '1',

l_f_start_row TYPE i VALUE '2',

l_f_end_col TYPE i VALUE '38',

l_f_end_row TYPE i VALUE '65536'.

FIELD-SYMBOLS : <l_fs>.

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

EXPORTING

filename = p_i_path

i_begin_col = l_f_start_col

i_begin_row = l_f_start_row

i_end_col = l_f_end_col

i_end_row = l_f_end_row

TABLES

intern = l_t_intern.

Assign uploaded XL fields to the fields of the target internal table

SORT l_t_intern BY row col .

LOOP AT l_t_intern .

MOVE l_t_intern-col TO l_f_index .

ASSIGN COMPONENT l_f_index OF STRUCTURE g_t_upload TO <l_fs> .

MOVE l_t_intern-value TO <l_fs> .

AT END OF row .

APPEND g_t_upload .

ENDAT .

ENDLOOP .

ENDIF .

2>

code

DATA: v_string TYPE string.

DATA: v_hex TYPE x VALUE '09'.

DATA: BEGIN OF itab OCCURS 0,

matnr TYPE matnr,

werks TYPE werks_d,

END OF itab.

OPEN DATASET '/tmp/test.xls' FOR INPUT.

CHECK sy-subrc = 0.

DO.

READ DATASET '/tmp/test.xls' INTO v_string.

IF sy-subrc 0.

EXIT.

ENDIF.

SPLIT v_string AT v_hex INTO itab-matnr itab-werks.

ENDDO.

CLOSE DATASET '/tmp/test.xls'.

Pls. reward if useful.....

Read only

Former Member
0 Likes
1,269

This message was moderated.