‎2008 Mar 05 12:27 AM
Hi all,
I am downloading a file through 'Open dataset' and 'Close dataset'. to the path: 'H:\test\filename.csv'. This is the local drive.
I have to use dataset commands as I cannot download by 'GUI_DOWNLOAD' function in background job. But the file is not downloaded by dataset commands.
Can you please advise where the issue could be. When I follow through in debug, there is no error displayed. Or is there any other way to download file in background. Thanks.
Regards,
FS
‎2008 Mar 05 12:49 AM
Hi,
Open Dataset command is used to access files on the
application server not the local desktop.
If you are running a job in backgroup it runs on the SAP server
not the local frontend.
Regards
Sudhir Atluru
‎2008 Mar 05 12:49 AM
Hi,
Open Dataset command is used to access files on the
application server not the local desktop.
If you are running a job in backgroup it runs on the SAP server
not the local frontend.
Regards
Sudhir Atluru
‎2008 Mar 05 12:54 AM
thanks for you r reply. Actually I also tried to send it to a server directory. But still it did not produce any file. Can you please send me some sample code. Thanks.
Regards,
FS
‎2008 Mar 05 1:24 AM
Hi FS,
Just search the forum there are lots of sample code on OPEN DATASET. Even if you just do F1 on this keyword you will get the info.
Regards,
Atish
‎2008 Mar 05 1:40 AM
Actually I am using file type .cma (comma delimited). Is this the issue that file is not getting downloaded by dataset commands. If yes, then what type should I use. Thanks.
Regards,
FS
‎2008 Mar 05 1:55 AM
Hi,
No it can't be the issue. There must be something wrong in your coding. paste your whole code.
Regards,
Atish
‎2008 Mar 05 2:53 AM
p_file = G:\ar_file.cma
open dataset p_file FOR OUTPUT IN binary mode message mess.
also tried above command with "IN TEXT MODE *ENCODING DEFAULT MESSAGE mess"
IF sy-subrc = 0.
loop at pt_export into gs_export.
TRANSFER gs_export TO p_file.
endloop.
endif.
close dataset p_file.
write: / 'Downloaded File', P_FILE(50),
(5) num_lines, 'lines'.
Regards,
FS
‎2008 Mar 05 3:00 AM
FS,
You want to read the data from file .So use like below.
DATA FNAME(60) VALUE 'G:\ar_file.cma'.
DATA: TEXT2(500).
OPEN DATASET FNAME FOR INPUT IN TEXT MODE.
DO.
READ DATASET FNAME INTO TEXT2 .
WRITE: / TEXT2.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET FNAME.
‎2008 Mar 05 3:19 AM
Actually I want to download file to the server and I pasted my code in the above section. Please advise.
Regard,
FS
‎2008 Mar 05 3:21 AM
FS,
This is the simple code for EX;
DATA FNAME(60) VALUE 'myfile'.
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
TYPES ITAB TYPE LINE OCCURS 10.
DATA: LIN TYPE LINE,
TAB TYPE ITAB.
DO 5 TIMES.
LIN-COL1 = SY-INDEX.
LIN-COL2 = SY-INDEX ** 2.
APPEND LIN TO TAB.
ENDDO.
OPEN DATASET FNAME FOR OUTPUT.
LOOP AT TAB INTO LIN.
TRANSFER LIN TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT.
DO.
READ DATASET FNAME INTO LIN.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE: / LIN-COL1, LIN-COL2.
ENDDO.
CLOSE DATASET FNAME.
‎2008 Mar 05 3:22 AM
Hi FS,
p_file = G:\ar_file.cma This can't be the file from application server. Just check with the basis for application server folder.
application server file starts like /<foldername>/file name.
Regards,
Atish
‎2008 Mar 05 4:09 AM
looks like I am using the server directory path incorrectly:
Can you please correct it:
previously I used : G:\ar_file.txt
I tried :
/serv01/folder1/folder2/ar_file.txt
(serv01 = servername for G:\ drive)
But this is still not working. Can you please show me the correct path to use for the dataset command. Thanks.
Regard,
FS
‎2008 Mar 05 4:19 AM
FS,
Goto Tcode AL11 ther you can find all directories in Appl;ication server.But one thing you should have authoriztion to write file in directory.For that contact basis person.otherwise take any directory try to write file there.Do like trail and error method.
Ex; filepath :
/data/sapdata/reg_billing_prod_mda/ test.txt
‎2008 Mar 05 4:58 AM
FS,
Following is the program to find the directories available in Application Server.
REPORT ZFINDDIRECTORIES .
parameters: p_path like DXFIELDS-LONGPATH.
data: lv_opath like dxfields-longpath.
data: ev_server_name like btctgtsrvr-srvname,
server_name like msxxlist-name.
call 'C_SAPGPARAM'
id 'NAME' field 'rdisp/myname'
id 'VALUE' field ev_server_name.
if sy-subrc <> 0.
clear ev_server_name.
endif.
call function 'F4_DXFILENAME_TOPRECURSION'
exporting
i_location_flag = 'X'
i_server = server_name
i_path = p_path
importing
o_path = lv_opath .
write:/ lv_opath.
K.Kiran.
‎2008 Mar 05 4:57 AM
Thanks guys,
I can send the files correctly to the application server. Can I use dataset command to Download and Upload from other servers within the network. Or is there any other command or function for that. Thanks.
Regards,
Faiq