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: 

Need to include header in csv file while using GUI_DOWNLOAD

Former Member
0 Kudos

Hi,

Iam using GUI_DOWNLOAD for downloading certain texts,its working fine.now i need to include the header(i'e) some text say 'This is a error file'at the top.how can i do this?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi swaminathan,

1. simple

2. use this code (just copy paste)

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'

TABLES

data_tab = t001.

*----


IMPORTANT

INSERT 'This is an error File'

INTO t001 INDEX 1.

BREAK-POINT.

regards,

amit m.

5 REPLIES 5

Former Member
0 Kudos

Hi swaminathan,

1. simple

2. use this code (just copy paste)

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'

TABLES

data_tab = t001.

*----


IMPORTANT

INSERT 'This is an error File'

INTO t001 INDEX 1.

BREAK-POINT.

regards,

amit m.

former_member223537
Active Contributor
0 Kudos

Hi,

You have to use GUI_DOWNLOAD twice. In the first call to GUI_DOWNLOAD, Open the file & pass header data internal table.

In the second call to GUI_DOWNLOAD open the same file in APPEND mode & pass the internal table line item data.

Best regards,

Prashant

Message was edited by: Prashant Patil

Former Member
0 Kudos

Hello Swaminathan,

For downloading you have the std FM GU_DOWNLOAD. You can append the first line as you want followed by rest of texts. For this the internal table should have the field as one continuous char.

With this u have to download it only once.

former_member188685
Active Contributor
0 Kudos
REPORT  ZTEST12347                              .


DATA: BEGIN OF ITAB OCCURS 0,
        VBELN LIKE VBAK-VBELN,
        POSNR LIKE VBAP-POSNR,
      END OF ITAB.


SELECT VBELN
       POSNR
      FROM VBAP
      UP TO 20 ROWS
      INTO TABLE ITAB.
DATA: IT_LINE LIKE TLINE OCCURS 0 WITH HEADER LINE.
IT_LINE-TDLINE = 'this is error file'.
append it_line.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                = 'C:test.txt'
  TABLES
    DATA_TAB                = IT_LINE
  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.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                = 'C:test.txt'
    APPEND                  = 'X'
  TABLES
    DATA_TAB                = ITAB
  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.

Former Member
0 Kudos

THANKS AMIT...

ITS WORKING FINE.