Application Development 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: 

Wht I need to pass for FILE and TEXT in 'FTP_R3_TO_SERVER'?

Former Member
0 Kudos

Hi Experts,

In the follwoing FM, am getting SY-SUBRC as 0, so, am guessing my FTP connection is get success,

call function 'FTP_CONNECT'

EXPORTING

user = p_userID

password = g_password

host = p_host

rfc_destination = c_dest

IMPORTING

handle = g_dhdl

EXCEPTIONS

NOT_CONNECTED.

So, in next step, I am using the below FM for transferring the data from internal table to FTP Server.

CALL FUNCTION 'FTP_R3_TO_SERVER'

EXPORTING

HANDLE = g_dhdl, usually, its coming as 1

FNAME = 'c:\datafile.txt'

CHARACTER_MODE = 'X'

TABLES

TEXT = it_text "internal table with one field, where all data records were appendedEXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3

OTHERS = 4.

Issues:

1) but, here, am getting TCPIP_ERROR = 1 error!! so, pls. let me know that, Wht does it mean? How can I rectify it?

2) If I change some parameters, etc,. some tmes am getting DATA_ERROR?

3) mainly, pls. let me know, Wht I have to pass for FNAME?

4) mainly, pls. let me know, Wht I have to pass for TEXT?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

i think u want to put data in server.....and get back....

try to use this fm call function 'DX_FILE_WRITE'

sample program.............i am put my data in application server... and geting back.....

&----


*& MODULE SD.

&----


    • Report ZDMS_BANK *

*----


    • Objective: This Program is to Download BANK data *

    • *

    • *

    • Program : Updates Tables ( ) Downloads data (X ) *

    • Outputs list ( ) *

    • *

    • *

    • DATE Created 10/10/2007 *

    • Author Prabhakar Rao *

    • Location EFL/Mumbai *

*----


    • External Dependencies *

*----


    • *

*----


    • Amendment History *

*----


    • Who Change ID(date) Reason *

    • *

*----


report zdms_bank.

tables: zdms_mst_knvv,

knvp,

knbk,

bnka.

data: begin of it_mst_knvv occurs 0,

kunnr like knvp-kunnr,

vkorg like knvv-vkorg,

vtweg like knvv-vtweg,

spart like knvv-spart,

kdgrp like knvv-kdgrp,

end of it_mst_knvv .

data: begin of it_knvp occurs 0,

kunnr like knvp-kunnr,

end of it_knvp .

data: begin of it_knbk occurs 0,

kunnr like knbk-kunnr,

bankl like knbk-bankl,

bankn like knbk-bankn,

bvtyp like knbk-bvtyp,

koinh like knbk-koinh,

end of it_knbk .

data: begin of it_bnka occurs 0,

bankl like bnka-bankl,

banka like bnka-banka,

brnch like bnka-brnch,

end of it_bnka .

data: begin of it_kna1 occurs 0,

kunnr like kna1-kunnr,

name1 like kna1-name1,

end of it_kna1 .

data: begin of it_download occurs 0,

string(239),

end of it_download.

data: f1(2),

f2(2),

f3(2),

f4(2).

data: it_textno like zdms_textno occurs 0,

wa_textno like line of it_textno .

data : gv_filenum like zdms_textno-filenumber ,

gv_path like zdms_textno-path,

gv_filenumc(10) type c .

  • DATA: gv_file1 type string.

data: gv_file1 type dxfile-filename,

it_temp type standard table of dxrawdata.

data : w_server type msxxlist-name value 'r3prod_EEP_05'.

start-of-selection.

select kunnr

vkorg

vtweg

spart

kdgrp

from zdms_mst_knvv

into table it_mst_knvv .

if not it_mst_knvv[] is initial.

select kunnr

from knvp

into table it_knvp

for all entries in it_mst_knvv

where kunnr eq it_mst_knvv-kunnr

and vkorg eq '1000'

and vtweg eq '25'

and spart eq '00'

and parvw eq 'AG'.

endif.

if not it_knvp[] is initial.

select kunnr

name1

from kna1

into table it_kna1

for all entries in it_knvp

where kunnr eq it_knvp-kunnr.

endif.

if not it_knvp[] is initial.

select kunnr

bankl

bankn

bvtyp

koinh

from knbk

into table it_knbk

for all entries in it_knvp

where kunnr = it_knvp-kunnr.

endif.

if not it_knbk[] is initial.

select bankl

banka

brnch

from bnka

into table it_bnka

for all entries in it_knbk

where bankl = it_knbk-bankl.

endif.

it_download-string = 'BANK' .

append it_download .

clear it_download .

it_download-string = '{' .

append it_download .

clear it_download .

loop at it_knvp.

clear: it_knbk,

it_bnka,

it_kna1.

read table it_kna1 with key kunnr = it_knvp-kunnr.

read table it_knbk with key kunnr = it_knvp-kunnr.

if sy-subrc = 0.

read table it_bnka with key bankl = it_knbk-bankl.

endif.

if ( it_knbk-bankl ne '' and it_knbk-kunnr ne '' and it_knbk-bankn ne '').

if it_bnka-banka eq ''.

f1 = ' ~'.

else.

f1 = '~'.

endif.

if it_kna1-name1 eq ''.

f2 = ' ~'.

else.

f2 = '~'.

endif.

if it_knbk-bvtyp eq ''.

f3 = ' ~'.

else.

f3 = '~'.

endif.

if it_knbk-koinh eq ''.

f4 = ' ~'.

else.

f4 = '~'.

endif.

concatenate 'BANK'

'~'

'001'

'~'

it_knbk-bankl

'~'

it_knbk-kunnr

'~'

it_knbk-bankn

'~'

it_bnka-banka

f1

it_kna1-name1

f2

it_knbk-bankl

'~'

it_knbk-bvtyp

f3

it_knbk-koinh

f4

';'

into it_download-string.

append it_download.

clear it_download.

endif.

endloop.

it_download-string = '}' .

append it_download .

clear it_download .

clear: gv_filenum ,

gv_filenumc,

gv_file1 ,

wa_textno .

select single filenumber path

from zdms_textno

into (gv_filenum, gv_path)

where filename eq 'DMS_' .

move gv_filenum to gv_filenumc .

shift gv_filenumc left deleting leading '0'.

  • if gv_filenum < 10 .

  • concatenate '0' gv_filenumc into gv_filenumc .

  • endif.

concatenate gv_path 'DMS_'

gv_filenumc

'.txt'

into gv_file1 .

*************************************Commented By Anbu****************************************************

*Downloading the file to Application Server**

*open dataset gv_file1 for output in text mode ENCODING DEFAULT .

*

  • loop at it_download.

  • transfer it_download-string to gv_file1.

  • endloop.

  • LOOP AT it_download.

  • move it_download TO it_temp.

  • ENDLOOP.

it_temp[] = it_download[].

call function 'DX_FILE_WRITE'

exporting

filename = gv_file1

server = w_server

pc = ''

tables

data_tab = it_temp

exceptions

no_file_on_server = 1

no_data_on_server = 2

gui_download_failed = 3

no_authority = 4

others = 5.

if sy-subrc <> 0.

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

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

endif.

*************************************Ended By Anbu****************************************************

close dataset gv_file1.

if sy-subrc = 0.

wa_textno-filename = 'DMS_' .

wa_textno-filenumber = gv_filenum + 1 .

wa_textno-path = gv_path.

modify zdms_textno from wa_textno .

endif.

if it is usefull.........Plz Reward

Regards

Anbu

1 REPLY 1

Former Member
0 Kudos

i think u want to put data in server.....and get back....

try to use this fm call function 'DX_FILE_WRITE'

sample program.............i am put my data in application server... and geting back.....

&----


*& MODULE SD.

&----


    • Report ZDMS_BANK *

*----


    • Objective: This Program is to Download BANK data *

    • *

    • *

    • Program : Updates Tables ( ) Downloads data (X ) *

    • Outputs list ( ) *

    • *

    • *

    • DATE Created 10/10/2007 *

    • Author Prabhakar Rao *

    • Location EFL/Mumbai *

*----


    • External Dependencies *

*----


    • *

*----


    • Amendment History *

*----


    • Who Change ID(date) Reason *

    • *

*----


report zdms_bank.

tables: zdms_mst_knvv,

knvp,

knbk,

bnka.

data: begin of it_mst_knvv occurs 0,

kunnr like knvp-kunnr,

vkorg like knvv-vkorg,

vtweg like knvv-vtweg,

spart like knvv-spart,

kdgrp like knvv-kdgrp,

end of it_mst_knvv .

data: begin of it_knvp occurs 0,

kunnr like knvp-kunnr,

end of it_knvp .

data: begin of it_knbk occurs 0,

kunnr like knbk-kunnr,

bankl like knbk-bankl,

bankn like knbk-bankn,

bvtyp like knbk-bvtyp,

koinh like knbk-koinh,

end of it_knbk .

data: begin of it_bnka occurs 0,

bankl like bnka-bankl,

banka like bnka-banka,

brnch like bnka-brnch,

end of it_bnka .

data: begin of it_kna1 occurs 0,

kunnr like kna1-kunnr,

name1 like kna1-name1,

end of it_kna1 .

data: begin of it_download occurs 0,

string(239),

end of it_download.

data: f1(2),

f2(2),

f3(2),

f4(2).

data: it_textno like zdms_textno occurs 0,

wa_textno like line of it_textno .

data : gv_filenum like zdms_textno-filenumber ,

gv_path like zdms_textno-path,

gv_filenumc(10) type c .

  • DATA: gv_file1 type string.

data: gv_file1 type dxfile-filename,

it_temp type standard table of dxrawdata.

data : w_server type msxxlist-name value 'r3prod_EEP_05'.

start-of-selection.

select kunnr

vkorg

vtweg

spart

kdgrp

from zdms_mst_knvv

into table it_mst_knvv .

if not it_mst_knvv[] is initial.

select kunnr

from knvp

into table it_knvp

for all entries in it_mst_knvv

where kunnr eq it_mst_knvv-kunnr

and vkorg eq '1000'

and vtweg eq '25'

and spart eq '00'

and parvw eq 'AG'.

endif.

if not it_knvp[] is initial.

select kunnr

name1

from kna1

into table it_kna1

for all entries in it_knvp

where kunnr eq it_knvp-kunnr.

endif.

if not it_knvp[] is initial.

select kunnr

bankl

bankn

bvtyp

koinh

from knbk

into table it_knbk

for all entries in it_knvp

where kunnr = it_knvp-kunnr.

endif.

if not it_knbk[] is initial.

select bankl

banka

brnch

from bnka

into table it_bnka

for all entries in it_knbk

where bankl = it_knbk-bankl.

endif.

it_download-string = 'BANK' .

append it_download .

clear it_download .

it_download-string = '{' .

append it_download .

clear it_download .

loop at it_knvp.

clear: it_knbk,

it_bnka,

it_kna1.

read table it_kna1 with key kunnr = it_knvp-kunnr.

read table it_knbk with key kunnr = it_knvp-kunnr.

if sy-subrc = 0.

read table it_bnka with key bankl = it_knbk-bankl.

endif.

if ( it_knbk-bankl ne '' and it_knbk-kunnr ne '' and it_knbk-bankn ne '').

if it_bnka-banka eq ''.

f1 = ' ~'.

else.

f1 = '~'.

endif.

if it_kna1-name1 eq ''.

f2 = ' ~'.

else.

f2 = '~'.

endif.

if it_knbk-bvtyp eq ''.

f3 = ' ~'.

else.

f3 = '~'.

endif.

if it_knbk-koinh eq ''.

f4 = ' ~'.

else.

f4 = '~'.

endif.

concatenate 'BANK'

'~'

'001'

'~'

it_knbk-bankl

'~'

it_knbk-kunnr

'~'

it_knbk-bankn

'~'

it_bnka-banka

f1

it_kna1-name1

f2

it_knbk-bankl

'~'

it_knbk-bvtyp

f3

it_knbk-koinh

f4

';'

into it_download-string.

append it_download.

clear it_download.

endif.

endloop.

it_download-string = '}' .

append it_download .

clear it_download .

clear: gv_filenum ,

gv_filenumc,

gv_file1 ,

wa_textno .

select single filenumber path

from zdms_textno

into (gv_filenum, gv_path)

where filename eq 'DMS_' .

move gv_filenum to gv_filenumc .

shift gv_filenumc left deleting leading '0'.

  • if gv_filenum < 10 .

  • concatenate '0' gv_filenumc into gv_filenumc .

  • endif.

concatenate gv_path 'DMS_'

gv_filenumc

'.txt'

into gv_file1 .

*************************************Commented By Anbu****************************************************

*Downloading the file to Application Server**

*open dataset gv_file1 for output in text mode ENCODING DEFAULT .

*

  • loop at it_download.

  • transfer it_download-string to gv_file1.

  • endloop.

  • LOOP AT it_download.

  • move it_download TO it_temp.

  • ENDLOOP.

it_temp[] = it_download[].

call function 'DX_FILE_WRITE'

exporting

filename = gv_file1

server = w_server

pc = ''

tables

data_tab = it_temp

exceptions

no_file_on_server = 1

no_data_on_server = 2

gui_download_failed = 3

no_authority = 4

others = 5.

if sy-subrc <> 0.

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

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

endif.

*************************************Ended By Anbu****************************************************

close dataset gv_file1.

if sy-subrc = 0.

wa_textno-filename = 'DMS_' .

wa_textno-filenumber = gv_filenum + 1 .

wa_textno-path = gv_path.

modify zdms_textno from wa_textno .

endif.

if it is usefull.........Plz Reward

Regards

Anbu