Upload file excel ke Internal Table ..

*&———————————————————————*
*& Report  ZUPXLTAB
*&
*&———————————————————————*
*& Name : Ghochi
*& Desc : Export file Excel ke Internal Tabel
*&———————————————————————*

report  zupxltab linesize 1000.

type-pools: truxs.

parameters: p_file type rlgrap-filename.

typesbegin of t_datatab,
col1(
30type c,
col2(
30type c,
col3(
30type c,
col4(
30type c,
col5(
30type c,
col6(
30type c,
col7(
30type c,
end of t_datatab.

data : max_row type i.
data : lv_i type string,lv_p type p.
data: it_datatab type standard table of t_datatab,
wa_datatab 
type t_datatab.

data: it_raw type truxs_t_text_data.

at selection-screen on value-request for p_file.
call function ‘F4_FILENAME’
exporting
field_name = 
‘P_FILE’
importing
file_name = p_file.

start-of-selection.

call function ‘TEXT_CONVERT_XLS_TO_SAP’
exporting
* I_FIELD_SEPERATOR =
i_line_header = 
‘X’
i_tab_raw_data = it_raw
i_filename = p_file
tables
i_tab_converted_data = it_datatab[]
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.

endof-selection.
describe field it_datatab length max_row in byte mode.

loop at it_datatab into wa_datatab.

write:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3,
wa_datatab-col4,
wa_datatab-col5,
wa_datatab-col6,
wa_datatab-col7.

endloop.

Advertisements

One Response to “Upload file excel ke Internal Table ..”

  1. opo iku..
    Ga Jelas….
    Le, tambah neng blogrollmu le.
    http://www.mochamadridwan.wordpress.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: