Skip to Content
avatar image
Former Member

Reg: GUI_DOWNLOAD (fieldnames )

Hello all,

How can we populate column names using FM 'GUI_DOWNLOAD' ??

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 22, 2007 at 11:55 AM

    Hi,

    try this:

    DATA: DATEI_PC TYPE STRING.

    *

    TYPES: BEGIN OF IMARA,

    MATNR LIKE MARA-MATNR,

    MTART LIKE MARA-MATNR,

    END OF IMARA.

    *

    DATA: ITAB TYPE TABLE OF IMARA WITH HEADER LINE.

    *

    SELECT MATNR MTART INTO TABLE ITAB FROM MARA UP TO 10 ROWS.

    *

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_DESKTOP_DIRECTORY

    CHANGING

    DESKTOP_DIRECTORY = DATEI_PC.

    *

    CALL METHOD CL_GUI_CFW=>FLUSH.

    *

    CONCATENATE DATEI_PC '\MATNR.TXT' INTO DATEI_PC.

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

    EXPORTING

    FILENAME = DATEI_PC

    FILETYPE = 'ASC'

    WRITE_FIELD_SEPARATOR = 'X'

    CHANGING

    DATA_TAB = ITAB[].

    *

    Regards, Dieter

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2007 at 12:12 PM

    hi,

    GUI_DOWNLOAD FM is used for downloading data into local system at specified path.

    parameters: p_file(75) type c.

    data:str type s.

    str = p_file.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = str 'path of file to which internal table is downloaded

    filetype = 'ASC'

    • APPEND = 'X'

    write_field_separator = '' ' for tab delimited file

    • CONFIRM_OVERWRITE = 'X'

    TABLES

    data_tab = ti_saida[] ' assign internal table body structure

    EXCEPTIONS

    file_open_error = 1

    file_write_error = 2

    OTHERS = 3.

    if helpful reward some points.

    with regards,

    suresh

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 22, 2007 at 11:30 AM

    Hi,

    To filename:

    p_file_saida TYPE string

    p_file_saida = 'C:\dir\text.txt'.

    The internal table:

    BEGIN OF ti_saida OCCURS 0,

    id(8) ,

    name(25) ,

    city(25) ,

    country(3) ,

    carrname(20) ,

    fldate(8) ,

    bookid(8) ,

    END OF ti_saida,

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = p_file_exit

    filetype = 'ASC'

    • APPEND = 'X'

    write_field_separator = ''

    • CONFIRM_OVERWRITE = 'X'

    TABLES

    data_tab = ti_saida[]

    EXCEPTIONS

    file_open_error = 1

    file_write_error = 2

    OTHERS = 3.

    Message was edited by:

    Rodrigo Paisante

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2007 at 11:59 AM

    hi

    create an internal table with one column containig the headngs of the cloumn.

    call GUI_DOWNLOAD and give file name and pass this internal table having column names

    now again call GUI_DOWNLOAD and pass ur internal table of value and give same file name

    regards

    ravish

    <b>plz dont forget to reward points if helpful</b>

    Message was edited by:

    ravish goyal

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2007 at 12:07 PM

    Hi Srivijaya

    Have a look at the following code. You have to populate the table FIELDNAMES with the names that u want and then pass it to the FM along with the data table.

    TYPES : BEGIN OF t_tadir,

    obj_name TYPE sobj_name,

    devclass TYPE devclass,

    END OF t_tadir.

    TYPES : BEGIN OF T_FIELD,

    COLUMN(50) TYPE C,

    END OF T_FIELD.

    DATA : it_tadir TYPE STANDARD TABLE OF t_tadir WITH HEADER LINE,

    IT_FIELD TYPE STANDARD TABLE OF T_FIELD WITH HEADER LINE.

    SELECT obj_name

    devclass

    FROM tadir

    up to 20 rows

    INTO TABLE it_tadir

    WHERE object = 'PROG'

    AND ( obj_name LIKE 'Y%' OR

    obj_name LIKE 'Z%' )

    AND devclass <> '$TMP'.

    IF sy-subrc = 0.

    SORT it_tadir BY obj_name.

    ENDIF.

    IT_FIELD-COLUMN = 'OBJECT NAME'.

    APPEND IT_FIELD.

    CLEAR IT_FIELD.

    IT_FIELD-COLUMN = 'DEV CLASS'.

    APPEND IT_FIELD.

    CLEAR IT_FIELD.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    FILENAME = 'D:\Documents and Settings\gnj192\My Documents\TEST'

    FILETYPE = 'DAT'

    DAT_MODE = 'X'

    TABLES

    DATA_TAB = IT_TADIR

    FIELDNAMES = IT_FIELD

    EXCEPTIONS

    FILE_WRITE_ERROR = 1

    NO_BATCH = 2

    GUI_REFUSE_FILETRANSFER = 3

    INVALID_TYPE = 4

    NO_AUTHORITY = 5

    UNKNOWN_ERROR = 6

    HEADER_NOT_ALLOWED = 7

    SEPARATOR_NOT_ALLOWED = 8

    FILESIZE_NOT_ALLOWED = 9

    HEADER_TOO_LONG = 10

    DP_ERROR_CREATE = 11

    DP_ERROR_SEND = 12

    DP_ERROR_WRITE = 13

    UNKNOWN_DP_ERROR = 14

    ACCESS_DENIED = 15

    DP_OUT_OF_MEMORY = 16

    DISK_FULL = 17

    DP_TIMEOUT = 18

    FILE_NOT_FOUND = 19

    DATAPROVIDER_EXCEPTION = 20

    CONTROL_FLUSH_ERROR = 21

    OTHERS = 22

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    hope this helps u.

    cheers

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2007 at 12:19 PM

    Hi,

    pass all the column names into an internal table and pass the internal table to the parameter <b>FIELDNAMES</b> of GUI_DOWNLOAD function module

    TABLES

    <b>DATA_TAB = itab

    FIELDNAMES = it_fieldnames</b>

    <b>PLS CHECK THE SIMPLE CODE BELOW...</b>

    **tables work area

    TABLES: mara.

    • internal table for output data

    data: begin OF itab occurs 0,

    matnr like mara-matnr,

    end of itab.

    **internal table for field names

    data : begin of IT_FIELDNAMES occurs 0,

    name(100),

    end of IT_FIELDNAMES.

    IT_FIELDNAMES-name = 'MATNR'.

    APPEND IT_FIELDNAMES.

    select matnr from mara into table itab UP TO 10 ROWS.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    FILENAME = 'C:\Documents and Settings\sampath\Desktop\flatfile.txt'

    FILETYPE = 'ASC'

    <b>TABLES

    DATA_TAB = itab

    FIELDNAMES = IT_FIELDNAMES</b>

    regards,

    Ashok Reddy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 23, 2007 at 09:20 AM

    fill tables fieldnames

    eg.

    types : begin of it_field,

    fldname(20) type c,

    end of it_field.

    data : itab_fields type standard table of it_field with header line.

    itab_field-fldname = ''field name" .

    append itab_field.

    ....

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = 'C:\download.xls'

    filetype = 'ASC'

    append = 'X'

    write_field_separator = 'X'

    TABLES

    data_tab = itab_header[]."Header data in this table

    fieldname = itab_fields " fill col name .

    Add comment
    10|10000 characters needed characters exceeded