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: 

SAPFTPA FTP_SERVER_TO_R3 Output in different language

former_member605939
Participant
0 Kudos

I am working on SAPFTPA background job.

I am using following function module (binary mode)

call function 'FTP_SERVER_TO_R3'
exporting
handle = w_hdl
fname = wrk_file
importing
blob_length = blob_length
tables
blob = gt_downlaod.

After executing the function module gt_download contains data in some different character format.

the format is attached.

6 REPLIES 6

former_member605939
Participant
0 Kudos

Looking for solution of the above post... In background the job gets cancelled with

"RFC to program SAPFTPA failed 04 205 E"

In front end it is working fine, but in background the table gt_download gets updated with some other language

and job gets cancelled.....

former_member605939
Participant
0 Kudos

Looking for the solution

SAPFTPA FTP_SERVER_TO_R3 Output in different language

call function 'FTP_SERVER_TO_R3'
exporting
handle = w_hdl
fname = wrk_file
importing
blob_length = blob_length
tables
blob = gt_downlaod.

After executing the function module gt_download contains data in some different character format.

Sandra_Rossi
Active Contributor
0 Kudos

The term "language" is incorrect, better use "mojibake".

1) What if you run the job in debug with JDBG? (okcode in SM37) Can you see in debug where it stops? I see that message 04 205 is sent by FTP_CONNECT.

2) I guess you pass SAPFTPA to FTP_CONNECT, did you try to regenerate SAPFTPA with program RSFTP005?

3) What is different between dialog and background? User ID? Logon language?

NB: you declared GT_DOWNLOAD as a string of characters but by default the parameter CHARACTER_MODE = ' '. Either you pass it to 'X' or you define the variable as a table of bytes (and decode to the right code page).

former_member605939
Participant
0 Kudos

Hi sandra.rossi

1) After debugging found that function module call function 'FTP_SERVER_TO_R3'

exporting
handle = w_hdl
fname = wrk_file
importing
blob_length = blob_length
tables
blob = gt_downlaod.

gt_download gets updated with attached file.

2) SAPFTPA with program RSFTP005 is working fine.

3) User and language is same for dialog and background.

4) if pas CHARACTER_MODE = then it is giving dump.

I think point number 1 is the cause of "mojibake".

Sandra_Rossi
Active Contributor

Please select your code and press the "CODE" button to make it correctly colorized/indented, so that it's easier for us to analyze it. Thank you.

"RSFTP005 is working fine" yes of course, it's used to regenerate SAPFTPA, so I guess you ran it and it generated it OK.

"giving dump" what dump? -> correct your program to not have a dump.

Thanks. These bytes:

492C31303E37312C4D414455524120494E445553545249414C2054455854494C4553204C54442C353734303439342C2C30322F303E2F323032312C...

correspond to ASCII or UTF-8:

I,10>71,MADURA INDUSTRIAL TEXTILES LTD,5740494,,02/0>/2021,...

For some unknown reason, dialog and background don't behave the same concerning the encoding of characters.

Normalize the way you get the characters. Try this:

DATA gt_characters TYPE soli_tab.
call function 'FTP_SERVER_TO_R3'
  exporting
    handle         = w_hdl
    fname          = wrk_file
    character_mode = 'X'
  tables
    text           = gt_characters.

If it still doesn't work, I suggest that you read in binary mode and store into a binary variable (type SOLIX_TAB for instance), then you decode yourself with code page hardcoded (ASCII or UTF-8), and it's certain that it will work in both situations. Below is the code for UTF-8.

DATA gt_bytes TYPE solix_tab.
call function 'FTP_SERVER_TO_R3'
  exporting
    handle         = w_hdl
    fname          = wrk_file
    character_mode = ' '
  importing
    blob_length    = blob_length
  tables
    blob           = gt_bytes.

DATA(xstring) = cl_bcs_convert=>solix_to_xstring( IT_SOLIX = gt_bytes IV_SIZE = blob_length ).

DATA(string) = cl_abap_codepage=>convert_from( xstring ). " UTF-8

Sandra_Rossi
Active Contributor

Thank you for the feedback "Main point was the conversion of character and binary format." Maybe you can post your solution as an Answer so that to help future visitors. Note that SAP Rules of Engagement prevent users from sharing private information like email addresses.