Skip to Content
0
Former Member
Aug 30, 2007 at 02:45 PM

Need a small change in this code, GUI_DOWNLOAD. FILE NAME ??

350 Views

Hi All,

I want to write a program to download data from VBAK. I have tried this and working fine but I have made my file name constant. Instead I want user to make a choice of file name and its location to save.

Also please review this code and let me know, how can I improve my programming skills...

&----


*& Report ZSAI1

*&

&----


*&

*&

&----


REPORT ZSAI1.

tables : vbak.

data : begin of it_vbak occurs 0,

vbeln like vbak-vbeln,

auart like vbak-auart,

audat like vbak-audat,

end of it_vbak.

data : i_filename type string value 'C:\Documents and Settings\venki\Desktop\text.xls'.

selection-screen begin of block sc1 with frame.

select-options : s_vbeln for vbak-vbeln.

selection-screen Skip 3.

parameters : i_excel radiobutton group Rb1,

i_text radiobutton group Rb1.

selection-screen end of block sc1.

perform select_dt.

.

if i_excel = 'X'.

perform download_excel.

endif.

&----


*& Form download_excel

&----


FORM download_excel .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = i_filename

FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = it_vbak

  • FIELDNAMES =

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.

ENDFORM. " download_excel

&----


*& Form download_text

&----


FORM download_text .

ENDFORM. " download_text

&----


*& Form select_dt

&----


FORM select_dt .

select vbeln auart audat from vbak

into table it_vbak where

vbeln in s_vbeln.

ENDFORM. " select_dt

Thank You once gain.

Regards

Venkat

Message was edited by:

venkat Kumbham