05-03-2006 6:16 AM
Hi,
i am running a report & the fields for output is saved in an internal table which has as many as 10 fields. But I want to select only a few fields for output. There is a option COL_SELECT in function 'GUI_DOWNLOAD'. How to use it. If possible with example.
05-03-2006 6:27 AM
if you have a look at the documentation it says this is only applicable for files of type *.DAT.
In order to activate selecting particular fields you have to pass 'X' to parameter COL_SELECT.
Now in order to select fields you have a field COL_SELECTMASK of length 128 characters. each character represents each field's mask. so if you want to download only 1,3, and 5th field. Pass 'X X X' to COL_SELECTMASK.
05-03-2006 6:26 AM
Hi vijay,
Just read below
There are two fields
COL_SELECT and COL_SELECT_MASK
Pass 'X' to COL_SELECT
and
COL_SELECT_MASK is a vector which should be populated as below:
Masking the column selection. In connection with COL_SELECT a column selection becomes possible.
Value range
Character field up to 128 characters, consisting of SPACE and 'x'. Each character represents one column of the table. A SPACE represents a column to be omitted, every other character represents a column to be added.
Example:
1) COL_SELECTMASK = 'X X X'
The columns 1,3,5 are downloaded.
2) COL_SELECTMASK = 'XXX X X'
The columns 1,2,3,5,7 are downloaded.
Hope it helps...
Lokesh
pls. reward appropriate points
Message was edited by: Lokesh Aggarwal
05-03-2006 6:27 AM
if you have a look at the documentation it says this is only applicable for files of type *.DAT.
In order to activate selecting particular fields you have to pass 'X' to parameter COL_SELECT.
Now in order to select fields you have a field COL_SELECTMASK of length 128 characters. each character represents each field's mask. so if you want to download only 1,3, and 5th field. Pass 'X X X' to COL_SELECTMASK.
05-03-2006 6:29 AM
05-03-2006 6:32 AM
Hi,
Which type of file you want.
This parameter has a limitation for *.dat. Incase you want a the other type, you need to pass only those fields to the Function Module.
For this you can create another internal table with only the fields you require and copy the data from the primary table to the one created.
Lokesh
pls. reward appropriate points
05-03-2006 6:32 AM
Hi vijay,
just select the required fields and pass it to an another itab and pass it to gui_download...
Cheers,
Abdul Hakim
05-03-2006 6:33 AM
Hi vijaykumar,
1. to get a taste of it, just copy paste in new program.
2. it will download 2 and 4th field of T001
ie. Bukrs, Ort01 only.
3.
report abc.
*----
data : t001 like table of t001 with header line.
*----
select * from t001 into table t001.
*----
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'd:\t001.txt'
WRITE_FIELD_SEPARATOR = 'X'
COL_SELECT = 'X' "<----
IMP
COL_SELECT_MASK = ' X X' "<----
IMP
TABLES
DATA_TAB = t001
.
regards,
amit m.
05-03-2006 6:47 AM
Hai VijayKumar
Try with the following code
tables : mara.
data : begin of it_mara occurs 0,
matnr like mara-matnr,
mbrsh like mara-mbrsh,
mtart like mara-mtart,
meins like mara-meins,
end of it_mara.
parameters : P_mtart like mara-mtart default 'ROH'.
start-of-selection.
perform select_data.
perform download_data.
&----
*& Form select_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM select_data .
select
matnr
mbrsh
mtart
meins
from mara into table it_mara
where mtart = p_mtart.
ENDFORM. " select_data
&----
*& Form download_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM download_data .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'c:\down.txt'
FILETYPE = 'ASC'
COL_SELECT = 'X'
COL_SELECT_MASK = 'X XX'
TABLES
DATA_TAB = it_mara.
IF SY-SUBRC = 0.
SORT IT_MARA BY MATNR.
ENDIF.
ENDFORM. " download_data
Thanks & Regards
Sreenivasulu P
05-03-2006 7:15 AM
Hi Vijay,
Another option is : you can follow the following steps :
1. You can create another internal tables whihc has only the fileds whihc you wan to be downloaded.
for exapmle, internal table itab has fields say from fld1 ..to..fld10.
But you want fld1, fld2, fld6, fld7, fld9 to be downloaded.
So you can create another internal table itab1 with columns fld1, fld2, fld6, fld7, fld9 .
You can do so :
<b>data : begin of itab1 occurs 0.
declare the necessary fileds fld1 fld2..fld9
end of itab1.</b>
2. Pass the values of these fileds from itab.
to do so , you can use :
<b>loop at itab.
itab1-fld1 = itab-fld1.
itab-fld2 = itab-fld2.
itab-fld6 = itab-fld6.
itab-fld7 = itab-fld7.
itab-fld9 = itab-fld9.
append itab.
endloop.</b>
3. <b>Pass itab1 to the gui_download function.</b>
So here you dont have to worry about the column_mask ...
Thanks and Regards,
Kunal.