2007 Jan 24 9:38 AM
hello abapers,
can anyone help me how to upload data from excel sheet to internal table directly.thanx in advance,
regards,
santosh.
hello abapers,
can anyone help me how to upload data from excel sheet to internal table directly.thanx in advance,
regards,
santosh.
2007 Jan 24 9:38 AM
Use the function module GUI_UPLOAD or ALSM_EXCEL_TO_INTERNAL_TABLE.
Manoj
2007 Jan 24 9:39 AM
u can use any one of the below 2 Function modules
ALSM_EXCEL_TO_INTERNAL_TABLE
GUI_UPLOAD&----
*& Report Z_UPLOAD_EXAMPLE
*&
&----
*&
*&
&----
report z_upload_example.
parameters: exl_file type rlgrap-filename.
exl_file = p_file.
data: begin of itab occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
matkl like mara-matkl,
wrkst like mara-wrkst,
end of itab.
data: begin of itab1 occurs 0.
include structure alsmex_tabline.
data: end of itab1.
----
AT S E L E C T I O N S C R E E N ON VALUE REQUEST
----
at selection-screen on value-request for exl_file.
To get the F4 help for file
perform get_filename.
&----
*& Form GET_FILENAME
&----
This routine allows user to select the input file path
----
&----
*& Form get_filename
&----
text
----
--> p1 text
<-- p2 text
----
form get_filename .
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
FIELD_NAME = ' '
importing
file_name = exl_file.
.
endform. " get_filename
start-of-selection.
perform upload_data.
&----
*& Form upload_data
&----
text
----
--> p1 text
<-- p2 text
----
form upload_data .
data: v_file type string.
v_file = exl_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = exl_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 4
i_end_row = 4
tables
intern = itab1
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " upload_data
end-of-selection.
sort itab1 by row.
loop at itab1.
case itab1-col.
when '0001'.
itab-matnr = itab1-value.
when '0002'.
itab-mtart = itab1-value.
when '0003'.
itab-matkl = itab1-value.
when '0004'.
itab-wrkst = itab1-value.
endcase.
at end of row.
append itab.
clear itab.
endat.
endloop.
loop at itab.
write 😕 itab.
endloop.
Message was edited by:
Chandrasekhar Jagarlamudi
2007 Jan 24 9:39 AM
hi
You can upload excel to internal table using function
ALSM_EXCEL_TO_INTERNAL_TABLE
-
Santosh
2007 Jan 24 11:27 AM
Hello,
Can i know what is the excel format . Is it normal Excel or CSV
If it is normal excel u can use GUI_UPlOAD or ALSM_EXCEL*
When the format is CSv u can use KCD_CSV*Fm
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |