12-13-2006 4:16 AM
Can any one tell me how to download an excel sheet into an internal table.. is there any function module...?
12-13-2006 4:26 AM
Hello Rajesh,
I Have a example for the excel to internal table upload..
Check this..
&----
*& Form excel_upload
&----
text
----
--> p1 text
<-- p2 text
----
FORM excel_upload .
DATA : l_f_index TYPE i.
FIELD-SYMBOLS : <l_fs> TYPE ANY.
Upload Excel file
IF p_rb2 = 'X'.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_fname2
i_begin_col = g_f_start_col
i_begin_row = g_f_start_row
i_end_col = g_f_end_col
i_end_row = g_f_end_row
TABLES
intern = g_t_intern
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.
ENDIF.
Populate data into Internal table
SORT g_t_intern BY row col .
LOOP AT g_t_intern .
MOVE g_t_intern-col TO l_f_index .
ASSIGN COMPONENT l_f_index OF STRUCTURE g_s_upld TO <l_fs> .
MOVE g_t_intern-value TO <l_fs>.
AT END OF row .
APPEND g_s_upld TO g_t_upld.
CLEAR g_s_upld .
ENDAT .
ENDLOOP .
LOOP AT g_t_upld INTO g_s_upld.
Convert the material to internal format.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = g_s_upld-matnr
IMPORTING
output = g_s_upld-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc EQ 0.
MODIFY g_t_upld FROM g_s_upld TRANSPORTING matnr.
ENDIF.
ENDLOOP.
ENDFORM. " excel_upload
Reward if usefull..
Regds,
Srini
12-13-2006 4:17 AM
Use the FM : ALSM_EXCEL_TO_INTERNAL_TABLE
Usage as below :
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_filename
i_begin_col = vf_start_col
i_begin_row = vf_start_row
i_end_col = vf_end_col
i_end_row = vf_end_row
TABLES
intern = if_intern.
IF if_intern[] IS INITIAL.
p_text = 'No Data Uploaded'.
ELSE.
SORT if_intern BY row col.
LOOP AT if_intern.
MOVE : if_intern-col TO vf_index.
ASSIGN COMPONENT vf_index OF STRUCTURE p_download TO <fs>.
MOVE : if_intern-value TO <fs>.
AT END OF row.
APPEND p_download.
CLEAR p_download.
ENDAT.
ENDLOOP.
ENDIF.
Regards
- Gopi
12-13-2006 4:19 AM
Hi,
You can also use FM TEXT_CONVERT_XLS_TO_SAP.
Please check this link for sample codes.
https://forums.sdn.sap.com/click.jspa?searchID=389598&messageID=2802611
Hope this will help.
Regards,
Ferry Lianto
12-13-2006 4:26 AM
Hello Rajesh,
I Have a example for the excel to internal table upload..
Check this..
&----
*& Form excel_upload
&----
text
----
--> p1 text
<-- p2 text
----
FORM excel_upload .
DATA : l_f_index TYPE i.
FIELD-SYMBOLS : <l_fs> TYPE ANY.
Upload Excel file
IF p_rb2 = 'X'.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_fname2
i_begin_col = g_f_start_col
i_begin_row = g_f_start_row
i_end_col = g_f_end_col
i_end_row = g_f_end_row
TABLES
intern = g_t_intern
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.
ENDIF.
Populate data into Internal table
SORT g_t_intern BY row col .
LOOP AT g_t_intern .
MOVE g_t_intern-col TO l_f_index .
ASSIGN COMPONENT l_f_index OF STRUCTURE g_s_upld TO <l_fs> .
MOVE g_t_intern-value TO <l_fs>.
AT END OF row .
APPEND g_s_upld TO g_t_upld.
CLEAR g_s_upld .
ENDAT .
ENDLOOP .
LOOP AT g_t_upld INTO g_s_upld.
Convert the material to internal format.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = g_s_upld-matnr
IMPORTING
output = g_s_upld-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
IF sy-subrc EQ 0.
MODIFY g_t_upld FROM g_s_upld TRANSPORTING matnr.
ENDIF.
ENDLOOP.
ENDFORM. " excel_upload
Reward if usefull..
Regds,
Srini