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

FTP error--urgent

Former Member
0 Likes
1,010

Hi all,

i am using SAPFTP for transfer of file from presentation server to ftp server.i am comming across error like

<b>put c:/pabi35.txt

open c:/pabi35.txt errno 22: Invalid argument</b>

my code is as follows.plz suggest me , where i am making mistake.it is very urgent.Thanks for ur help.

THis is working fine if i use application server file with SAPFTPA.what is the problem with this?

data: user(64) type c value 'EDI_FTP',

pwd(64) type c value 'jhtediftp2006',

host(64) type c value '172.16.100.16',

cmd1(80) type c ,

cmd2(80) type c ,

cmd3(80) type c ,

dest like rfcdes-rfcdest value 'SAPFTP',

compress type c value 'N'.

data:zfile(150) type c.

data: hdl type i,

key type i value 26101957,

dstlen type i.

data: begin of result occurs 0,

line(100) type c,

end of result.

data:begin of bt occurs 0,

zdate like zmt012-zdate,

userid like zmt012-userid,

seq(10) type c,

matnr like zmt012-matnr,

menge(13) type c,

lgpla like zmt012-lgpla,

charg like zmt012-charg,

date_code like zmt012-date_code,

lot_code like zmt012-lot_code,

lifnr like zmt012-lifnr,

end of bt.

describe field pwd length dstlen.

select * from zmt012.

move zmt012-zdate to bt-zdate.

move zmt012-userid to bt-userid.

move zmt012-matnr to bt-matnr.

move zmt012-lgpla to bt-lgpla.

move zmt012-charg to bt-charg.

move zmt012-date_code to bt-date_code.

move zmt012-lot_code to bt-lot_code.

move zmt012-lifnr to bt-lifnr.

move zmt012-seq to bt-seq." unit char.

move zmt012-menge to bt-menge.

append bt.

endselect.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

  • FILENAME = 'c:\pabi33.txt '

FILENAME = 'c:/pabi35.txt'

FILETYPE = 'DAT'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = bt.

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • OTHERS = 10

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

call 'AB_RFC_X_SCRAMBLE_STRING'

id 'SOURCE' field pwd id 'KEY' field key

id 'SCR' field 'X' id 'DESTINATION' field pwd

id 'DSTLEN' field dstlen.

call function 'FTP_CONNECT'

exporting

user = user

password = pwd

host = host

rfc_destination = dest

importing

handle = hdl.

CONCATENATE dir printer bt-userid bt-zdate sy-uzeit bt-seq '.txt'

INTO zfilename.

CONDENSE zfilename no-gaps.

zfile = 'c:/pabi35.txt'.

concatenate 'put' zfile into cmd1 separated by space.

if cmd1 ne ' '.

call function 'FTP_COMMAND'

exporting

handle = hdl

command = cmd1

compress = compress

tables

data = result

exceptions

command_error = 1

tcpip_error = 2.

  • IF SY-SUBRC EQ 0.

loop at result.

write:/ result.

endloop.

  • ENDIF.

refresh result.

endif.

if cmd2 ne ' '.

call function 'FTP_COMMAND'

exporting

handle = hdl

command = cmd2

tables

data = result

exceptions

command_error = 1

tcpip_error = 2.

loop at result.

write:/ result.

endloop.

refresh result.

endif.

if cmd3 ne ' '.

call function 'FTP_COMMAND'

exporting

handle = hdl

command = cmd3

tables

data = result

exceptions

command_error = 1

tcpip_error = 2.

loop at result.

write:/ result.

endloop.

refresh result.

endif.

call function 'FTP_DISCONNECT'

exporting

handle = hdl.

at selection-screen output.

loop at screen.

if screen-name = 'PWD'.

screen-invisible = '1'.

modify screen.

endif.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
721

Hi Pabitra,

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

  • FILENAME = 'c:\pabi33.txt '

FILENAME = <b>'C:\</b>pabi35.txt'

<b>FILETYPE = 'ASC'</b>

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = bt.

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • OTHERS = 10

.

Best regards,

Prashant

<b>PS : Many of your previous threads are OPEN, Please close them by awarding appropriate points by selecting radio button on the left</b>

Hi all,

i am using SAPFTP for transfer of file from presentation server to ftp server.i am comming across error like

<b>put c:/pabi35.txt

open c:/pabi35.txt errno 22: Invalid argument</b>

my code is as follows.plz suggest me , where i am making mistake.it is very urgent.Thanks for ur help.

THis is working fine if i use application server file with SAPFTPA.what is the problem with this?

data: user(64) type c value 'EDI_FTP',

pwd(64) type c value 'jhtediftp2006',

host(64) type c value '172.16.100.16',

cmd1(80) type c ,

cmd2(80) type c ,

cmd3(80) type c ,

dest like rfcdes-rfcdest value 'SAPFTP',

compress type c value 'N'.

data:zfile(150) type c.

data: hdl type i,

key type i value 26101957,

dstlen type i.

data: begin of result occurs 0,

line(100) type c,

end of result.

data:begin of bt occurs 0,

zdate like zmt012-zdate,

userid like zmt012-userid,

seq(10) type c,

matnr like zmt012-matnr,

menge(13) type c,

lgpla like zmt012-lgpla,

charg like zmt012-charg,

date_code like zmt012-date_code,

lot_code like zmt012-lot_code,

lifnr like zmt012-lifnr,

end of bt.

describe field pwd length dstlen.

select * from zmt012.

move zmt012-zdate to bt-zdate.

move zmt012-userid to bt-userid.

move zmt012-matnr to bt-matnr.

move zmt012-lgpla to bt-lgpla.

move zmt012-charg to bt-charg.

move zmt012-date_code to bt-date_code.

move zmt012-lot_code to bt-lot_code.

move zmt012-lifnr to bt-lifnr.

move zmt012-seq to bt-seq." unit char.

move zmt012-menge to bt-menge.

append bt.

endselect.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

  • FILENAME = 'c:\pabi33.txt '

FILENAME = 'c:/pabi35.txt'

FILETYPE = 'DAT'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = bt.

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • OTHERS = 10

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

call 'AB_RFC_X_SCRAMBLE_STRING'

id 'SOURCE' field pwd id 'KEY' field key

id 'SCR' field 'X' id 'DESTINATION' field pwd

id 'DSTLEN' field dstlen.

call function 'FTP_CONNECT'

exporting

user = user

password = pwd

host = host

rfc_destination = dest

importing

handle = hdl.

CONCATENATE dir printer bt-userid bt-zdate sy-uzeit bt-seq '.txt'

INTO zfilename.

CONDENSE zfilename no-gaps.

zfile = 'c:/pabi35.txt'.

concatenate 'put' zfile into cmd1 separated by space.

if cmd1 ne ' '.

call function 'FTP_COMMAND'

exporting

handle = hdl

command = cmd1

compress = compress

tables

data = result

exceptions

command_error = 1

tcpip_error = 2.

  • IF SY-SUBRC EQ 0.

loop at result.

write:/ result.

endloop.

  • ENDIF.

refresh result.

endif.

if cmd2 ne ' '.

call function 'FTP_COMMAND'

exporting

handle = hdl

command = cmd2

tables

data = result

exceptions

command_error = 1

tcpip_error = 2.

loop at result.

write:/ result.

endloop.

refresh result.

endif.

if cmd3 ne ' '.

call function 'FTP_COMMAND'

exporting

handle = hdl

command = cmd3

tables

data = result

exceptions

command_error = 1

tcpip_error = 2.

loop at result.

write:/ result.

endloop.

refresh result.

endif.

call function 'FTP_DISCONNECT'

exporting

handle = hdl.

at selection-screen output.

loop at screen.

if screen-name = 'PWD'.

screen-invisible = '1'.

modify screen.

endif.

endloop.

3 REPLIES 3
Read only

Former Member
0 Likes
722

Hi Pabitra,

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

  • FILENAME = 'c:\pabi33.txt '

FILENAME = <b>'C:\</b>pabi35.txt'

<b>FILETYPE = 'ASC'</b>

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = bt.

  • FIELDNAMES =

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_WRITE_ERROR = 2

  • INVALID_FILESIZE = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • OTHERS = 10

.

Best regards,

Prashant

<b>PS : Many of your previous threads are OPEN, Please close them by awarding appropriate points by selecting radio button on the left</b>

Read only

0 Likes
721

Hi patil,

This(ur idea) is not working.i am doing mistake somewhere else.but this program is working fine with sapftpa if i will go for application server.plz suggest me where i am doing mistake?

Thanks for ur kind help

Regards

pabitra

Read only

Former Member
0 Likes
721

Try if the below works...

Steps for FTP

connect.

lcd c:\

put file ---> here file is just the filename

disconnect.