‎2007 Jun 11 8:13 AM
hi friends
i make one file like dat.i use open data set so dat file created
so my question is that where this file is created ?
it will create on applicationserver?
bcoz its not create on my local drive.
‎2007 Jun 11 8:16 AM
Hi,
OPEN DATASET stmt is used to open a file on applicaiton server either for reading or writing.
Eg: OPEN DATASET <dsn> FOR [OUTPUT/INPUT] ....
OUTPUT in above stmt identifies that we are opening the file for writing.
INPUT in above stmt identified that we are opening the file for output.
Reading Data from Application Server:
open dataset fname for input in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', fname.
else.
do.
read datasset fname into <wa>.
if sy-subrc ne o.
exit.
else.
append <wa> to itab.
endif.
close dataset fname.
enddo.
endif.
Writing Data to Application Server:
open dataset fname for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', fname.
else.
loop at itab.
transfer itab to fname.
endloop.
close dataset fname.
endif.
Hope this info gives you some idea.
Regards
‎2007 Jun 11 8:17 AM
Hi,
yes this fill will be created in the applicationn server . You can see
that file using transaction AL11 .
***do reward if usefull
vijay
‎2007 Jun 11 9:01 AM
thanks for reply
but if i want make file on my local drive for that what coding i do?
‎2007 Jun 11 9:13 AM
Hi,
PARAMETERS : p_file TYPE localfile.
<b>else hardcode value for p_FILE WHICH IS FOUND IN LOCAL DRIVE</b>
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
*errror msg.
ELSE.
LOOP AT gt_fichier INTO gs_fichier.
TRANSFER gs_fichier TO p_file.
ENDLOOP.
CLOSE DATASET p_file.
Regards,
Sooness
‎2007 Jun 11 9:30 AM
hi prasanth,
use FM gui_downlaod to down load to your pc.
reward points if userful.
regards,
seshu.
‎2007 Jun 11 11:28 AM
hi
i done all this things.
but i can't store file in my local drive and perticular folder.
so what can i do?
plz reply me.
‎2007 Jun 11 8:17 AM
Hi
Yes
A file will be created on Application server.
We use DATASET concept for reading, writing, transfering data from Local to Application servers.
see the sample code
ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.
&----
*& Report ZUPLOADTAB *
*& *
&----
*& Example of Uploading tab delimited file *
*& *
&----
REPORT zuploadtab .
PARAMETERS: p_infile LIKE rlgrap-filename
OBLIGATORY DEFAULT '/usr/sap/'..
DATA: ld_file LIKE rlgrap-filename.
*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.
*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5) type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.
*String value to data in initially.
DATA: wa_string(255) type c.
constants: con_tab TYPE x VALUE '09'.
*If you have Unicode check active in program attributes then you will
*need to declare constants as follows:
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
************************************************************************
*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.
*!! Text data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.
Reward points for useful Answers
Regards
Anji
‎2007 Jun 11 8:19 AM
hi prashant,
yeah it definatly create file in application server,
to view this file,
go to T.code al11,
select dir_home folder, here u can find your open datset file name.
reward points if helpful,
regards,
seshu.
‎2007 Jun 11 8:21 AM
hi,
for opening the file which resides on the application server we use OPEN DATASET
for Creating use this code
*-- Generate Absolute File Name --*
PERFORM GENERATE_FILEPATH USING 'I'
'O'
' '
V_PATH_OUT.
We concatenate the file path and file name
CONCATENATE V_PATH_OUT P_FILENM INTO P_FNAME.
We open the file (dataset) for output on the server
OPEN DATASET P_FNAME FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
PERFORM SSC_ERROR_HANDLER
USING
'ZA' "Message Id
'005' "Message Number
'E' "Message type
P_FNAME "Message 1
' ' "Message 2
' ' "Message 3
' ' "Message 4
' ' "Mail the error message or no
'X' "log the error Message or no
' ' "Plant
' '. "Company code
EXIT.
ELSE.
We loop at the output table and write out the data to the server file
IF P_DETAIL EQ 'X'.
LOOP AT I_OUT_REC.
TRANSFER I_OUT_REC TO P_FNAME LENGTH 256.
ENDLOOP.
ELSEIF P_SUM EQ 'X'.
LOOP AT D_OUT_REC.
TRANSFER D_OUT_REC TO P_FNAME LENGTH 256.
ENDLOOP.
elseif p_sumven eq 'X'.
LOOP AT V_OUT_REC.
TRANSFER V_OUT_REC TO P_FNAME LENGTH 256.
ENDLOOP.
ENDIF.
CLOSE DATASET P_FNAME.
‎2007 Jun 11 9:34 AM
Datasets whether open, read or write,whatever they are, statements are always used for Application Servers and GUI_UPLOAD and GUI_DOWNLOAD are used for Presentation Servers. So your file will be created on Application Server. Go to AL11 and double click on DIR_HOME to view the file.
‎2007 Jun 11 9:47 AM
hi,
What ever the file u created by using OPENDATA SET < name > FOR OUTPUT,
CLOSEDATA SET <name>.
That file created deffinetly on Application server.
<b>for creating file on local disc, call these FM</b>
download,
ws_download
gui_download
or call this method...
call method cl_gui_fronend_services=>gui_download
exporting
filename = ' ' "provide path where u want to create
file type = 'ASC'
regards,
Ashokreddy.