2007 Oct 17 5:37 PM
Hi I am using the FM ALSM_EXCEL_TO_INTERNAL_TABLE to upload a excel file to an internal table. I am giving a row and column range and all data with in this range should be in the internal table. Now the problem is , those cells that are blank , are not uploaded , I want the blanks also to be loaded in to the internal table. Can this be achieved ?
Thank you
2007 Oct 17 5:41 PM
Using this fm it is not possible, but you can use GUI_UPLOAD and change EXCEL to CSV format and upload the file. This will help you to get blank cells.
ashish
Using this fm it is not possible, but you can use GUI_UPLOAD and change EXCEL to CSV format and upload the file. This will help you to get blank cells.
ashish
2007 Oct 17 5:41 PM
Using this fm it is not possible, but you can use GUI_UPLOAD and change EXCEL to CSV format and upload the file. This will help you to get blank cells.
ashish
2007 Oct 17 6:56 PM
Hi,
Please try FM TEXT_CONVERT_XLS_TO_SAP.
Also check this link for sample codes.
http://www.sapdevelopment.co.uk/file/file_upexcel.htm
Regards,
Ferry Lianto
2007 Oct 17 7:43 PM
Why do you need that? when you didnt find a certain row/column in the table you know that its value is blank:
pseudocode:
read table it_excel with key row = 4 col = 6.
if sy-subrc = 0.
field = value.
else,
clear field.
endif.
2007 Oct 17 8:16 PM
Krish,
This fm has a limitation
It's the 50-character size of the VALUE field in structure ALSMEX_TABLINE.Some of the cells in the source files contain texts which are longer than 50 characters and therefore the texts are truncated.
a®
2007 Oct 17 10:03 PM
try this...I think this should resolve ur problem....
v_semfile = p_ifname.
refresh it_input.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = v_semfile
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 17
I_END_ROW = 6
TABLES
INTERN = it_input
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
2007 Oct 18 6:24 AM
Krish,
File manuplations...............................
1. At the presentation level:
->GUI_UPLOAD
->GUI_DOWNLOAD
->CL_GUI_FRONTEND
2. At the application server level:
->OPEN DATASET : open a file in the application server for reading or writing.
->READ DATASET : used to read from a file on the application server that has been opened for reading
-> TRANSFER DATASET : writing data to a file.
-> CLOSE DATASET : closes the file
-> DELETE DATASET : delete file
************************************************************************************************
If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
call function 'GUI_UPLOAD'
exporting
filename = p_file
filetype = 'ASC'
has_field_separator = '#'
tables
data_tab = t_data
******************************************************************************
p_file : excel file path.
t_data : internal table
*******************************************************************************
reward points if useful.
regards,
Vinod Samuel.
2007 Oct 18 6:30 AM
Hi
this program is write like excel sheet to internal table and then to application server
see this you can understand very easily
&----
*& Report ZSD_EXCEL_INT_APP
*&
&----
*&
*&
&----
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 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.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
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.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop.
<b>Reward fi usefull</b>
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |