08-10-2009 9:03 AM
Hi all,
I am using dataset to transfer data to fileshare and it works if I use directory in application server for example "D:\". Actually I want to save data to some fileshare like "
pwdf***\test". With the same program it doesn't work at all.
My question is how to map that fileshare? Where should I input user and password to this fileshare?
Thanks,
Felix
08-10-2009 9:20 AM
HI,
Use following:
Data vobject TYPE REF TO zcl_ftp_file_handling.
CREATE OBJECT vobject.
Exporting
i_filename = <file name>
i_ftpuser = <user id>
i_ftppwd = <pwd for the ftp dir>
i_ftpdir = <ftpdir>
08-10-2009 9:22 AM
After creating object use,
CALL METHOD vobject->connect_ftp.
CALL METHOD vobject->export_to_ftp
EXPORTING
data_file = <data file>
unicode = ' '.
CALL METHOD vobject->disconnect_ftp.
08-10-2009 9:25 AM
Hi there,
Thanks for your reply. But I think your solution assumes that server supports FTP function and it's may not feasible to use this. The owner of the fileshare has told us the user name and password.
Normally, if we visit that directly at windows, we are required to input user and password directly. And I wander now, how to input that before report running or set that within report?
Thanks,
Felix
08-10-2009 9:26 AM
Hi Felix,
You can use FTP For this purpose.
Please check the following sample code.
Using scrambe password FM is optional.
g_dlen = STRLEN( p_pwd ).
***Below Function module is used to Encrypt the Password
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = p_pwd "Actual password
sourcelen = g_dlen
key = c_key
IMPORTING
destination = g_dpwd. "Encyrpted Password
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Connecting to FTP Server'(300).
***Connecting to FTP Server
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = p_user
password = g_dpwd
host = p_path
rfc_destination = c_dest
IMPORTING
handle = g_dhdl
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE s000 WITH 'Error in Connection'(250).
ELSE.
MESSAGE s000 WITH 'FTP Connection is Opened'(251).
ENDIF.
***Transferring the data from internal table to FTP Server.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = g_dhdl
fname = g_filename
character_mode = c_x
TABLES
text = lt_table
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE s000 WITH 'File Has Been Created on FTP Server'(252).
ENDIF.
**To Disconnect the FTP Server
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = g_dhdl.
Regards,
Vimal.
Edited by: Vimal V on Aug 10, 2009 10:29 AM
08-10-2009 9:32 AM
08-10-2009 10:38 AM
Hi !
For validating the username and pwd you could make use of running External Commands.. an example is "NET" in Dos based OS..
However you should not have any problems in saving the file using OPEN DATASET.. because when you save a file using Open Dataset.. the SAP OS user credentials are used to create the file.
Revert if you would like to discuss this further.
08-10-2009 11:12 AM
Hi!
You point out the key problem.
I contacted application server owner but it seems he is not very clear how to apply this user and password.
Therefore, I do a simple test to grant write authorization to somebody else. What I need to do is search out the user and add it into the list.
Then, current question is I can't search out user who logges on the application server. From the GUI status screen, it lists server name, but no user. How can I obtain the logged user name?
Thanks,
Felix
08-10-2009 12:30 PM
Hi..
You could try user <SID> ADM.. it is usually the one used for this purpose..
Revert if u need more.
08-10-2009 1:54 PM
Hi,
I think I need more advice. Application server owner tells me that the logged user is myself. It is correct, but this answer seems not to the question. Obviously, the statement Open Dataset doesn't use my id. For me, I can visit that fileshare directly on my laptop.
Again, which is the exact user that need to be granted?
Thanks,
08-10-2009 2:15 PM
>
>For me, I can visit that fileshare directly on my laptop.
> Thanks,
So you are in a group wich is allowed to access that share. Or you are loggid automatically in by windows.
You need to figure out whith you basis team under which user the SAP is running. Or try a standard one like xxxADM where xxx is your SID:
08-11-2009 9:50 AM
Hi Felix,
Do u have any administrative rights on the folder? If yes then you could try for once to remove the pwd check and see if OPEN dataset works fine or not.
Then after pwd restriction add the username <SAP System ID>ADM and provide the rights same as yours. Log in with this user once through windows and then try Open Dataset.
Revert with results.
08-12-2009 4:08 AM
Thank you all.
I think you've given enough advice on this topic.
Current problem is I can't search out the user we want to grant. I think there must be a solution and I will come back to update this thread.
Thanks again
Felix