‎2008 Jan 15 8:53 AM
HI,
How to download data from application server?
What is the use of AL11?
‎2008 Jan 15 8:58 AM
we can see the files in application server using al11 transaction.
we use syntax for download data from apllication server.
open dataset file for input..
read dataset file into itab.
.....
.....
close dataset file.
‎2008 Jan 15 9:08 AM
HELLO,
Refer to the code below.
Use function GUI_DOWNLOAD to download required file into int. table.
Then use the following code to read and write into appl. Server
data: p_path type rlgrap-filename value file_path.
constant : file_path type rlgrap-filename
value 'D:\usr\sap\RES\DVEBMGS00\work'.
( This path is taken from AL11).
This code is to read file from Appl. Server.
open dataset p_path for input in text mode encoding default.
do.
read dataset p_path into result.
if sy-subrc <> 0.
close dataset p_path.
message i007.
exit.
else.
append result to i_prog1.
endif.
enddo.
To write file into appl. Server.
concatenate p_path '\' 'FILE1' into p_path.
open dataset p_path for output in text mode encoding default.
if sy-subrc <> 0.
close dataset p_path.
message e004.
exit.
endif.
loop at i_prog into wa_prog.
transfer wa_prog to p_path.
endloop.
close dataset p_path.
message i006.
‎2008 Jan 16 5:43 AM
Load this program in the system and check:
&----
*& Report ZAPPSERVER01
*&
&----
*&
*&
&----
REPORT ZAPPLSERVER message-id FB.
************************************************************************
Constants
constants :c_mask(80) type c value ',.,..', " Mask
c_file_type(10) type c value 'ASC', " File type
c_mode(1) type c value 'L'. " Mode
Internal tables *
data: begin of i_file occurs 0,
field(3000) type c,
end of i_file.
data : v_msg(100),
struct_file like i_file occurs 0.
Parameters
parameters: p_fpath type filename-FILEINTERN obligatory,
p_lpath type localfile,
p_upload as checkbox default 'X',
p_dload as checkbox,
p_delete as checkbox.
************************************************************************
Check selection-screen entries *
************************************************************************
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lpath.
PERFORM get_file CHANGING p_lpath.
************************************************************************
Main *
************************************************************************
Start of selection
start-of-selection.
if p_upload = 'X'.
Upload to app server
perform upload_to_appserver.
endif.
if p_dload = 'X'.
Download to desktop
perform download_to_desktop.
endif.
if p_delete = 'X'.
Delete file on app server
delete dataset p_fpath.
if sy-subrc = 0.
message s000 with 'File deleted'.
endif.
endif.
************************************************************************
*----
Set file path of local machine
*----
FORM get_file CHANGING file_out.
DATA: l_filename TYPE localfile. "Local file for upload/download
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
mask = c_mask
mode = c_mode
IMPORTING
filename = l_filename
EXCEPTIONS
inv_winsys = 01
no_batch = 02
selection_cancel = 03
selection_error = 04.
p_lpath = l_filename.
ENDFORM. "get_file
&----
*& Form UPLOAD_TO_APPSERVER
&----
Upload local file to app server
----
form upload_to_appserver .
data: l_lpath type string.
l_lpath = p_lpath.
refresh i_file.
clear i_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_lpath
FILETYPE = c_file_type
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = 'X'
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = SPACE
CHECK_BOM = '#'
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = i_file
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.
open dataset p_fpath for output in text mode encoding default
message v_msg.
if sy-subrc = 0.
loop at i_file. " into struct_file.
if not i_file is initial.
transfer i_file to p_fpath.
endif.
endloop.
else.
message e000 with 'File cannot be opened for output'.
endif.
close dataset p_fpath.
endform. " UPLOAD_TO_APPSERVER
&----
*& Form DOWNLOAD_TO_DESKTOP
&----
text
----
--> p1 text
<-- p2 text
----
form download_to_desktop .
open dataset p_fpath for input in text mode
encoding default
message v_msg.
if sy-subrc = 0.
refresh : i_file.
do.
read dataset p_fpath into i_file.
if sy-subrc = 0.
append i_file to i_file.
else.
exit.
endif.
enddo.
else.
message e000 with 'File cannot be opened'.
endif.
close dataset p_fpath.
call function 'DOWNLOAD'
EXPORTING
filename = p_lpath
TABLES
data_tab = i_file.
endform. " DOWNLOAD_TO_DESKTOP
cheers
Aveek
‎2008 Jan 16 8:52 AM
HI Martin,
AL11 tranaction is the application server path that means we can view and reterive the application server data in this transaction.
i will send a sample code for download data from application server.
CODE:
REPORT YBDC_DATASETS_INPUT_AL11.
----
Internal Table
----
DATA: BEGIN OF gt_data OCCURS 0,
text(50),
END OF gt_data.
----
OPEN THE DATASET
----
OPEN DATASET 'ZBDCDEMO' FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATA FROM THE DATASET(APPSERVER) AND PLACE THEM IN Internal Table
CLEAR : gt_data. "Clear Header Line
READ DATASET 'ZBDCDEMO' INTO gt_data.
IF sy-subrc = 0.
APPEND gt_data.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
----
Display the Data
----
LOOP AT gt_data.
WRITE: / gt_data-text.
ENDLOOP.
----
Display the Data
----
CLOSE DATASET 'ZBDCDEMO'.
Reward points if helpful.
Kiran Kumar.G.A
Have a Nice Day..
Edited by: KIRAN KUMAR on Jan 16, 2008 9:53 AM
‎2008 Jan 18 1:23 PM
Hi,
Besides several ABAP approaches, you can also up- and download using these transactions:
CG3Y File download from Appp server to Client
CG3Z File upload to App Server
With AL11 ypou can browse folder content at server side & you can view (text)file contents.
regards and reward if usefull,
Joris