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 download data to presentation server using open dataset

Former Member
0 Kudos
1,332

Dear Abapguru,

is it possible to download data to presentaion server using open dataset?

as some one told me to run in background .but then also i am not finding the end result.

11 REPLIES 11

Former Member
0 Kudos
206

Hi Rajesh,

Try to call GUI_DOWNLOAD FM.

Pass the data through internal table into the local file on desktop.

This will give u the result.

gui_Download:

REPORT ZSR_BDC_DOWNLOAD.

TABLES : LFA1.

SELECT-OPTIONS : S_LIFNR FOR LFA1-LIFNR.

DATA : BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

LAND1 LIKE LFA1-LAND1,

END OF ITAB.

SELECT LIFNR LAND1 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN S_LIFNR.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'c:\d.txt'

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 = ITAB

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

WRITE 😕 'not downloaded'.

ENDIF.

Regards,

Priyanka.

Former Member
0 Kudos
206

hi,

parameters: p_file like rlgrap-filename obligatory
default '/usr/sap/upload.xls'.

types: begin of t_data,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
werks like vbap-werks,
megne like vbap-zmeng,
end of t_data.
data: it_data type standard table of t_data,
wa_data type t_data.

open dataset p_file for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', p_file.
else.
do.
read dataset p_file into wa_data.
if sy-subrc ne 0.
exit.
else.
append wa_data to it_data.
endif.
enddo.
close dataset p_file.
endif.

Regards

Reshma

0 Kudos
206

after giveng file path as

C:\Documents and Settings\bcone-1753\My Documents\abc1.dat

content of file is

-


abc

-


but it is giving sy-subrc as 4 while read dataset

former_member588853
Active Contributor
0 Kudos
206

hi,

Open dataset is use to upload download in application servers/ftp servers..

for presentation you need to use FM GUI_DOWNLOAD..and there are some other FM which does the same..to downlaod into presentation

rewards if useful,

regards,

nazeer

Former Member
0 Kudos
206

Hi,

In general we use OPEN DATASET for accessing files in Application Server.

If u want to download data to presentation server we have to use GUI_DOWNLOAD but using this FM we cannot do background job scheduling.

For this OPEN DATASET is used.

0 Kudos
206

Thank you very much ,

my main problem is regarding background sheduling only.

so will it be possible to download file on presentaion server if i execute same in background ?

0 Kudos
206

0 Kudos
206

Hello Rajesh

Two brief remarks:

(1) Instead of using function modules use methods GUI_DOWNLOAD and GUI_UPLOAD of class <b>CL_GUI_FRONTEND_SERVICES</b> for data handling towards the presentation server (i.e. the local PC) -> <i>Unicode</i>-compatible.

(2) In the background the SAP system does not "anything" about the presentation server. Thus, you cannot download or upload data to and from the presentation server in background tasks.

Regards

Uwe

Former Member
0 Kudos
206

Hi Rajesh

We use Open DATASET for uploading /downloading to/from Application Server.

To Upload or Download data to presentation server we use function module

Gui_upload/download.

Former Member
0 Kudos
206

First Read data from Application Server using Open Dataset

like this

<b>parameters : p_set like rlgrap-filename.

data : begin of i_vbak occurs 0,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

erzet like vbak-erzet,

end of i_vbak.

OPEN DATASET P_SET FOR INPUT IN TEXT MODE ENCODING DEFAULT.

if sy-subrc <> 0.

write : 'file cannot be opened'.

endif.

do.

read dataset p_set into i_vbak.

if sy-subrc <> 0.

exit.

endif.

append i_vbak.

clear i_vbak.</b>

Now after populating i_vbak use FM Gui_download to download its contents to a Flat file By passing this table in Tables of that Function Module.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'C:\Documents and Settings\arpit\Desktop\arpit1.TXT'

FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

<b>TABLES

DATA_TAB = i_vbak</b>

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

If it satisfies your need

then Pls Reward Points.