05-27-2008 4:42 PM
1.How to transfer the data from presentation layer to application layer and vice-versa?
05-27-2008 4:51 PM
05-27-2008 5:07 PM
hi,
Using GUI_UPLOAD , you can take the data into internal table. Read this table and transfer to DATA SET.
Use
OPEN DATA SET
TRANSFER to DATASET
APPEND TO DATASET
CLOSE DATASET
Regards
Sandeep REddy
05-27-2008 5:24 PM
Hi Kiran,
I am giving some description and code to do so.
Steps:
--> Use function module GUI_UPLOAD to upload the file from presentation server to an internal table.
--> Use OPEN DATASET, TRANSFER and CLOSE DATASET statements to put the internal table to a file on the application server.
Transactions to use:
CG3Z : Presentation (desktop) to Application Server.
CG3Y : Application Server to Presentation Server.
Code Snippets:
Retrieve Data file from Application server(Upload from Unix)*
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
OPEN DATASET i_file FOR INPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE e999(za) WITH 'Error opening file' i_file.
ENDIF.
DO.
Reads each line of file individually
READ DATASET i_file INTO wa_datatab.
Perform processing here
.....
ENDDO.
Download internal table to presentation server file(PC)*
DATA: ld_filename TYPE string,
Pre version 4.7 declaration e_file like rlgrap-filename.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
call function 'GUI_DOWNLOAD'
exporting
filename = ld_filename
filetype = 'ASC'
tables
data_tab = it_datatab[]
exceptions
file_open_error = 1
file_write_error = 2
others = 3.
Download internal table to presentation server file(PC)*
Separating fields/columns by a tab*
DATA: ld_filename TYPE string,
Pre version 4.7 declaration e_file like rlgrap-filename.
DATA: begin of it_datatab occurs 0,
col1(50) type c,
col2(50) type c,
col3(50) type c,
etc....
end of it_datatab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_filename
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[]
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
Retrieve data file from presentation server(Upload from PC)*
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = i_file
filetype = 'ASC'
TABLES
data_tab = it_datatab "ITBL_IN_RECORD[]
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
Hope this prove to be helpful to you.
Please Reward Points if any of the above points are helpful.
Regards,
Kalyan Chakravarthy