1 Month a go, we already passed our SAP Implementation (All Modules), there are some requirement for BASIS to support project from setting printer, setting user ID, setting Role.
In this case, we need to develop interface between SAP and FTP server to upload PO Document when user run Z Report automatically.
ABAPer already develop Z Report for creating PO document and in last line will call our UNIX automatically.
So, let begin develop FTP Script, we devide 3 bash shell scripts:
sftp.sh
here, we add some line ABAP code for call UNIX script
In this case, we need to develop interface between SAP and FTP server to upload PO Document when user run Z Report automatically.
ABAPer already develop Z Report for creating PO document and in last line will call our UNIX automatically.
So, let begin develop FTP Script, we devide 3 bash shell scripts:
- Precheck Condition for FTP , we call sftp.sh
- FTP script for transfering file and moving , we call sftp_next.sh
- Batchmode for Uploading File, we call batchcmd
sftp.sh
lv_base="/usr/users/interfac/XX/outbound/outboundlog"sftp_next.sh
lv_batch="/usr/users/interfac/XX/outbound"
lv_c=`ls -ltr $lv_batch | grep -i XX | wc -l`
if [ $lv_c == 0 ]thenecho "No Files for FTP or Has been transfered" $(/bin/date +%m-%d-%Y) >> $lv_base/no_transfer_$(/bin/date +%m-%d-%Y).txtelse# In this case, we use Port Secure(31) instead of SFTP/usr/bin/ftp -n <ipadressFTPserver> 31 < $lv_batch/batchcmd >> $lv_base/sftp_log_$(/bin/date +%m-%d-%Y-%H:%M:%S).txtsleep 5/usr/users/interfac/XX/outbound/sftp_next.shfi
lv_direk="/usr/users/interfac/XX/outbound/outboundlog"batchcmd : Sequence command, core of FTP script
lv_log=$lv_direk/move_file_$(/bin/date +%m-%d-%Y-%H:%M:%S).txt
lv_base="/usr/users/interfac/XX/outbound"
mv /usr/users/interfac/XX/outbound/XX* $lv_direk
echo "Copy or Move File" $lv_file "Success" >> $lv_log
batchcmdSo, we already create UNIX script, lets we move to ABAP Code
user
user password
prompt
lcd /usr/users/interfac/XX/outbound/
mput XX*
pwd
bye
here, we add some line ABAP code for call UNIX script
Done..Good Luck for your ABAP code
** Unix Command
data: UNIXCOMM(50).
DATA: BEGIN OF ITABA occurs 0,
LINE(200),
end of ITABA.
*-- Unix Command to call a ftp script in unix
unixcomm = '/bin/sh /usr/users/interfac/XX/outbound/sftp.sh'.
call 'SYSTEM' id 'COMMAND' field UNIXCOMM
id 'TAB' field ITABA-*SYS*.
MESSAGE i001(aq) WITH 'File Successfully Transferred'.
0 Response to "FTP Script Automatically : UNIX"
Posting Komentar