‎2009 Jul 28 3:59 AM
Hello,
Please help me on how to use the logical command.
Here is the details of my problem.
In program, a flat file is created and put on the file system. Right after storing the flat file on the file system, an additional logical command needs to be called that starts an FTP script.
logical command: Z_POSTING_PUT
The problem is, I don't know how to use the said logical command. Can any body help me please....
Thanks a lot.
massive
‎2009 Jul 28 4:25 AM
I think you have already created your logical command thru Sm59 ( ie
Use fm SXPG_COMMAND_EXECUTE to call logical command script Z_POSTING_PUT
call function 'SXPG_COMMAND_EXECUTE'
exporting
commandname = Z_POSTING_PUT
a®
‎2009 Jul 28 4:34 AM
Hello,
Thanks for your reply. May i know what is the use of the logical command in the program?
massive
‎2009 Jul 28 4:39 AM
it is used to connect the various external system..
the commond varies according to the system you are using
it can be seen in SM49 transaction and according you need to chose that
* connect to the FTP server and send the files.
* Calculate password length
u201C password used for connection
v_slen = strlen( ppwd ).
* Encrypt password
call function 'HTTP_SCRAMBLE'
exporting
source = ppwd
sourcelen = v_slen
key = v_key
importing
destination = v_encrypted_pwd.
* Connect to destination server
call function 'FTP_CONNECT'
exporting
user = puser
password = v_encrypted_pwd
host = phost u201CHost address
rfc_destination = c_rfc_destination u201Cit is a constant c_rfc_destination type rfcdes-rfcdest value 'SAPFTPA'.
importing
handle = v_handle
exceptions
not_connected.
if sy-subrc <> 0.
message e002 with phost sy-subrc.
endif.
refresh it_result.
refresh it_commands.Commands will depend on which OS is being used on server side and client side.
This code is for unix machines
* change the directory on the destination machine
concatenate 'cd' prpath into wa_command-line separated by space.
append wa_command to it_commands.
* Change the local directory on the sap server
concatenate 'lcd' plpath into wa_command-line separated by space.
append wa_command to it_commands.
* Set Ascii mode
clear wa_command-line.
if pbin eq 'X'.
move 'bin' to wa_command-line.
else.
move 'asc' to wa_command-line.
endif.
append wa_command to it_commands.
* files to be transferred
loop at it_list into wa_list.
* Put the file from the sap server to the destination machine
concatenate 'put' wa_list-name wa_list-name
into wa_command-line separated by space.
append wa_command to it_commands.
endloop.
* Send FTP commands to server
call function 'FTP_COMMAND_LIST'
exporting
handle = v_handle
importing
command_index = v_command_index
tables
data = it_result
commands = it_commands
exceptions
command_error = 1
tcpip_error = 2.
v_subrc = sy-subrc.
if v_subrc ne 0.
* if there is an error disconnect from the server
* and display an appropriate message
perform ftp_disconnect using v_handle c_rfc_destination.
message e004.
endif.
**************************************************************
form ftp_disconnect using
in_handle
in_rfc_destination.
* Disconnect from destination server
call function 'FTP_DISCONNECT'
exporting
handle = in_handle.
* Close RFC connection
call function 'RFC_CONNECTION_CLOSE'
exporting
destination = in_rfc_destination
exceptions
others = 1.
endform. "ftp_disconnect
‎2009 Jul 28 4:46 AM
Please look into this thread
http://help.sap.com/saphelp_nw04/helpdata/EN/c4/3a6047505211d189550000e829fbbd/frameset.htm
a®