SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

FTP via ABAP - report + Unix Script



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Transport and Upgrade | Транспорт и Обновления
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Nov 17, 2007 6:51 pm    Post subject: FTP via ABAP - report + Unix Script Reply with quote

Code:
REPORT YFTP1 .

*  FTP by abap.
*  This program passses host, user, source/target
*  directory and file parameters to a UNIX script which
*  in turn gets the required file from the host by ftp.
*  The unix script should look like this:
*
*  #! /bin/sh
*  ftp -n $1 << !!
*  user $2 $3
*  cd ..                      <-- only for mainframe ftp
*  get $4 $5
*  quit
*  !!
*
*  placed in the adm path, preferably under
*  /sapmnt//exe. In order to make this program
*  work please create sapcpic/manager cpic user and
*  apply note no. 41770.


PARAMETERS: HOST(10) OBLIGATORY LOWER CASE,
USER(8) OBLIGATORY LOWER CASE,
PASSWORD(8) OBLIGATORY LOWER CASE,
SRC_FILE(45) OBLIGATORY LOWER CASE,
TRG_FILE(45) DEFAULT '/usr/sap/trans/data/??????' OBLIGATORY LOWER CASE,
BIN AS CHECKBOX.
DATA: JC(8), FLG(1), B(128), PRNAME(128), LOGFILE(30), AAA(40).

DATA: BEGIN OF A,
1(12), 2(10), 3(10), 4(47), 5(47),
END OF A.

IF HOST = 'zxaq'.
  IF BIN = 'X'.
    PRNAME = 'ftp_bin_vms'.
  ELSE.
    PRNAME = 'ftp_asc_vms'.
  ENDIF.
ELSE.
  IF BIN = 'X'.
    PRNAME = '/usr/sap/trans/bin/ftp_bin_unix'.
  ELSE.
    PRNAME = '/usr/sap/trans/bin/ftp_asc_unix'.
  ENDIF.
ENDIF.

A-1 = HOST.
A-2 = USER.
A-3 = PASSWORD.
A-4 = SRC_FILE.
A-5 = TRG_FILE.
CONDENSE A.
B = A.

CALL FUNCTION 'JOB_OPEN'
     EXPORTING
          JOBNAME  = 'FTP'
     IMPORTING
          JOBCOUNT = JC.

CALL FUNCTION 'JOB_SUBMIT'
     EXPORTING
          AUTHCKNAM     = SY-UNAME
          EXTPGM_NAME   = PRNAME
          EXTPGM_PARAM  = B
          EXTPGM_SYSTEM = 'jupiter'
          JOBCOUNT      = JC
          JOBNAME       = 'FTP'.

CALL FUNCTION 'JOB_CLOSE'
     EXPORTING
          JOBCOUNT         = JC
          JOBNAME          = 'FTP'
          STRTIMMED        = 'X'
          TARGETSYSTEM     = 'jupiter'
     IMPORTING
          JOB_WAS_RELEASED = FLG.

LOGFILE = '/tmp/ftp.log'.
DO.
  OPEN DATASET LOGFILE FOR INPUT IN TEXT MODE.
  IF SY-SUBRC = 0. EXIT. ENDIF.
ENDDO.

DO.
  READ DATASET LOGFILE INTO AAA.
  IF SY-SUBRC = 0. WRITE / AAA. ENDIF.
  IF AAA = 'FTP completed'. EXIT. ENDIF.
ENDDO.

CLOSE DATASET LOGFILE.
delete dataset logfile.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Transport and Upgrade | Транспорт и Обновления All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.