Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Regarding FTP_COPY

Former Member
0 Likes
1,385

Hi all,

I have written a simiple code to place a flat file on the application server.

Then I have used the function modules HTTP_SCRAMBLE,

FTP_CONNECT,

CTP_COPY,

and finally FTP_DISCONNECT to copy the file from the application server

to the FTP address given to me.

However, I am not able to connect.

I am getting the message... "Attempt to connect to FTP://123...... failed"

I am just wondering .... has anything to be set up by the BASIS Team???

The FTP address given by me is accessible from the outside world. It's public.

It's working . we have checked it.

The network team at my client's place has allowed data to go out from the DEV server.

I am executing the ABAP code from the DEV server using a DEV user id.

However, they are not able to ping from unix command promt of the DEV server. OS is unix.

Let me know , if anything has to be configured by the BASIS team.

The following is my code---


REPORT  ZTP_HR_FAMILY_DATA.

* INTERNAL TABLES

DATA: BEGIN OF IT0021 OCCURS 0,
        PERNR LIKE P0021-PERNR,    " EMPLOYEE NUMBER
        SUBTY LIKE P0021-SUBTY,   " SUBTYPE
        BEGDA LIKE P0021-BEGDA,   " START DATE
        ENDDA LIKE P0021-ENDDA,   " END DATE
        FANAM LIKE P0021-FANAM,   " LAST NAME
        FAVOR LIKE P0021-FAVOR,   " FIRST NAME
        FASEX LIKE P0021-FASEX,   " GENDER
        FGBDT LIKE P0021-FGBDT,   " DATE OF BIRTH
        FGBOT LIKE P0021-FGBOT,   " BIRTH PLACE
        FGBLD LIKE P0021-FGBLD,   " COUNTRY OF BIRTH
        FANAT LIKE P0021-FANAT,   " NATIONALITY
      END OF IT0021.


DATA: BEGIN OF IT0021_D OCCURS 0,
        PERNR LIKE P0021-PERNR,    " EMPLOYEE NUMBER
        SUBTY LIKE P0021-SUBTY,   " SUBTYPE
        BEGDA LIKE P0021-BEGDA,   " START DATE
        ENDDA LIKE P0021-ENDDA,   " END DATE
        FANAM LIKE P0021-FANAM,   " LAST NAME
        FAVOR LIKE P0021-FAVOR,   " FIRST NAME
        FASEX LIKE P0021-FASEX,   " GENDER
        FGBDT LIKE P0021-FGBDT,   " DATE OF BIRTH
        FGBOT LIKE P0021-FGBOT,   " BIRTH PLACE
        FGBLD LIKE P0021-FGBLD,   " COUNTRY OF BIRTH
        FANAT LIKE P0021-FANAT,   " NATIONALITY
      END OF IT0021_D.

DATA: DATA TYPE STRING.

*DATA: BEGIN OF FINAL1 OCCURS 0,
 *     DATA TYPE STRING,
  *  END OF FINAL1.

DATA: FILE(100) TYPE  C VALUE '/tmp/cnergyis/family3.txt'.


START-OF-SELECTION.

  SELECT *    "pernr
*         subty
*         begda
*         endda
*         fanam
*         favor
*         fasex
*         fgbdt
*         fgbot
*         fgbld
*         fanat
 FROM PA0021 UP TO 10 ROWS  INTO CORRESPONDING FIELDS OF TABLE IT0021.

*  IF sy-subrc EQ 0.
*    WRITE:/ 'DATA IS THERE'.
*  ENDIF.

*IF NOT it0021[] IS INITIAL.
*  SORT it0021 BY pernr.
*ENDIF.


  OPEN  DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT  . 
  IF SY-SUBRC EQ 0.
    LOOP AT IT0021.
      CONCATENATE IT0021-PERNR
                  IT0021-SUBTY
                  IT0021-BEGDA
                  IT0021-ENDDA
                  IT0021-FANAM
                  IT0021-FAVOR
                  IT0021-FASEX
                  IT0021-FGBDT
                  IT0021-FGBOT
                  IT0021-FGBLD
                  IT0021-FANAT
                  INTO DATA SEPARATED BY '~'.
      TRANSFER DATA TO FILE.
      IF SY-SUBRC EQ 0.
        WRITE:/ 'Row created'.
      ELSE.
        WRITE:/ 'failed'.
      ENDIF.
    ENDLOOP.
  ENDIF.
**

  CLOSE DATASET FILE.
  IF SY-SUBRC NE 0.
    WRITE:/ 'not closed'.
  ELSE.
  write:/ 'closed'.

   DATA: PWD(7) TYPE C VALUE '*****9#',
        SLEN TYPE I VALUE '7',
        KEY TYPE I VALUE 26101957,
  SUSER(13) TYPE C VALUE 'administrator',
        SHOST(100) TYPE C VALUE 'ftp://123.252.134.10',
*        rfc_dest(6) TYPE c VALUE 'SAPFTPA',
        SHDL TYPE I,
        DHDL TYPE I.

  DATA: RESULT TYPE TABLE OF TEXT WITH HEADER LINE.


    CALL FUNCTION 'HTTP_SCRAMBLE'
      EXPORTING
        SOURCE      = PWD
        SOURCELEN   = SLEN
        KEY         = KEY
      IMPORTING
        DESTINATION = PWD.

    IF SY-SUBRC EQ 0.
      WRITE:/ 'PASSWORD SCRAMBLED'.
    ENDIF.
*
    CALL FUNCTION 'FTP_CONNECT'
      EXPORTING
        USER                   = SUSER
        PASSWORD               = PWD
*   ACCOUNT                =
        HOST                   = SHOST
        RFC_DESTINATION        = 'SAPFTP'
*     GATEWAY_USER           = SUSER

*     GATEWAY_PASSWORD       = PWD
*   GATEWAY_HOST           =
     IMPORTING
       HANDLE                 = DHDL
 EXCEPTIONS
   NOT_CONNECTED          = 1
   OTHERS                 = 2
              .
    IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    IF SY-SUBRC EQ 0.
      WRITE:/ 'CONNECTED'.
    ELSE.
      WRITE:/ 'CONNECTION FAILED'.
    ENDIF.


    CALL FUNCTION 'FTP_COPY'
      EXPORTING
        HANDLE_SOURCE            = SHDL
        HANDLE_DESTINATION       = DHDL
        FILE_SOURCE              = FILE
        FILE_DESTINATION         = SHOST
      TABLES
        DATA                     = RESULT
* EXCEPTIONS
*   DATA_ERROR               = 1
*   COMMAND_ERROR            = 2
*   TCPIP_ERROR              = 3
*   OTHERS                   = 4
              .
    IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    IF SY-SUBRC EQ 0.
      WRITE:/ 'COPIED'.
    ELSE.
      WRITE:/ 'NOT COPIED'.
      WRITE:/ RESULT.
    ENDIF.

    CALL FUNCTION 'FTP_DISCONNECT'
      EXPORTING
        HANDLE = SHDL.
    WRITE:/ 'closed'.
  ENDIF.

Warm regards,

Hari Kiran

Edited by: HARI KIRAN REDDY on Jan 7, 2009 4:10 PM

Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:14 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,027

hi,

run the report RSFTP001

you can also check SM59 in order to see the connection for FTP

check this thread

thanks

hi,

run the report RSFTP001

you can also check SM59 in order to see the connection for FTP

check this thread

thanks

6 REPLIES 6
Read only

Former Member
0 Likes
1,028

hi,

run the report RSFTP001

you can also check SM59 in order to see the connection for FTP

check this thread

thanks

Read only

0 Likes
1,027

Hi Rimpa,

Thank you for answering.

I have done all that.

Ran all those RSFTP reports ... we got the same error message.

"Attempt to connect failed "

SAFTP looks fine.

Just have a look at my code and let me know if anything looks wrong.

The BASIS adming when he sits and tries to ftp from the Unix command prompt, it's not happening.

They say they have opened the DEV server for outbound though.

Anyone clarify this simple doubt.

If I execute any of those RSFTP series programs and give the destination ip address and the app server

path and as the BASIS team says " DEV server is open for outbound".....

then that RSFTP program should work????

Am I right about that???

let me know.

Thanking you again,

Warm regards,

Hari Kiran

Read only

0 Likes
1,027

inputs please

Regards,

hari

Read only

Former Member
0 Likes
1,027

Yes thats right.. the RSFTP* program should work with the correct input if BASIS has already opened the connection/ports.

Best regards,

Prashant

Read only

0 Likes
1,027

... also the operating service must grant authority to execute ftp command on server.

Regards,

Clemens

Read only

0 Likes
1,027

Thank you all for the inputs.

Currently, the admin is not able to ping the ftp path given by me

from his Unix command prompt.

It's saying" session timed out".

I am operating alone at the client 's place.

I don't know what to suggest them

or they need to check.

Network guy says DEV server has been allowed for outbound communication.

Then, in that case, they should be able to ping.

let's see what happens.

Thanking you all again.

Hari Kiran