‎2008 Jan 28 8:12 AM
hi i downloaded alv report in to exl/txt file using
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_ofname
filetype = 'ASC'
write_field_separator = '|'
TABLES
data_tab = i_out " .
but in the internal teble first column is displaying in last in excel/text file the so how to display it in proper manner
THX
‎2008 Jan 28 8:16 AM
Hi CHAAYA SEN,
Use Function module : ALSM_EXCEL_TO_INTERNAL_TABLE for execel sheet.
See this example code for upload excel sheet.
&----
*& Report ZC120_UPLOAD_TIMESHEET
*&
&----
*&
*&
&----
REPORT ZCL120_UPLOAD_TIMESHEET.
Parameters:
p_file type RLGRAP-FILENAME
default 'd:\times_internal_20071010', " File Name
p_empid type ZCL_EMPID.
constants:
C_b_c type i value 1, " Begin Col
C_b_r type i value 1, " Begin Row
C_e_c type i value 100, " End Col
C_e_r type i value 500. " End Row
data:
fs_table type ALSMEX_TABLINE, " Work Area for it_table
fs_insert type ZCL_TIME_DATA1. " Work Area for it_insert
data:
Begin of fs_data,
name(30),
Date(40),
Task(15),
Project(15),
Activity(15),
Time(6),
Disc(50),
Status(20),
Bill(5),
end of fs_data.
data:
it_table like table
of fs_table, " Table To Store data Of File
it_data like table
of fs_data, " Store In File Formate.
it_insert like table
of fs_insert. " To Store data like Database Table Formate
Read Excel Sheet
perform read_file Changing it_table.
Convert Data Function Module Structure to file Structure
perform convert using it_table
changing it_data.
Convert Date Formate
perform convert_date changing it_data.
Insert Data for file to Database Table
perform insert using it_data
changing it_insert.
loop at it_data into fs_data.
write / fs_data.
endloop.
&----
*& Form read_file
&----
text
----
<--P_IT_TABLE text
----
FORM read_file CHANGING P_IT_TABLE like it_table[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = c_b_c
I_BEGIN_ROW = c_b_r
I_END_COL = c_e_c
I_END_ROW = c_e_r
TABLES
INTERN = p_it_table
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. " read_file
&----
*& Form convert
&----
text
----
-->P_IT_TABLE text
<--P_IT_DATA text
----
FORM convert USING P_IT_TABLE like it_table[]
CHANGING P_IT_DATA like it_data[].
data: w_Temp type i value 1,
w_row type i value 1.
loop at p_it_table into fs_table.
if w_row = fs_table-row.
case w_temp.
when 1.
fs_data-name = fs_Table-value.
when 2.
fs_data-date = fs_table-value.
when 3.
fs_data-task = fs_table-value.
when 4.
fs_data-project = fs_Table-value.
when 5.
fs_data-activity = fs_table-value.
when 6.
fs_data-time = fs_table-value.
when 7.
fs_data-disc = fs_table-value.
when 8.
fs_data-status = fs_table-value.
when 9.
fs_data-disc = fs_table-value.
w_row = w_row + 1.
endcase.
w_temp = w_temp + 1.
if w_temp = 10.
append fs_data to p_it_data.
w_Temp = 1.
clear fs_table.
endif.
*endif.
endloop.
ENDFORM. " convert
&----
*& Form convert_date
&----
text
----
<--P_IT_DATA text
----
FORM convert_date CHANGING P_IT_DATA like it_data[].
data: day(2),
month(2),
year(4),
date(8).
loop at p_it_data into fs_data.
split fs_data-date at '/'
into day month year.
concatenate year month day into date.
fs_data-date = date.
modify p_it_data from fs_data.
endloop.
ENDFORM. " convert_date
&----
*& Form insert
&----
text
----
-->P_IT_DATA text
-->P_IT_INSERT text
----
FORM insert using p_it_data like it_data[]
changing P_IT_INSERT like it_insert[].
data lfs_insert like fs_insert.
loop at p_it_data into fs_data.
Conver Data From File Structure to Table Structure
perform convert_data using fs_data
changing lfs_insert.
insert ZCL_TIME_DATA1 from lfs_insert.
clear lfs_insert.
endloop.
ENDFORM. " insert
&----
*& Form convert_data
&----
text
----
-->P_FS_DATA text
-->P_FS_INSERT text
----
FORM convert_data USING P_fs_DATA like fs_data
CHANGING P_fs_INSERT like fs_insert.
p_fs_insert-mandt = sy-mandt.
p_fs_insert-empid = p_empid.
p_fs_insert-projectid = 'ERP_INT'.
p_fs_insert-WORK_DATE = fs_data-date.
p_fs_insert-objectid = 'SS'.
P_fs_insert-ACTIVITYID = fs_data-activity.
P_fs_insert-ACTIVITYID = 'AC001'.
p_fs_insert-empname = fs_data-name.
p_fs_insert-timeworked = fs_data-time.
p_fs_insert-DESCRIPTION = fs_data-Disc.
p_fs_insert-status = fs_data-status.
p_fs_insert-billingstatus = fs_data-bill.
ENDFORM. " convert_data
Plzz reward if it is useful,
Mahi.