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

Populating internal table with excel data from application server

Former Member
0 Likes
1,343

Hi All,

I am trying to download excel file into an internal table and file is residing at application server. In this case, internal table is getting populated with some garbage values which are the properties of an excel sheet.

So, kindly suggest me how to populate the internal table with only excel data.

Regards,

N.Jain

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
705

For downloading data from application server u need to use DATASETS.

Refer to the following code

gv_dataset1 TYPE char100 .

OPEN DATASET gv_dataset1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

  • MESSAGE

ELSE.

WHILE ( sy-subrc EQ 0 ).

READ DATASET gv_dataset1 INTO wa_itab.

IF NOT wa_itab IS INITIAL.

APPEND wa_itab TO itab.

ENDIF.

CLEAR wa_itab.

ENDWHILE.

ENDIF.

CLOSE DATASET gv_dataset1.

REWARD POINTS IF USEFUL

5 REPLIES 5
Read only

Former Member
0 Likes
706

For downloading data from application server u need to use DATASETS.

Refer to the following code

gv_dataset1 TYPE char100 .

OPEN DATASET gv_dataset1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

  • MESSAGE

ELSE.

WHILE ( sy-subrc EQ 0 ).

READ DATASET gv_dataset1 INTO wa_itab.

IF NOT wa_itab IS INITIAL.

APPEND wa_itab TO itab.

ENDIF.

CLEAR wa_itab.

ENDWHILE.

ENDIF.

CLOSE DATASET gv_dataset1.

REWARD POINTS IF USEFUL

Read only

Former Member
0 Likes
705

hOPE THIS IS HELPFUL TO U

FOLLOW THE LINK

DO REWARD IF USEFUL

Read only

Former Member
0 Likes
705

Hi,

Try this..I believe it will work if the file is tab delimited..

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'.

Regards.

Read only

Former Member
0 Likes
705

hi,

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 .

Hope this helps, Do reward.

Read only

Former Member
0 Likes
705

Actually I am having Macros in the file so it is not getting properly converted.