Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to select columns from internal table using 'GUI_DOWNLOAD' ?

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

8 REPLIES 8

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

same question answered in this link...

0 Kudos

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

abdul_hakim
Active Contributor
0 Kudos

Hi vijay,

just select the required fields and pass it to an another itab and pass it to gui_download...

Cheers,

Abdul Hakim

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.