2006 Feb 13 6:36 PM
Hi Friendz...
In a program i have transferred the data from a Excel Spread sheet (.xls file) to an internal table using FM <b>"ALSM_EXCEL_TO_INTERNAL_TABLE"</b>.
The internal table is like this:
begin of xl_data occurs 0,
vendor name
street
address
vat reg no
bank no
........
.........
........
end of xl_data.
now i have to include some more fields to this internal table and then i have to download this data to a <b>.txt</b> file.
could you please tell me how should i do this?
2006 Feb 13 6:44 PM
Please see this sample program. It will upload from excel into internal table, move data to another itab with other fields and download to C:\ drive.
report zrich_0002.
types: begin of ttab ,
fld1(30) type c,
fld2(30) type c,
fld3(30) type c,
fld4(30) type c,
fld5(30) type c,
end of ttab.
types: begin of ttab2 ,
fld1(30) type c,
fld2(30) type c,
fld3(30) type c,
fld4(30) type c,
fld5(30) type c,
fld6(30) type c,
fld7(30) type c,
end of ttab2.
data: itab type table of ttab with header line.
data: itab2 type table of ttab2 with header line.
selection-screen skip 1.
parameters: p_file type localfile default
'C:test.txt'.
selection-screen skip 1.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
clear itab. refresh itab.
perform upload_data.
loop at itab.
clear itab2.
move-corresponding itab to itab2.
itab2-fld6 = 'Another Field'.
itab2-fld7 = 'No, really last one'.
append itab2.
endloop.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:itab2.txt'
tables
data_tab = itab2
exceptions
others = 22.
************************************************************************
* Upload_Data
************************************************************************
form upload_data.
data: file type rlgrap-filename.
data: xcel type table of alsmex_tabline with header line.
file = p_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'
tables
intern = xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
loop at xcel.
case xcel-col.
when '0001'.
itab-fld1 = xcel-value.
when '0002'.
itab-fld2 = xcel-value.
when '0003'.
itab-fld3 = xcel-value.
when '0004'.
itab-fld4 = xcel-value.
when '0005'.
itab-fld5 = xcel-value.
endcase.
at end of row.
append itab.
clear itab.
endat.
endloop.
endform.
Regards,
Rich Heilman
Hi Friendz...
In a program i have transferred the data from a Excel Spread sheet (.xls file) to an internal table using FM <b>"ALSM_EXCEL_TO_INTERNAL_TABLE"</b>.
The internal table is like this:
begin of xl_data occurs 0,
vendor name
street
address
vat reg no
bank no
........
.........
........
end of xl_data.
now i have to include some more fields to this internal table and then i have to download this data to a <b>.txt</b> file.
could you please tell me how should i do this?
2006 Feb 13 6:44 PM
Please see this sample program. It will upload from excel into internal table, move data to another itab with other fields and download to C:\ drive.
report zrich_0002.
types: begin of ttab ,
fld1(30) type c,
fld2(30) type c,
fld3(30) type c,
fld4(30) type c,
fld5(30) type c,
end of ttab.
types: begin of ttab2 ,
fld1(30) type c,
fld2(30) type c,
fld3(30) type c,
fld4(30) type c,
fld5(30) type c,
fld6(30) type c,
fld7(30) type c,
end of ttab2.
data: itab type table of ttab with header line.
data: itab2 type table of ttab2 with header line.
selection-screen skip 1.
parameters: p_file type localfile default
'C:test.txt'.
selection-screen skip 1.
at selection-screen on value-request for p_file.
call function 'KD_GET_FILENAME_ON_F4'
exporting
static = 'X'
changing
file_name = p_file.
start-of-selection.
clear itab. refresh itab.
perform upload_data.
loop at itab.
clear itab2.
move-corresponding itab to itab2.
itab2-fld6 = 'Another Field'.
itab2-fld7 = 'No, really last one'.
append itab2.
endloop.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:itab2.txt'
tables
data_tab = itab2
exceptions
others = 22.
************************************************************************
* Upload_Data
************************************************************************
form upload_data.
data: file type rlgrap-filename.
data: xcel type table of alsmex_tabline with header line.
file = p_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'
tables
intern = xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
loop at xcel.
case xcel-col.
when '0001'.
itab-fld1 = xcel-value.
when '0002'.
itab-fld2 = xcel-value.
when '0003'.
itab-fld3 = xcel-value.
when '0004'.
itab-fld4 = xcel-value.
when '0005'.
itab-fld5 = xcel-value.
endcase.
at end of row.
append itab.
clear itab.
endat.
endloop.
endform.
Regards,
Rich Heilman
2006 Feb 13 7:06 PM
Hi Rich,
thanks very much.
I'll follow this method in my program.
2006 Feb 13 7:09 PM
2006 Feb 13 6:47 PM
Create a new internal table with all fields in your uploaded table in same sequence & at last additional fields you require. Equate table as -
New table[] = Uploaded table[]
Populate data in required fields & download it.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |