2008 Dec 11 1:28 PM
Dear friends,
While uploading flat file into an internal table generally we ask users to save that file in TEXT format
and by using filetype DAT , we take it into an internal table....
Can we take that file Directly from EXCEL to an INTERNAL TABLE using GUI_UPLOAD...
and avoiding use of fun module ALSM_EXCEL_TO_INTERNAL_TABLE....
or any other way out ?
Thanks........
2008 Dec 14 10:00 AM
HI,
Try this code to upload excel data into itab...
DATA l_count TYPE sy-tabix.
CONSTANTS: lc_begin_col TYPE i VALUE '1',
lc_begin_row TYPE i VALUE '2',
lc_end_col TYPE i VALUE '2',
lc_end_row TYPE i VALUE '3000'.
* Begin of CALK912848 - Carlos Werberich - 16Sep08
CLEAR p_i_excel_data. REFRESH p_i_excel_data.
* End of CALK912848 - Carlos Werberich - 16Sep08
* Function module to read excel file and convert it into internal table
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_p_file
i_begin_col = lc_begin_col
i_begin_row = lc_begin_row
i_end_col = lc_end_col
i_end_row = lc_end_row
TABLES
intern = i_data
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
* Error in file upload
IF sy-subrc NE 0 .
MESSAGE text-006 TYPE 'E'.
EXIT.
ENDIF.
IF i_data[] IS INITIAL .
MESSAGE text-007 TYPE 'E'.
EXIT.
ELSE.
SORT i_data BY row col .
* Loop to fill data in Internal Table
LOOP AT i_data .
MOVE i_data-col TO l_count .
ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO .
AT END OF row .
* Append data into internal table
APPEND p_i_excel_data.
CLEAR p_i_excel_data.
ENDAT .
ENDLOOP .
ENDIF
Dear friends,
While uploading flat file into an internal table generally we ask users to save that file in TEXT format
and by using filetype DAT , we take it into an internal table....
Can we take that file Directly from EXCEL to an INTERNAL TABLE using GUI_UPLOAD...
and avoiding use of fun module ALSM_EXCEL_TO_INTERNAL_TABLE....
or any other way out ?
Thanks........
2008 Dec 11 1:41 PM
hi,
try using this function module with fname as excel file name.
DATA FNAME TYPE RLGRAP-FILENAME.
DATA PNAME TYPE STRING
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = fname
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
and gui_upload like,
PNAME = FNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = PNAME
FILETYPE = 'ASC'
thanks
Arjun
2008 Dec 11 1:56 PM
but you got to split the cell content into your internal table structure.. that's gonna be messy its better to use the ALMExcell FM...
2008 Dec 11 2:38 PM
Hi,
This is not possiable with GUI_upload
It's better to go with ASLM_EXCEL_INTERNALTABLE.
Thanks,
2008 Dec 14 9:28 AM
2008 Dec 14 10:00 AM
HI,
Try this code to upload excel data into itab...
DATA l_count TYPE sy-tabix.
CONSTANTS: lc_begin_col TYPE i VALUE '1',
lc_begin_row TYPE i VALUE '2',
lc_end_col TYPE i VALUE '2',
lc_end_row TYPE i VALUE '3000'.
* Begin of CALK912848 - Carlos Werberich - 16Sep08
CLEAR p_i_excel_data. REFRESH p_i_excel_data.
* End of CALK912848 - Carlos Werberich - 16Sep08
* Function module to read excel file and convert it into internal table
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_p_file
i_begin_col = lc_begin_col
i_begin_row = lc_begin_row
i_end_col = lc_end_col
i_end_row = lc_end_row
TABLES
intern = i_data
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
* Error in file upload
IF sy-subrc NE 0 .
MESSAGE text-006 TYPE 'E'.
EXIT.
ENDIF.
IF i_data[] IS INITIAL .
MESSAGE text-007 TYPE 'E'.
EXIT.
ELSE.
SORT i_data BY row col .
* Loop to fill data in Internal Table
LOOP AT i_data .
MOVE i_data-col TO l_count .
ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO .
AT END OF row .
* Append data into internal table
APPEND p_i_excel_data.
CLEAR p_i_excel_data.
ENDAT .
ENDLOOP .
ENDIF
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |