Application Development and Automation 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: 
Read only

Fieldnames in GUI_Download function module

Former Member
0 Likes
1,829

Dear All,

In the following code im passing the parameter it_fieldnames into 'c:/text.txt' file along with the data but im not able to get the fieldnames in to it, it is getting only data from the it_final. can any1 tell me what is the problem.

call function 'GUI_DOWNLOAD'

exporting

filename = 'c:/text.txt'"p_fname

filetype = 'ASC'

  • append = 'X'

write_field_separator = 'X'

tables

data_tab = it_final

fieldnames = it_fieldnames

exceptions

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5.

case sy-subrc.

when 0.

when 1.

write : / 'Error in opening file ', fname.

when 2.

write : / 'Error in writing file ', fname.

when 3.

write : / 'The file type is not valid'.

when others.

write : / 'The file could not be transferred'.

endcase.

endform. " f_submit_layout

&----


*& Form VEND_FIELDNAMES

&----


  • text

----


form tab_fieldnames.

it_fieldnames-name = 'Sl No'.

append it_fieldnames.

it_fieldnames-name = 'Credit Acc'.

append it_fieldnames.

it_fieldnames-name = 'credit Doc'.

append it_fieldnames.

it_fieldnames-name = 'Credit Ref'.

append it_fieldnames.

it_fieldnames-name = ' '.

append it_fieldnames.

it_fieldnames-name = 'Amount'.

append it_fieldnames.

it_fieldnames-name = 'SSI'.

append it_fieldnames.

it_fieldnames-name = 'Debit Bankcode'.

append it_fieldnames.

it_fieldnames-name = 'Debit BrCode'.

append it_fieldnames.

it_fieldnames-name = 'Debit Acc'.

append it_fieldnames.

it_fieldnames-name = 'Debit Cheque'.

append it_fieldnames.

it_fieldnames-name = ' '.

append it_fieldnames.

it_fieldnames-name = ' '.

append it_fieldnames.

it_fieldnames-name = 'Batch date'.

append it_fieldnames.

it_fieldnames-name = ' '.

append it_fieldnames.

endform. "VEND_FIELDNAMES

Thanks a lot,

Santosh Kotra.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
960

Hi santosh,

1. Exactly for the same purpose

2. There is an independent subroutine (FORM)

in my program,

which will download any table,

to the specified filename

(along with FIELDNAMES)

3. just copy paste

4.

report abc.

*----


data : itab like table of t001 with header line.

*----


select * from t001 into table itab.

perform mydownload tables itab using 'D:\t001.txt'.

*----


  • INDEPENDENT FORM

*----


form mydownload tables ptab using filename.

*----


DAta

DATA : components LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.

DATA : allfields(300) TYPE c.

DATA : fld(100) TYPE c.

data : begin of htab occurs 0,

allfields(300) type c,

end of htab.

*----


Get component list

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = sy-repid

fieldname = 'ITAB'

TABLES

components = components.

*----


construct

LOOP AT components.

CONCATENATE components-compname

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO fld.

CONCATENATE allfields fld INTO allfields .

ENDLOOP.

htab-allfields = allfields.

append htab.

*----


download first field list

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'D:\t001.txt'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = htab

.

*----


then download file data

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = filename

APPEND = 'X'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ptab

.

endform.

regards,

amit m.

Hi santosh,

1. Exactly for the same purpose

2. There is an independent subroutine (FORM)

in my program,

which will download any table,

to the specified filename

(along with FIELDNAMES)

3. just copy paste

4.

report abc.

*----


data : itab like table of t001 with header line.

*----


select * from t001 into table itab.

perform mydownload tables itab using 'D:\t001.txt'.

*----


  • INDEPENDENT FORM

*----


form mydownload tables ptab using filename.

*----


DAta

DATA : components LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.

DATA : allfields(300) TYPE c.

DATA : fld(100) TYPE c.

data : begin of htab occurs 0,

allfields(300) type c,

end of htab.

*----


Get component list

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = sy-repid

fieldname = 'ITAB'

TABLES

components = components.

*----


construct

LOOP AT components.

CONCATENATE components-compname

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO fld.

CONCATENATE allfields fld INTO allfields .

ENDLOOP.

htab-allfields = allfields.

append htab.

*----


download first field list

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'D:\t001.txt'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = htab

.

*----


then download file data

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = filename

APPEND = 'X'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ptab

.

endform.

regards,

amit m.

4 REPLIES 4
Read only

Former Member
0 Likes
961

Hi santosh,

1. Exactly for the same purpose

2. There is an independent subroutine (FORM)

in my program,

which will download any table,

to the specified filename

(along with FIELDNAMES)

3. just copy paste

4.

report abc.

*----


data : itab like table of t001 with header line.

*----


select * from t001 into table itab.

perform mydownload tables itab using 'D:\t001.txt'.

*----


  • INDEPENDENT FORM

*----


form mydownload tables ptab using filename.

*----


DAta

DATA : components LIKE rstrucinfo OCCURS 0 WITH HEADER LINE.

DATA : allfields(300) TYPE c.

DATA : fld(100) TYPE c.

data : begin of htab occurs 0,

allfields(300) type c,

end of htab.

*----


Get component list

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = sy-repid

fieldname = 'ITAB'

TABLES

components = components.

*----


construct

LOOP AT components.

CONCATENATE components-compname

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO fld.

CONCATENATE allfields fld INTO allfields .

ENDLOOP.

htab-allfields = allfields.

append htab.

*----


download first field list

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'D:\t001.txt'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = htab

.

*----


then download file data

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = filename

APPEND = 'X'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ptab

.

endform.

regards,

amit m.

Read only

Former Member
0 Likes
960

Hi Santosh,

For ASC files, you can not use this option.

Only for the DBF file type.

Optional table with column names for the individual columns.

- 'DBF': The column names are entered in the structure definition of the DBF file.

- 'DAT': An additional line with the column name is inserted at the beginning of the table.

See also the documentation of this function module.

Regards,

Remco Broen

Read only

0 Likes
960
ex---
DATA : ITAB TYPE MARA OCCURS 0 WITH HEADER LINE.
 
SELECT * INTO ITAB
         FROM MARA
         UP TO 10 ROWS.
         APPEND ITAB.
ENDSELECT.
 
DATA : BEGIN OF ITAB1 OCCURS 0,
         LINE(50) TYPE C,
       END OF ITAB1.
 
ITAB1-LINE = 'field1 description'.
APPEND ITAB1.
ITAB1-LINE = 'field2 desc'.
APPEND ITAB1.
ITAB1-LINE = 'field3 desc'.
APPEND ITAB1.
*--and so on you have to add up the records in itab1.
 
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = 'c:abc.xls'
   FILETYPE                        = 'ASC'
   WRITE_FIELD_SEPARATOR           = 'X'
* IMPORTING
*   FILELENGTH                      =
  TABLES
    DATA_TAB                        = ITAB
   FIELDNAMES                      = ITAB1
 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.

Read only

Former Member
0 Likes
960

Thanks a lot Amit...its done.