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 down load file from bdc

Former Member
0 Kudos

hi

i hav one dout, pls any one give me clear picture

"how to down load my data from BDC" i'm using flat file

pls tell me asap

regards

trupti.

7 REPLIES 7

Former Member
0 Kudos

Hi Trupti...

To get data from your<b> Flat File to Internal table</b>...use Function module <b>GUI_UPLOAD</b> as follows..

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = LOC_FILEPATH

FILETYPE = 'ASC' " for .TXT file

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = ITAB1.

and To get data from your<b> Internal table to FLat File</b>...use Function module <b>GUI_DOWNLOAD</b> as follows...

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = FILENAMEPATH " where you want to save

FILETYPE = 'ASC'

TABLES

DATA_TAB = ITAB1[] " table which you wnat to save to flat file.

<b>Reward Points if helpful,</b>

Regards,

Tejas

Former Member
0 Kudos

Hi,

use this function module.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:/BHARAT/VEND.TXT'(flat file path)

FILETYPE = 'ASC' (flat file type)

HAS_FIELD_SEPARATOR = 'X'(if the file has any field seperator)

TABLES

DATA_TAB = ITAB.(inernal table)

regards,

bharat.

Message was edited by:

Bharat Kalagara

former_member404244
Active Contributor
0 Kudos

Hi,

u can use the below FM

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = file path(give ur desktop or someother location)

FILETYPE = 'ASC'

filed_seperator = 'X'

TABLES

DATA_TAB = ITAB.(inernal tablename)

regards,

Nagaraj

Former Member
0 Kudos

<u><b>Upload a file from Frontend to BDC</b></u>

1) Use function module 'UPLOAD' or 'GUI_UPLOAD'

<u><b>Download a file from BDC to frontend</b></u>

<u><b>If you have the data in internal table,</b></u>

Then follow the below step.

1) Create/locate the diretory in frontend using function module

<b>TMP_GUI_CREATE_DIRECTORY</b>

2)Using function module <b>WS_DOWNLOAD or GUI_DOWNLOAD</b> download to the respective directory.

<u><b>If you have data in the list format then</b></u>

1) Get the list to the internal table using function module 'LIST_TO_ASCI'.

2) Create/locate the diretory in frontend using function module

<b>TMP_GUI_CREATE_DIRECTORY</b>

3)Using function module <b>WS_DOWNLOAD or GUI_DOWNLOAD</b> download to the respective directory.

If is useful,please reward.

Regards,

Vijay

Former Member
0 Kudos

Hi Trupti,,,

Please use GUI_DOWNLOAD function module....

Regards,

Kali Pramod

Former Member
0 Kudos

HI..,

I didnt get ur question .. but just check this program..

U can directly copy and execute the code !!..

<b>

it downloads the data in internal table to a flat file.. and again uploads the file data into another interanal table of same structure..</b>

tables:

spfli.

field-symbols : <fs>, <fs1>.

data:

w_line(1000),

w_field(20) type c,

wa_spfli type spfli.

data:

begin of fs_spfli,

carrid type spfli-carrid,

connid type spfli-connid,

countryfr type spfli-countryfr,

countryto type spfli-countryto,

fltime type spfli-fltime,

end of fs_spfli.

data :

t_file like standard table

of w_line

initial size 0.

data:

t_spfli like

standard table

of fs_spfli

initial size 0.

data:

t_spfli_up like

standard table

of fs_spfli

initial size 0.

select carrid

connid

countryfr

countryto

fltime

into corresponding fields of table t_spfli

from spfli.

call function 'GUI_DOWNLOAD'

exporting

  • BIN_FILESIZE =

filename = 'D:\file.txt'

filetype = 'DAT'

  • 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 = t_spfli

  • 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.

clear t_spfli[].

call function 'GUI_UPLOAD'

exporting

filename = 'D:\file.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = t_spfli_up

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

if sy-subrc <> 0.

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

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

endif.

clear fs_spfli.

loop at t_spfli_up into fs_spfli.

do.

assign component sy-index of structure fs_spfli to <fs>.

if sy-subrc ne 0.

exit.

endif.

write <fs>.

enddo.

skip.

endloop.

reward if it helps u..

sai ramesh

raymond_giuseppi
Active Contributor
0 Kudos

There is an option to download BDC data in SM35

Is it what you want?

Regards